Ruby Expansion: Spline Class
Posted: Tue Oct 21, 2014 1:40 am
It is not without pride that I announce the release of my first
Ruby For Flowstone Expansion: Spline Class
The idea came up when I saw Nubeat7's Array Class Methods Expansion on Flowstone Guru. I instantly thought that the same principle should also work for expanding the Ruby Edit Class (which basically is the editor you're using in a schematic). Some tests later I could start the development. Several weeks of hard work later, the result is the Spline Class Expansion module. And to honor Nubeat7, I adapted his idea of a ruby-red module design to indicate the relation to ruby.
This is not just some additional methods, it is a whole library, enabling you to make use of splines in your projects. Furthermore I tried to keep it as simple as possible for you, so that even without much knowledge of Ruby you should be able to draw a spline within a minute.
You're adding the Spline Class to your schematic, setup a view and connect it with a ruby editor. Now with only 5 orders you will create a spline. That's the basics.
Of course, the Spline Class offers a lot more. It is much more suitable to be used than Ruby's curve drawing methods. Here are just a few highlights:
The Spline class also comes with a toolbox that you can use even without using splines. The toolbox offers methods for distance, angle and interpolation calculation and more.
A word on 'Numeric'. Often times you can get or set values declared as Numerics. In Ruby, unlike other languages, everything is an object (aka class). Really everything. Even numbers are classes. This makes it possible to do something like this:
Or this:
Cool thing, but it also has an issue. 5 and 5.0 are not the same. They are two different objects. The former is a fixnum, which is a subclass of the integer class, the latter is a float class. And this is why that can get ugly:
Us humans just go 5+2 = 7 / 2 = 3.5, but Ruby has no other information than integer, because all of the classes used in the equation are integers. That's why the result will be the integer number 3. That's just an easy example, of course.
To help you not to get into trouble, I implemented on-the-fly conversions, so that you should be able to mix both, integer and float, in any way you like. The mother class of both is 'Numeric', so that's what is meant, when you read that term. However, if you at some point don't get what you expect, test for this possible issue. And if it is related to conversion issues, please notify me and give me a simple code that generates the issue. Thank you!
By all means, do take your time to read the manual. It's a pdf with a brief introduction and specifications, and a complete reference. All of that with example code and illustrations. (Bookmarks unfortunately messed up. Better scroll through the document)
And last but not least: Please, don't just download it. Leave a thank you or any other comment. It's always so discouraging seeing 80 downloads but no comments...
Ruby For Flowstone Expansion: Spline Class
The idea came up when I saw Nubeat7's Array Class Methods Expansion on Flowstone Guru. I instantly thought that the same principle should also work for expanding the Ruby Edit Class (which basically is the editor you're using in a schematic). Some tests later I could start the development. Several weeks of hard work later, the result is the Spline Class Expansion module. And to honor Nubeat7, I adapted his idea of a ruby-red module design to indicate the relation to ruby.
This is not just some additional methods, it is a whole library, enabling you to make use of splines in your projects. Furthermore I tried to keep it as simple as possible for you, so that even without much knowledge of Ruby you should be able to draw a spline within a minute.
You're adding the Spline Class to your schematic, setup a view and connect it with a ruby editor. Now with only 5 orders you will create a spline. That's the basics.
Of course, the Spline Class offers a lot more. It is much more suitable to be used than Ruby's curve drawing methods. Here are just a few highlights:
- • A whole framework for creating, changing and accessing splines
• Visible nodes and control points (on/off switchable)
• Easy integration with simple methods
• At any time you can use the 'send' method of a spline to get an array of values
- - Those are freely adaptable to your project
- Resolution independent output
- Just tell it to send 256 values, and you will get 256 values, no matter the resolution of the spline
- Automatic (re-)mapping of the values. Just tell it a range of numbers to map to
• Dynamic per-segment-resolution of interpolation points while drawing; automated
• Different coloring of the spline, its nodes and control points possible, supports alpha channel
• Each spline can be drawn within its own 'virtualgrid'. This way it is a breeze to draw several splines in the same view, with each spline independantly controllable
• Supports point-in-node detection, which enables you to use mouse control
The Spline class also comes with a toolbox that you can use even without using splines. The toolbox offers methods for distance, angle and interpolation calculation and more.
A word on 'Numeric'. Often times you can get or set values declared as Numerics. In Ruby, unlike other languages, everything is an object (aka class). Really everything. Even numbers are classes. This makes it possible to do something like this:
Code: Select all
5.odd?
# returns true if the object 5 is an odd numberOr this:
Code: Select all
5.next
# returns 6Cool thing, but it also has an issue. 5 and 5.0 are not the same. They are two different objects. The former is a fixnum, which is a subclass of the integer class, the latter is a float class. And this is why that can get ugly:
Code: Select all
(5 + 2) / 2Us humans just go 5+2 = 7 / 2 = 3.5, but Ruby has no other information than integer, because all of the classes used in the equation are integers. That's why the result will be the integer number 3. That's just an easy example, of course.
To help you not to get into trouble, I implemented on-the-fly conversions, so that you should be able to mix both, integer and float, in any way you like. The mother class of both is 'Numeric', so that's what is meant, when you read that term. However, if you at some point don't get what you expect, test for this possible issue. And if it is related to conversion issues, please notify me and give me a simple code that generates the issue. Thank you!
By all means, do take your time to read the manual. It's a pdf with a brief introduction and specifications, and a complete reference. All of that with example code and illustrations. (Bookmarks unfortunately messed up. Better scroll through the document)
And last but not least: Please, don't just download it. Leave a thank you or any other comment. It's always so discouraging seeing 80 downloads but no comments...