Filled triangle

What’s the easiest way to draw filled triangle?..An Image gif is not so good, since the size & direction may vary. Using a cobra board & LCD.

Why double post?

http://www.tinyclr.com/forum/1/5136/#/1/msg48715

I checked out that PDF in the original response … and it made no sense to me :frowning: I read it and re-read it, and it was still difficult for me. :-[

Perhaps the Hoyt felt the same way … ?

Multiple threads with the same question are confusing. I don’t think there is an easy way of doing this. Otherwise we would’ve had it already. ;D

Look for Graphics Gems books. These books cover a lot of algorithms.

Look at DrawingContext.DrawPolygon.

So there is no way to generate a simple shape (red triangle)? What kind of graphics support is that?
I was not looking to invent an algorithm, just use the tools provided.

I am sorry, I have misled you. Of course you can use DrawPolygon (as rocketbob indicated above) for that.


Bitmap _LCD = new Bitmap(SystemMetrics.ScreenWidth, SystemMetrics.ScreenHeight);
Brush brush = new SolidColorBrush(Colors.Blue);
Pen pen = new Pen(Colors.White);
 int[] triangle = new int[] { 0, SystemMetrics.ScreenHeight / 2, SystemMetrics.ScreenWidth-1, 0, SystemMetrics.ScreenWidth-1, SystemMetrics.ScreenHeight-1 };

...
//Draw a filled triangle
DrawingContext context = new DrawingContext(_LCD);
context.DrawPolygon(brush, pen, triangle);
...

I didn’t know this exists in NETMF. Learned something new today :slight_smile:

Yeah, that class has eluded me too.

By the way if anybody’s interested the triangle example above is used with Gus’ scope class from:

http://code.tinyclr.com/project/395/a-scope-like-display/