[Ruby] defaultGridStep without a view

For general discussion related FlowStone
Post Reply
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

[Ruby] defaultGridStep without a view

Post by tulamide »

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)
TheOm
Posts: 103
Joined: Tue Jan 28, 2014 7:35 pm
Location: Germany

Re: [Ruby] defaultGridStep without a view

Post by TheOm »

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?
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: [Ruby] defaultGridStep without a view

Post by tulamide »

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)
Post Reply