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

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] defaultGridStep without a view

For general discussion related FlowStone

[Ruby] defaultGridStep without a view

Postby tulamide » Thu Mar 24, 2016 3:03 pm

Sometimes the simplest things turn out to be the most complicated. For a conversion pixel => grid I need to access defaultGridStep from within a mouse state method. There is no view accessible, but the defaultGridStep method is an instance method of a view.

How do you solve such an issue? I'm not running out of ideas (I store the value in a variable from within the draw method), but I would hope to find the most elegant way to deal with it. For some reason it doesn't feel right to use resources by calling that rather constant value (the default grid step won't change at all in an exported plugin, and only rarely while editing in Flowstone) x times per second in the draw routine, just to be able to use it in another method.

So I hope there's something I didn't see, that enables me to call this exactly once when needed, without misusing the draw method.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: [Ruby] defaultGridStep without a view

Postby TheOm » Thu Mar 24, 2016 3:33 pm

You can use the Grid to Pixel or the Pixel to Grid primitive, feed it with a 1 and connect it to an input.
But out of interest, why do you need this value in a mouse method?
TheOm
 
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: [Ruby] defaultGridStep without a view

Postby tulamide » Thu Mar 24, 2016 3:49 pm

TheOm wrote:You can use the Grid to Pixel or the Pixel to Grid primitive, feed it with a 1 and connect it to an input.
But out of interest, why do you need this value in a mouse method?

Thank you. I hoped for a Ruby-only solution, but this is ok as well.

The script's database is pixel-based, since all elements shall have specific pixel values. Those database values may change during development, which makes it neccessary to convert on-the-fly.
"There lies the dog buried" (German saying translated literally)
tulamide
 
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany


Return to General

Who is online

Users browsing this forum: No registered users and 68 guests

cron