Remarks
MicroGraphics | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Characteristic | Locus |
---|---|
Inheritance | System.Object > MicroGraphics |
Namespace | Meadow.Foundation.Graphics |
Assembly | MicroGraphics.dll |
Syntax
public class MicroGraphics : ITextDisplay
Constructors
MicroGraphics(PixelBufferBase, Boolean)
Create a new MicroGraphics instance from a pixel buffer instance
Declaration
public MicroGraphics(PixelBufferBase pixelBuffer, bool initializeBuffer)
Parameters
Type | Name | Description |
---|---|---|
PixelBufferBase | pixelBuffer | The pixel buffer |
System.Boolean | initializeBuffer | Initialize the offscreen buffer if true |
MicroGraphics(IGraphicsDisplay)
Create a new MicroGraphics instance from a display perihperal driver instance
Declaration
public MicroGraphics(IGraphicsDisplay display)
Parameters
Type | Name | Description |
---|---|---|
IGraphicsDisplay | display | An IGraphicsDisplay object |
Fields
canvasState
The current canvas state
Declaration
protected MicroGraphics.CanvasState canvasState
Field Value
Type | Description |
---|---|
MicroGraphics.CanvasState |
display
Display object reponsible for managing the buffer and rendering
Declaration
protected readonly IGraphicsDisplay display
Field Value
Type | Description |
---|---|
IGraphicsDisplay |
IgnoreOutOfBoundsPixels
Ingore pixels that are outside of the pixel buffer coordinate space
Declaration
public bool IgnoreOutOfBoundsPixels
Field Value
Type | Description |
---|---|
System.Boolean |
pixelBuffer
PixelBuffer draw target
Declaration
protected IPixelBuffer pixelBuffer
Field Value
Type | Description |
---|---|
IPixelBuffer |
Properties
ColorMode
Current color mode
Declaration
public ColorMode ColorMode { get; }
Property Value
Type | Description |
---|---|
ColorMode |
CurrentFont
Font used for drawing text to the display
Declaration
public IFont CurrentFont { get; set; }
Property Value
Type | Description |
---|---|
IFont |
CursorColumn
The current cursor column relative to text/font
Declaration
public byte CursorColumn { get; }
Property Value
Type | Description |
---|---|
System.Byte |
CursorLine
The current cursor line relative to the text
Declaration
public byte CursorLine { get; }
Property Value
Type | Description |
---|---|
System.Byte |
DelayBetweenFrames
Optional enforced deplay between updates when calling ShowBuffered
Declaration
public TimeSpan DelayBetweenFrames { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
DisplayConfig
Text display configuration for use with text display menu
Declaration
public TextDisplayConfig DisplayConfig { get; }
Property Value
Type | Description |
---|---|
TextDisplayConfig |
Height
Return the height of the display after accounting for the rotation.
Declaration
public int Height { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
PenColor
Current pen color
Declaration
public Color PenColor { get; set; }
Property Value
Type | Description |
---|---|
Color |
Rotation
Current rotation used for drawing pixels to the display
Declaration
public RotationType Rotation { get; set; }
Property Value
Type | Description |
---|---|
RotationType |
Stroke
Stroke / line thickness when drawing lines or shape outlines
Declaration
public int Stroke { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Width
Return the width of the display after accounting for the rotation.
Declaration
public int Width { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
Clear(Color, Boolean)
Clear the pixel buffer to a color
Declaration
public virtual void Clear(Color color, bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
Color | color | Color to set display |
System.Boolean | updateDisplay | Update the display immediately when true |
Clear(Boolean)
Clear the pixel buffer
Declaration
public virtual void Clear(bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | updateDisplay | Update the display immediately when true |
Clear(Int32, Int32, Int32, Int32, Boolean)
Clear a region of the display pixel buffer
Declaration
public virtual void Clear(int originX, int originY, int width, int height, bool updateDisplay = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | originX | The X coord to start |
System.Int32 | originY | The Y coord to start |
System.Int32 | width | The width of the region to clear |
System.Int32 | height | The height of the region to clear |
System.Boolean | updateDisplay | Update the display immediately when true |
ClearLine(Byte)
Clear a single line of text
Declaration
public void ClearLine(byte lineNumber)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | lineNumber | The line to clear |
ClearLines()
Clear all lines of text
Declaration
public void ClearLines()
DrawArc(Int32, Int32, Int32, Angle, Angle, Color, Boolean)
Draw a circular arc between two angles
Declaration
public void DrawArc(int centerX, int centerY, int radius, Angle startAngle, Angle endAngle, Color color, bool centerBetweenPixels = true)
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 |
Angle | startAngle | The arc starting angle |
Angle | endAngle | The arc ending angle |
Color | color | The color of the circle |
System.Boolean | centerBetweenPixels | If true, the center of the arc is between the assigned pixel and the next pixel, false it's directly on the center pixel |
Remarks
Note that y axis is inverted so the arc will be flipped from the standard cartesian plain
DrawArc(Int32, Int32, Int32, Angle, Angle, Boolean)
Draw a circular arc between two angles using PenColor
Declaration
public void DrawArc(int centerX, int centerY, int radius, Angle startAngle, Angle endAngle, bool centerBetweenPixels = true)
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 |
Angle | startAngle | The arc starting angle |
Angle | endAngle | The arc ending angle |
System.Boolean | centerBetweenPixels | If true, the center of the arc is between the assigned pixel and the next pixel, false it's directly on the center pixel |
Remarks
Note that y axis is inverted so the arc will be flipped from the standard cartesian plain
DrawArc(Int32, Int32, Int32, Angle, Angle, Boolean, Boolean)
Draw a circular arc between two angles
Declaration
public void DrawArc(int centerX, int centerY, int radius, Angle startAngle, Angle endAngle, bool enabled = true, bool centerBetweenPixels = true)
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 |
Angle | startAngle | The arc starting angle |
Angle | endAngle | The arc ending angle |
System.Boolean | enabled | Should draw the arc (true) or remove (false) |
System.Boolean | centerBetweenPixels | If true, the center of the arc is between the assigned pixel and the next pixel, false it's directly on the center pixel |
Remarks
Note that y axis is inverted so the arc will be flipped from the standard cartesian plain
DrawBitmap(Int32, Int32, Int32, Int32, Byte[], Color, ScaleFactor)
Writes a 1-bit bitmap stored in a byte array
Declaration
protected void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, Color color, ScaleFactor scaleFactor = default(ScaleFactor))
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 pixels |
System.Int32 | height | Height of the bitmap in pixels |
System.Byte[] | bitmap | Bitmap to display |
Color | color | The color of the bitmap |
ScaleFactor | scaleFactor | The integer scale factor (default is 1) |
DrawBitmap(Int32, Int32, Int32, Int32, Byte[], ScaleFactor)
Writes a 1-bit bitmap to the buffer - used for font rendering
Declaration
protected void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, ScaleFactor scaleFactor = default(ScaleFactor))
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 pixels |
System.Int32 | height | Height of the bitmap in pixels |
System.Byte[] | bitmap | Bitmap to display |
ScaleFactor | scaleFactor | The integer scale factor (default is 1) |
DrawBuffer(Int32, Int32, IPixelBuffer)
Draw a buffer onto the display buffer at the given location For best performance, source buffer should be the same color depth as the target display
Declaration
public void DrawBuffer(int x, int y, IPixelBuffer buffer)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x location of target to draw buffer |
System.Int32 | y | x location of target to draw buffer |
IPixelBuffer | buffer | the source buffer to write to the display buffer |
DrawBuffer(Int32, Int32, IPixelBuffer, HorizontalAlignment, VerticalAlignment)
Draw a buffer onto the display buffer at the given location For best performance, source buffer should be the same color depth as the target display
Declaration
public void DrawBuffer(int x, int y, IPixelBuffer buffer, HorizontalAlignment alignmentH = HorizontalAlignment.Left, VerticalAlignment alignmentV = VerticalAlignment.Top)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x location of target to draw buffer |
System.Int32 | y | x location of target to draw buffer |
IPixelBuffer | buffer | the source buffer to write to the display buffer |
HorizontalAlignment | alignmentH | Horizontal alignment: Left, Center or right align the buffer to the x location |
VerticalAlignment | alignmentV | Vertical alignment: Top, Center or bottom align the buffer to the y location |
DrawCircle(Int32, Int32, Int32, Color, Boolean, Boolean)
Draw a circle
Declaration
public void DrawCircle(int centerX, int centerY, int radius, Color color, bool filled = false, bool centerBetweenPixels = 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 |
System.Boolean | centerBetweenPixels | If true, the center of the circle is between the assigned pixel and the next pixel, false it's directly on the center pixel |
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
DrawCircle(Int32, Int32, Int32, Boolean, Boolean)
Draw a circle
Declaration
public void DrawCircle(int centerX, int centerY, int radius, bool filled = false, bool centerBetweenPixels = 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 | filled | Draw a filled circle? |
System.Boolean | centerBetweenPixels | If true, the center of the circle is between the assigned pixel and the next pixel, false it's directly on the center pixel |
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
DrawCircle(Int32, Int32, Int32, Boolean, Boolean, Boolean)
Draw a circle
Declaration
public void DrawCircle(int centerX, int centerY, int radius, bool enabled, bool filled = false, bool centerBetweenPixels = 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 | enabled | Show the circle when true |
System.Boolean | filled | Draw a filled circle? |
System.Boolean | centerBetweenPixels | Set center between pixels |
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
DrawCircleQuadrant(Int32, Int32, Int32, Int32, Color, Boolean, Boolean)
Draws a circle quadrant (quarter circle)
Declaration
public void DrawCircleQuadrant(int centerX, int centerY, int radius, int quadrant, Color color, bool filled = false, bool centerBetweenPixels = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | centerX | |
System.Int32 | centerY | |
System.Int32 | radius | |
System.Int32 | quadrant | |
Color | color | |
System.Boolean | filled | |
System.Boolean | centerBetweenPixels |
DrawCircleQuadrant(Int32, Int32, Int32, Int32, Boolean, Boolean)
Draws a circle quadrant (quarter circle)
Declaration
public void DrawCircleQuadrant(int centerX, int centerY, int radius, int quadrant, bool filled = false, bool centerBetweenPixels = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | centerX | |
System.Int32 | centerY | |
System.Int32 | radius | |
System.Int32 | quadrant | |
System.Boolean | filled | |
System.Boolean | centerBetweenPixels |
DrawCircleQuadrant(Int32, Int32, Int32, Int32, Boolean, Boolean, Boolean)
Draws a circle quadrant (quarter circle)
Declaration
public void DrawCircleQuadrant(int centerX, int centerY, int radius, int quadrant, bool enabled = true, bool filled = false, bool centerBetweenPixels = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | centerX | |
System.Int32 | centerY | |
System.Int32 | radius | |
System.Int32 | quadrant | |
System.Boolean | enabled | |
System.Boolean | filled | |
System.Boolean | centerBetweenPixels |
DrawHorizontalLine(Int32, Int32, Int32)
Draw a horizontal line
Declaration
public void DrawHorizontalLine(int x, int y, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the starting point of the line |
System.Int32 | y | Ordinate of the starting point of the line |
System.Int32 | length | Length of the line to draw |
DrawHorizontalLine(Int32, Int32, Int32, Color)
Draw a horizontal line
Declaration
public void DrawHorizontalLine(int x, int y, int length, Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the starting point of the line |
System.Int32 | y | Ordinate of the starting point of the line |
System.Int32 | length | Length of the line to draw |
Color | color | The color of the line |
DrawHorizontalLine(Int32, Int32, Int32, Boolean)
Draw a horizontal line.
Declaration
public void DrawHorizontalLine(int x, int y, int length, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the starting point of the line |
System.Int32 | y | Ordinate of the starting point of the line |
System.Int32 | length | Length of the line to draw |
System.Boolean | enabled | Turn the pixel on (true) or off (false) |
DrawImage(Image)
Draw an Image onto the display buffer at (0, 0)
Declaration
public void DrawImage(Image image)
Parameters
Type | Name | Description |
---|---|---|
Image | image | the source image to write to the display buffer |
DrawImage(Int32, Int32, Image)
Draw an Image onto the display buffer at the specified location
Declaration
public void DrawImage(int x, int y, Image image)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x location of target to draw buffer |
System.Int32 | y | x location of target to draw buffer |
Image | image | the source image to write to the display buffer |
DrawImage(Int32, Int32, Image, HorizontalAlignment, VerticalAlignment)
Draw an Image onto the display buffer at the specified location
Declaration
public void DrawImage(int x, int y, Image image, HorizontalAlignment alignmentH = HorizontalAlignment.Left, VerticalAlignment alignmentV = VerticalAlignment.Top)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x location of target to draw buffer |
System.Int32 | y | x location of target to draw buffer |
Image | image | the source image to write to the display buffer |
HorizontalAlignment | alignmentH | Horizontal alignment: Left, Center or right align the image to the x location |
VerticalAlignment | alignmentV | Vertical alignment: Top, Center or bottom align the image to the y location |
DrawLine(Int32, Int32, Int32, Int32)
Draw a line using Bresenhams line drawing algorithm
Declaration
public void DrawLine(int x0, int y0, int x1, int y1)
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 |
Remarks
Bresenhams line drawing algoritm: https://en.wikipedia.org/wiki/Bresenham's_line_algorithm C# Implementation: https://en.wikipedia.org/wiki/Bresenham's_line_algorithm
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 | Color of the line to be drawn |
Remarks
Bresenhams line drawing algoritm: https://en.wikipedia.org/wiki/Bresenham's_line_algorithm C# Implementation: https://en.wikipedia.org/wiki/Bresenham's_line_algorithm
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 enabled)
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 | enabled | Turn the pixel on (true) or off (false) |
DrawLine(Int32, Int32, Int32, Single, Color)
Draw a line from a point to a position defined by a radius and an angle
Declaration
public void DrawLine(int x, int y, int length, float angle, Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | |
System.Int32 | y | Ordinate of the starting point of the line |
System.Int32 | length | length of line |
System.Single | angle | angle to draw line in radians |
Color | color | The color of the line |
DrawLine(Int32, Int32, Int32, Single, Boolean)
Draw a line using polar coordinates
Declaration
public void DrawLine(int x, int y, int length, float angle, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the starting point of the line |
System.Int32 | y | Ordinate of the starting point of the line |
System.Int32 | length | Length of line |
System.Single | angle | Angle in radians |
System.Boolean | enabled | Turn the pixel on (true) or off (false) |
DrawPath(GraphicsPath)
Draw a graphics path
Declaration
public void DrawPath(GraphicsPath path)
Parameters
Type | Name | Description |
---|---|---|
GraphicsPath | path | The path |
DrawPath(GraphicsPath, Color)
Draw a graphics path
Declaration
public void DrawPath(GraphicsPath path, Color color)
Parameters
Type | Name | Description |
---|---|---|
GraphicsPath | path | The path |
Color | color | The color to draw the path |
DrawPath(GraphicsPath, Boolean)
Draw a graphics path
Declaration
public void DrawPath(GraphicsPath path, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
GraphicsPath | path | The path |
System.Boolean | enabled | Should pixels be enabled (on) or disabled (off) |
DrawPixel(Int32)
Draw a single pixel using the pen color
Declaration
public virtual void DrawPixel(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | pixel location in buffer |
DrawPixel(Int32, Int32)
Draw a single pixel
Declaration
public virtual void DrawPixel(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x location |
System.Int32 | y | y location |
DrawPixel(Int32, Int32, Color)
Draw a single pixel using the pen color
Declaration
public virtual 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 |
DrawPixel(Int32, Int32, Boolean)
Draw a single pixel
Declaration
public void DrawPixel(int x, int y, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x location |
System.Int32 | y | y location |
System.Boolean | enabled | Turn the pixel on (true) or off (false) |
DrawRectangle(Int32, Int32, Int32, Int32, Color, Boolean)
Draw a rectangle
Declaration
public void DrawRectangle(int x, int y, int width, int height, Color color, bool filled = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the top left corner |
System.Int32 | y | 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) |
DrawRectangle(Int32, Int32, Int32, Int32, Boolean)
Draw a rectangle
Declaration
public void DrawRectangle(int x, int y, int width, int height, bool filled = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the top left corner |
System.Int32 | y | Ordinate of the top left corner |
System.Int32 | width | Width of the rectangle |
System.Int32 | height | Height of the rectangle |
System.Boolean | filled | Fill the rectangle (true) or draw the outline (false, default) |
DrawRectangle(Int32, Int32, Int32, Int32, Boolean, Boolean)
Draw a rectangle
Declaration
public void DrawRectangle(int x, int y, int width, int height, bool enabled, bool filled = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the top left corner |
System.Int32 | y | Ordinate of the top left corner |
System.Int32 | width | Width of the rectangle |
System.Int32 | height | Height of the rectangle |
System.Boolean | enabled | Turn pixels on (true) or turn pixels off (false) |
System.Boolean | filled | Fill the rectangle (true) or draw the outline (false, default) |
DrawRoundedRectangle(Int32, Int32, Int32, Int32, Int32, Color, Boolean)
Draw a rounded rectangle
Declaration
public void DrawRoundedRectangle(int x, int y, int width, int height, int cornerRadius, Color color, bool filled = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the top left corner |
System.Int32 | y | Ordinate of the top left corner |
System.Int32 | width | Width of the rectangle |
System.Int32 | height | Height of the rectangle |
System.Int32 | cornerRadius | Radius of the corners of the rectangle |
Color | color | The color of the rectangle |
System.Boolean | filled | Fill the rectangle (true) or draw the outline (false, default) |
DrawRoundedRectangle(Int32, Int32, Int32, Int32, Int32, Boolean)
Draw a rounded rectangle
Declaration
public void DrawRoundedRectangle(int x, int y, int width, int height, int cornerRadius, bool filled = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the top left corner |
System.Int32 | y | Ordinate of the top left corner |
System.Int32 | width | Width of the rectangle |
System.Int32 | height | Height of the rectangle |
System.Int32 | cornerRadius | Radius of the corners of the rectangle |
System.Boolean | filled | Fill the rectangle (true) or draw the outline (false, default) |
DrawRoundedRectangle(Int32, Int32, Int32, Int32, Int32, Boolean, Boolean)
Draw a rounded rectangle
Declaration
public void DrawRoundedRectangle(int x, int y, int width, int height, int cornerRadius, bool enabled, bool filled = false)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the top left corner |
System.Int32 | y | Ordinate of the top left corner |
System.Int32 | width | Width of the rectangle |
System.Int32 | height | Height of the rectangle |
System.Int32 | cornerRadius | Radius of the corners of the rectangle |
System.Boolean | enabled | Turn pixels on (true) or turn pixels off (false) |
System.Boolean | filled | Fill the rectangle (true) or draw the outline (false, default) |
DrawText(Int32, Int32, String, Color, ScaleFactor, HorizontalAlignment, VerticalAlignment, IFont)
Draw a text message on the display using the current font.
Declaration
public void DrawText(int x, int y, string text, Color color, ScaleFactor scaleFactor = default(ScaleFactor), HorizontalAlignment alignmentH = HorizontalAlignment.Left, VerticalAlignment alignmentV = VerticalAlignment.Top, IFont font = null)
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 |
ScaleFactor | scaleFactor | Scalefactor used to calculate the size |
HorizontalAlignment | alignmentH | Horizontal alignment: Left, Center or right aligned text |
VerticalAlignment | alignmentV | Vertical alignment: Top, Center or bottom aligned text |
IFont | font | Optional font used to draw the text |
DrawText(Int32, Int32, String, ScaleFactor, HorizontalAlignment, VerticalAlignment)
Draw a text message on the display using the current font
Declaration
public void DrawText(int x, int y, string text, ScaleFactor scaleFactor = default(ScaleFactor), HorizontalAlignment alignmentH = HorizontalAlignment.Left, VerticalAlignment alignmentV = VerticalAlignment.Top)
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 |
ScaleFactor | scaleFactor | Scalefactor used to calculate the size |
HorizontalAlignment | alignmentH | Horizontal alignment: Left, Center or right aligned text |
VerticalAlignment | alignmentV | Vertical alignment: Top, Center or bottom aligned text |
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? |
DrawTriangle(Int32, Int32, Int32, Int32, Int32, Int32, Boolean)
Draw a triangle
Declaration
public void DrawTriangle(int x0, int y0, int x1, int y1, int x2, int y2, 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 | filled | Draw a filled triangle? |
Remarks
Draw triangle method for 1 bit displays
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 enabled = true, 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 | enabled | Should the triangle add (true) or remove (false) |
System.Boolean | filled | Draw a filled triangle? |
Remarks
Draw triangle method for 1 bit displays
DrawVerticalLine(Int32, Int32, Int32)
Draw a vertical line
Declaration
public void DrawVerticalLine(int x, int y, int length)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the starting point of the line |
System.Int32 | y | Ordinate of the starting point of the line |
System.Int32 | length | Length of the line to draw |
DrawVerticalLine(Int32, Int32, Int32, Color)
Draw a vertical line
Declaration
public void DrawVerticalLine(int x, int y, int length, Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the starting point of the line |
System.Int32 | y | Ordinate of the starting point of the line |
System.Int32 | length | Length of the line to draw |
Color | color | The color of the line |
DrawVerticalLine(Int32, Int32, Int32, Boolean)
Draw a vertical line.
Declaration
public void DrawVerticalLine(int x, int y, int length, bool enabled)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | Abscissa of the starting point of the line |
System.Int32 | y | Ordinate of the starting point of the line |
System.Int32 | length | Length of the line to draw |
System.Boolean | enabled | Show the line when (true) or off (false) |
GetXForRotation(Int32, Int32)
Get x pixel position for the current graphics rotation
Declaration
public int GetXForRotation(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The non-rotated x position |
System.Int32 | y | The non-rotated y position |
Returns
Type | Description |
---|---|
System.Int32 |
GetYForRotation(Int32, Int32)
Get y pixel position for the current graphics rotation
Declaration
public int GetYForRotation(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | The non-rotated x position |
System.Int32 | y | The non-rotated y position |
Returns
Type | Description |
---|---|
System.Int32 |
InvertPixel(Int32, Int32)
Invert the color of the pixel at the given location
Declaration
public void InvertPixel(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x location |
System.Int32 | y | y location |
InvertRectangle(Int32, Int32, Int32, Int32)
Invert all pixels within a rectangle
Declaration
public virtual void InvertRectangle(int x, int y, int width, int height)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | x start |
System.Int32 | y | y start |
System.Int32 | width | width of area to invert |
System.Int32 | height | height of area to invert |
MeasureText(String, IFont, ScaleFactor)
Get the size in pixels of a string for a given font and scale factor
Declaration
public Size MeasureText(string text, IFont font, ScaleFactor scaleFactor = default(ScaleFactor))
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The string to measure |
IFont | font | The font used to calculate the text size |
ScaleFactor | scaleFactor | Scalefactor used to calculate the size |
Returns
Type | Description |
---|---|
Size |
MeasureText(String, ScaleFactor)
Get the size in pixels of a string using the current font
Declaration
public Size MeasureText(string text, ScaleFactor scaleFactor = default(ScaleFactor))
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The string to measure |
ScaleFactor | scaleFactor | Scalefactor used to calculate the size |
Returns
Type | Description |
---|---|
Size |
RestoreState()
Restore saved state variables and apply them to the MicroGraphics instance Includes: CurrentFont, Stroke, and Rotation
Declaration
public void RestoreState()
SaveState()
Save any state variables Includes: CurrentFont, Stroke, and Rotation
Declaration
public void SaveState()
SetCursorPosition(Byte, Byte)
Set the cursor position relative to the text
Declaration
public void SetCursorPosition(byte column, byte line)
Parameters
Type | Name | Description |
---|---|---|
System.Byte | column | The text column |
System.Byte | line | The line column |
Show()
Update the display target from the buffer (thread safe)
Declaration
public virtual void Show()
Show(Rect)
Update a region of the display Note: not all displays support partial updates
Declaration
public virtual void Show(Rect rect)
Parameters
Type | Name | Description |
---|---|---|
Rect | rect |
Show(Int32, Int32, Int32, Int32)
Update a region of the display Note: not all displays support partial updates
Declaration
public virtual void Show(int left, int top, int right, int bottom)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | left | |
System.Int32 | top | |
System.Int32 | right | |
System.Int32 | bottom |
ShowBuffered()
Update the display target from the buffer (thread safe) while respecting MinimumTimeBetweenUpdates
Declaration
public virtual Task ShowBuffered()
Returns
Type | Description |
---|---|
Task |
ShowUnsafe()
Update the display target from the buffer (not thread safe)
Declaration
public virtual void ShowUnsafe()
ShowUnsafe(Int32, Int32, Int32, Int32)
Update a region of the display Note: not all displays support partial updates
Declaration
public virtual void ShowUnsafe(int left, int top, int right, int bottom)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | left | |
System.Int32 | top | |
System.Int32 | right | |
System.Int32 | bottom |
Write(String)
Write text to the display
Declaration
public void Write(string text)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text |
WriteLine(String, Byte, Boolean)
Write a line of text
Declaration
public void WriteLine(string text, byte lineNumber, bool showCursor = false)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | The text |
System.Byte | lineNumber | The line to write |
System.Boolean | showCursor | True to show the cursor |