Mike
October 14, 2011, 11:39pm
1
I noticed something interesting tonight; there is not method for drawing a line in the Gadgeteer Library.
There is support for drawing an image, ellipse, rectangle and text, but there is not one for drawing a line.
A line could be drawn pixel by pixel, but I don’t think this was the intent.
Is it MS’s intent that any serious graphics work would be done on a BItmap and the drawn on the display object? Or is this an oversight?
hhoover
October 14, 2011, 11:44pm
2
Surely, implementing Bresenham’s algorithm isn’t such a big deal?
The implementation does seem rather minimal - but perhaps that’s just a mark of how young Gadgeteer still is?
It would be nice to have more functionality somewhere in the codebase - does Glide have anything for vector drawing? Any other libs?
Mike
October 14, 2011, 11:54pm
3
The Bitmap class has lots of drawing capability.
Might be an infancy issue, but seems to too elementary to be a future feature.
I can expose it though reflection if you need my help.
Mike
October 15, 2011, 12:13am
5
Thanks Valen… There are several ways of getting to the internal Bitmap. For now, I will just use another Bitmap and rendered it to the display object.
Could you draw a really flat rectangle?
Mike
October 15, 2011, 3:26pm
7
For those interested, the following code will allow you to get a reference to the internal bitmap of the display object.
Type type = typeof(GTM.Module.DisplayModule.SimpleGraphicsInterface);
Bitmap bm = (Bitmap)type.GetField("_display", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(display.SimpleGraphics);
You will need to add the following to the beginning of your code:
using System.Reflection;
Thanks Mike
Think this shouldn’t be private on future releases. We’ll see
Mike
October 15, 2011, 3:28pm
9
What is a flat rectangle?
A rectangle where two of the four corners are the same as the other two. (Doesn’t work if rectangles are only allowed to be orthogonal to the image frame.(