Support

If you have a problem or need to report a bug please email : support@dsprobotics.com

There are 3 sections to this support area:

DOWNLOADS: access to product manuals, support files and drivers

HELP & INFORMATION: tutorials and example files for learning or finding pre-made modules for your projects

USER FORUMS: meet with other users and exchange ideas, you can also get help and assistance here

NEW REGISTRATIONS - please contact us if you wish to register on the forum

how to make fit...

For general discussion related FlowStone

how to make fit...

Postby tester » Sat Jan 26, 2013 5:17 pm

How to make that vector triangle fit the whole square/rectangle? (non-ruby)
Attachments
triangle.fsm
(1.02 KiB) Downloaded 863 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: how to make fit...

Postby trogluddite » Sun Jan 27, 2013 1:23 pm

The triangle in the example is drawn by using a single very thick line that is angled at 45deg. This effectively gives you a rectangle (line length * line width) rotated to 45deg. The triangle is then one corner of this rectangle clipped off by the view area - which mean that the angle at the lower point has to be 90deg.
To change the height of the triangle would require that angle to be different, and so it cannot be done using this method.

Three possible solutions...

1) Masking
For this technique you would have to have a GUI with a definite background colour - and then use other rotated rectangles (i.e. wide lines) drawn in the background colour to 'paint out' areas of pixels that are not part of the shape. But this will lead to some fiendishly complex maths - the required geometry would change, for example, as the triangle's apex changed from an acute to obtuse angle.

2) Fill your own shape.
Using geometry and draw loops, you would 'scan' the shape, using the equations of it's geometry to define lines of pixels that needed filling, building up the shape a row at a time. For this shape, a simple 'fan' might be easiest - scan along the top edge one pixel at a time, drawing a line from there to the triangle's apex.
A search for 'polygons' on the SM site should find you a few good examples - I remember there being a few threads about creating filled shapes.

3) Use Ruby to just draw the outline and let GDI+ do all the hard work.
I know, you said a 'non-Ruby' solution, but for non-trivial shapes, the old 'green/yellow' vector primitives are, well, just a bit too 'primitive' - there is no way to define 'fillable' outlines with them other than the default rectangle and ellipse shapes (and the "thick lines" method for rotated rectangles). OTOH with Ruby you can easily fill very complex outlines, including those with combinations of straight and curved edges - this is one area where Ruby really does have a huge advantage over the old methods.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
trogluddite
 
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: how to make fit...

Postby tester » Sun Jan 27, 2013 1:49 pm

Thanks for explaining.
Meanwhile I just resigned somewhat from triangular pointers - the simplest way :-)

Right now I'm avoiding ruby for a moment. My lack of knowledge/experience on that, this "roaming folder" thing and uncertainty to the performance of ruby-driven modules - makes me to wait with that.
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
 
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet


Return to General

Who is online

Users browsing this forum: No registered users and 39 guests