Graphics in the Gadgeteer Library

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?

Surely, implementing Bresenham’s algorithm isn’t such a big deal? :stuck_out_tongue:

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?

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.

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?

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

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.(