[Ruby] defaultGridStep without a view
Posted: 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.
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.