Characteristic Locus
Inheritance System.Object > GraphicsLibrary
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Graphics
Assembly GraphicsLibrary.dll

Syntax

public class GraphicsLibrary

Constructors

View Source

GraphicsLibrary(DisplayBase)

Declaration
public GraphicsLibrary(DisplayBase display)

Parameters

Type Name Description
DisplayBase display

Properties

View Source

CurrentFont

Current font used for displaying text on the display.

Declaration
public FontBase CurrentFont { get; set; }

Property Value

Type Description
FontBase
View Source

Height

Return the height of the display after accounting for the rotation.

Declaration
public uint Height { get; }

Property Value

Type Description
System.UInt32
View Source

Rotation

Current rotation used for drawing pixels to the display

Declaration
public GraphicsLibrary.RotationType Rotation { get; set; }

Property Value

Type Description
GraphicsLibrary.RotationType
View Source

Width

Return the width of the display after accounting for the rotation.

Declaration
public uint Width { get; }

Property Value

Type Description
System.UInt32

Methods

View Source

Clear(Boolean)

Clear the display.

Declaration
public void Clear(bool updateDisplay = false)

Parameters

Type Name Description
System.Boolean updateDisplay

Update the display immediately when true.

View Source

DrawBitmap(Int32, Int32, Int32, Int32, Byte[], Color)

Display a 1-bit bitmap

This method simply calls a similar method in the display hardware.

Declaration
public void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, Color color)

Parameters

Type Name Description
System.Int32 x

Abscissa of the top left corner of the bitmap.

System.Int32 y

Ordinate of the top left corner of the bitmap.

System.Int32 width

Width of the bitmap in bytes.

System.Int32 height

Height of the bitmap in bytes.

System.Byte[] bitmap

Bitmap to display.

Color color

The color of the bitmap.

View Source

DrawBitmap(Int32, Int32, Int32, Int32, Byte[], DisplayBase.BitmapMode)

Display a 1-bit bitmap

This method simply calls a similar method in the display hardware.

Declaration
public void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, DisplayBase.BitmapMode bitmapMode)

Parameters

Type Name Description
System.Int32 x

Abscissa of the top left corner of the bitmap.

System.Int32 y

Ordinate of the top left corner of the bitmap.

System.Int32 width

Width of the bitmap in bytes.

System.Int32 height

Height of the bitmap in bytes.

System.Byte[] bitmap

Bitmap to display.

DisplayBase.BitmapMode bitmapMode

How should the bitmap be transferred to the display?

View Source

DrawCircle(Int32, Int32, Int32, Color, Boolean)

Draw a dircle.

Declaration
public void DrawCircle(int centerX, int centerY, int radius, Color color, bool filled = false)

Parameters

Type Name Description
System.Int32 centerX

Abscissa of the centre point of the circle.

System.Int32 centerY

Ordinate of the centre point of the circle.

System.Int32 radius

Radius of the circle.

Color color

The color of the circle.

System.Boolean filled

Draw a filled circle?

Remarks

This algorithm draws the circle by splitting the full circle into eight segments. This method uses the Midpoint algorithm: https://en.wikipedia.org/wiki/Midpoint_circle_algorithm A C# implementation can be found here: https://rosettacode.org/wiki/Bitmap/Midpoint_circle_algorithm#C.23

View Source

DrawCircle(Int32, Int32, Int32, Boolean, Boolean)

Draw a dircle.

Declaration
public void DrawCircle(int centerX, int centerY, int radius, bool colored = true, bool filled = false)

Parameters

Type Name Description
System.Int32 centerX

Abscissa of the centre point of the circle.

System.Int32 centerY

Ordinate of the centre point of the circle.

System.Int32 radius

Radius of the circle.

System.Boolean colored

Show the circle when true.

System.Boolean filled

Draw a filled circle?

Remarks

This algorithm draws the circle by splitting the full circle into eight segments. This method uses the Midpoint algorithm: https://en.wikipedia.org/wiki/Midpoint_circle_algorithm A C# implementation can be found here: https://rosettacode.org/wiki/Bitmap/Midpoint_circle_algorithm#C.23

View Source

DrawHorizontalLine(Int32, Int32, Int32, Color)

Draw a horizontal line.

Declaration
public void DrawHorizontalLine(int x0, int y0, int length, Color color)

Parameters

Type Name Description
System.Int32 x0

Abscissa of the starting point of the line.

System.Int32 y0

Ordinate of the starting point of the line.

System.Int32 length

Length of the line to draw.

Color color

The color of the line.

View Source

DrawHorizontalLine(Int32, Int32, Int32, Boolean)

Draw a horizontal line.

Declaration
public void DrawHorizontalLine(int x0, int y0, int length, bool colored = true)

Parameters

Type Name Description
System.Int32 x0

Abscissa of the starting point of the line.

System.Int32 y0

Ordinate of the starting point of the line.

System.Int32 length

Length of the line to draw.

System.Boolean colored

Turn the pixel on (true) or off (false).

View Source

DrawLine(Int32, Int32, Int32, Int32, Color)

Draw a line using Bresenhams line drawing algorithm.

Declaration
public void DrawLine(int x0, int y0, int x1, int y1, Color color)

Parameters

Type Name Description
System.Int32 x0

Abscissa of the starting point of the line.

System.Int32 y0

Ordinate of the starting point of the line

System.Int32 x1

Abscissa of the end point of the line.

System.Int32 y1

Ordinate of the end point of the line

Color color

The color of the line.

Remarks

View Source

DrawLine(Int32, Int32, Int32, Int32, Boolean)

Draw a line using Bresenhams line drawing algorithm.

Declaration
public void DrawLine(int x0, int y0, int x1, int y1, bool colored = true)

Parameters

Type Name Description
System.Int32 x0

Abscissa of the starting point of the line.

System.Int32 y0

Ordinate of the starting point of the line

System.Int32 x1

Abscissa of the end point of the line.

System.Int32 y1

Ordinate of the end point of the line

System.Boolean colored

Turn the pixel on (true) or off (false).

Remarks

View Source

DrawPixel(Int32, Int32)

Draw a single pixel using the pen color

Declaration
public void DrawPixel(int x, int y)

Parameters

Type Name Description
System.Int32 x

x location

System.Int32 y

y location

View Source

DrawPixel(Int32, Int32, Color)

Draw a single pixel

Declaration
public void DrawPixel(int x, int y, Color color)

Parameters

Type Name Description
System.Int32 x

x location

System.Int32 y

y location

Color color

Color of pixel.

View Source

DrawPixel(Int32, Int32, Boolean)

Draw a single pixel

Declaration
public void DrawPixel(int x, int y, bool colored)

Parameters

Type Name Description
System.Int32 x

x location

System.Int32 y

y location

System.Boolean colored

Turn the pixel on (true) or off (false).

View Source

DrawRectangle(Int32, Int32, Int32, Int32, Color, Boolean)

Draw a rectangle.

Declaration
public void DrawRectangle(int xLeft, int yTop, int width, int height, Color color, bool filled = false)

Parameters

Type Name Description
System.Int32 xLeft

Abscissa of the top left corner.

System.Int32 yTop

Ordinate of the top left corner.

System.Int32 width

Width of the rectangle.

System.Int32 height

Height of the rectangle.

Color color

The color of the rectangle.

System.Boolean filled

Fill the rectangle (true) or draw the outline (false, default).

View Source

DrawRectangle(Int32, Int32, Int32, Int32, Boolean, Boolean)

Draw a rectangle.

Declaration
public void DrawRectangle(int xLeft, int yTop, int width, int height, bool colored = true, bool filled = false)

Parameters

Type Name Description
System.Int32 xLeft

Abscissa of the top left corner.

System.Int32 yTop

Ordinate of the top left corner.

System.Int32 width

Width of the rectangle.

System.Int32 height

Height of the rectangle.

System.Boolean colored

Draw the pixel (true) or turn the pixel off (false).

System.Boolean filled

Fill the rectangle (true) or draw the outline (false, default).

View Source

DrawText(Int32, Int32, String)

Draw a text message on the display using the current font.

Declaration
public void DrawText(int x, int y, string text)

Parameters

Type Name Description
System.Int32 x

Abscissa of the location of the text.

System.Int32 y

Ordinate of the location of the text.

System.String text

Text to display.

View Source

DrawText(Int32, Int32, String, Color)

Draw a text message on the display using the current font.

Declaration
public void DrawText(int x, int y, string text, Color color)

Parameters

Type Name Description
System.Int32 x

Abscissa of the location of the text.

System.Int32 y

Ordinate of the location of the text.

System.String text

Text to display.

Color color

Color of the text.

View Source

DrawTriangle(Int32, Int32, Int32, Int32, Int32, Int32, Color, Boolean)

Draw a triangle

Declaration
public void DrawTriangle(int x0, int y0, int x1, int y1, int x2, int y2, Color color, bool filled = false)

Parameters

Type Name Description
System.Int32 x0

Vertex #0 x coordinate

System.Int32 y0

Vertex #0 y coordinate

System.Int32 x1

Vertex #1 x coordinate

System.Int32 y1

Vertex #1 y coordinate

System.Int32 x2

Vertex #2 x coordinate

System.Int32 y2

Vertex #2 y coordinate

Color color

Color of triangle

System.Boolean filled

Draw a filled triangle?

View Source

DrawTriangle(Int32, Int32, Int32, Int32, Int32, Int32, Boolean, Boolean)

Draw a triangle

Declaration
public void DrawTriangle(int x0, int y0, int x1, int y1, int x2, int y2, bool colored, bool filled = false)

Parameters

Type Name Description
System.Int32 x0

Vertex #0 x coordinate

System.Int32 y0

Vertex #0 y coordinate

System.Int32 x1

Vertex #1 x coordinate

System.Int32 y1

Vertex #1 y coordinate

System.Int32 x2

Vertex #2 x coordinate

System.Int32 y2

Vertex #2 y coordinate

System.Boolean colored

Should the triangle add (true) or remove (false)

System.Boolean filled

Draw a filled triangle?

Remarks

Draw triangle method for 1 bit displays

View Source

DrawVerticalLine(Int32, Int32, Int32, Color)

Draw a vertical line.

Declaration
public void DrawVerticalLine(int x0, int y0, int length, Color color)

Parameters

Type Name Description
System.Int32 x0

Abscissa of the starting point of the line.

System.Int32 y0

Ordinate of the starting point of the line.

System.Int32 length

Length of the line to draw.

Color color

The color of the line.

View Source

DrawVerticalLine(Int32, Int32, Int32, Boolean)

Draw a vertical line.

Declaration
public void DrawVerticalLine(int x0, int y0, int length, bool colored = true)

Parameters

Type Name Description
System.Int32 x0

Abscissa of the starting point of the line.

System.Int32 y0

Ordinate of the starting point of the line.

System.Int32 length

Length of the line to draw.

System.Boolean colored

Show the line when (true) or off (false).

View Source

GetXForRotation(Int32, Int32)

Declaration
public int GetXForRotation(int x, int y)

Parameters

Type Name Description
System.Int32 x
System.Int32 y

Returns

Type Description
System.Int32
View Source

GetYForRotation(Int32, Int32)

Declaration
public int GetYForRotation(int x, int y)

Parameters

Type Name Description
System.Int32 x
System.Int32 y

Returns

Type Description
System.Int32
View Source

Show()

Show the changes on the display.

Declaration
public void Show()