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
Users are reminded of the forum rules they sign up to which prohibits any activity that violates any laws including posting material covered by copyright
Ruby: How to shift GraphicsPath?
4 posts
• Page 1 of 1
Ruby: How to shift GraphicsPath?
Let's say I have a GraphicsPath and I what to shift it or perhaps rotate it. Is there a method to do do it?
So far only way I can think of is to create new Path with all the elements shifted, which is not very convenient (especially if the elements are added at various places in code).
So far only way I can think of is to create new Path with all the elements shifted, which is not very convenient (especially if the elements are added at various places in code).
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Ruby: How to shift GraphicsPath?
yes, if the different path elements are not directly related, like for a hanging cable, it will be pretty inconvenient to change each element by itself - i don't think that there is another way..
maybe its easier to create a bitmap from the view and resize, place or rotate the image
maybe its easier to create a bitmap from the view and resize, place or rotate the image
-
Nubeat7 - Posts: 1347
- Joined: Sat Apr 14, 2012 9:59 am
- Location: Vienna
Re: Ruby: How to shift GraphicsPath?
Yeah,... I've found something:
https://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.graphicspath.transform(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
Dunno if it's usable in Flowstone's Ruby.
Making a bitmap is not always a solution. For example the color may not be decided at the moment when shifting is needed.
Also I often use GraphicsPaths to define mouse interaction areas for "isInMousePoint" method, when more complicated shapes are used. That's also the case - I need to shift it, because the module gui should be scrollable. I know there are several alternatives, but I'm specifically asking if this solution is possible.
https://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.graphicspath.transform(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
Dunno if it's usable in Flowstone's Ruby.
Making a bitmap is not always a solution. For example the color may not be decided at the moment when shifting is needed.
Also I often use GraphicsPaths to define mouse interaction areas for "isInMousePoint" method, when more complicated shapes are used. That's also the case - I need to shift it, because the module gui should be scrollable. I know there are several alternatives, but I'm specifically asking if this solution is possible.
- KG_is_back
- Posts: 1196
- Joined: Tue Oct 22, 2013 5:43 pm
- Location: Slovakia
Re: Ruby: How to shift GraphicsPath?
KG_is_back wrote:Yeah,... I've found something:
https://msdn.microsoft.com/en-us/library/system.drawing.drawing2d.graphicspath.transform(v=vs.110).aspx?cs-save-lang=1&cs-lang=cpp#code-snippet-1
Dunno if it's usable in Flowstone's Ruby.
Making a bitmap is not always a solution. For example the color may not be decided at the moment when shifting is needed.
Also I often use GraphicsPaths to define mouse interaction areas for "isInMousePoint" method, when more complicated shapes are used. That's also the case - I need to shift it, because the module gui should be scrollable. I know there are several alternatives, but I'm specifically asking if this solution is possible.
No, a transform matrix is not supported from the GraphicsPath class. However you might want to take a look at my spline class. I make use of graphic paths a lot there. The way I worked was to use my own transform matrix by normalizing each single part of the path. That means, instead of directly making a draw call like a rectangle with [10, 10, 20, 20], I calculate the ratio of the rect (1:1) and translate it to a coordinate system, where -1 means most left, most top and +1 one most right, most bottom, with 0 being the center of the object. A class keeps those values [-1, -1, 1, 1], and calculates the final gridstep values only in the draw method by calling a class method with the final dimensions: center 20,20 and size 20, 20 (All values just simplified examples)
It's not much work for the drawing method to do. Tests with the spline class let me draw thousands of graphic path elements reacting in realtime to audio input.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 51 guests