The. Net Micro Framework Official graphics library is WPF, because the current St CORTEX-M3 Development Board RAM is too small, the largest 512K (commonly 128K or 256k), and CORTEX-M3 CPU frequency is not too high, Running the WPF graphics frame is too heavy, so here I have a lightweight graphics library Tinygui (in addition, I also launched a WinForm framework that is compatible with the. Net framework and suitable for users who like WinForm development, but this is not lightweight, see the Open source System.Windows.Forms Library, let. Net Micro Framework Interface Development and PC as simple ").
Tinygui related Introduction, in my early blog has introduced, so do not know what Tinygui readers, you can first look at this article "play turn. Net mf–06" for CORTEX-M3 to build lightweight Tinygui (upper).
The Tinygui interface is very simple, and the relevant declarations are as follows:
public sealed class Graphics
{
public Graphics ();
public static void Clear (uint color);
public static void DrawEllipse (int x, int y, int width, int height, uint color);
public static void DrawImage (int x, int y, byte[] bytdata);
public static void Drawimageex (int x, int y, byte[] bytdata, uint maskcolor);
public static void DrawLine (int x1, int y1, int x2, int y2, uint color);
public static void DrawRectangle (int x, int y, int width, int height, uint color);
public static void drawstring (int x, int y, string s, uint color);
public static void FillEllipse (int x, int y, int width, int height, uint color);
public static void FillRectangle (int x, int y, int width, int height, uint color);
public static UINT GetPixel (int x, int y);
public static void Print (String str);
public static void SetPixel (int x, int y, uint color);
}
Examples of related drawings are as follows (this is the source code I used to provide the graphics sample PE file)
public static void Main ()
{
uint[] colors = new Uint[]{color.black, Color.red,color.green, Color.orange,color.yellow, Color.brown,color.purple, Color.gray,
Color.darkgray, Color.lightgray,color.blue, Color.magenta,color.cyan, color.white,color.lightgreen};
Graphics.clear (Color.Blue);
int x, y, width, height,c;
Long index = 0;
Random rnd = new Random ();
while (true)
{
x = rnd. Next (239);
width = rnd. Next (239-x);
y = rnd. Next (319);
Height = rnd. Next (319-Y);
c = rnd. Next (colors. LENGTH-1);
Switch (index% 3)
{
Case 0:
if (Rnd. Next (> 5)
Graphics.drawrectangle (x, y, width, height, colors[c]);
Else
Graphics.FillRectangle (x, y, width, height, colors[c]);
Break
Case 1:
if (Rnd. Next (> 5)
Graphics.drawellipse (x, y, width, height, colors[c]);
Else
Graphics.FillEllipse (x, y, width, height, colors[c]);
Break
Case 2:
Graphics.drawline (x, Y, rnd). Next (239), Rnd. Next (319), colors[c]);
Break
}
Graphics.FillRectangle (0, 239, color.white);
Graphics.DrawString (2, 303, (index++). ToString (), color.blue);
Thread.Sleep (50);
}
}