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 Expansion: Spline Class
11 posts
• Page 1 of 2 • 1, 2
Ruby Expansion: Spline Class
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 number
Or this:
- Code: Select all
5.next
# returns 6
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:
- Code: Select all
(5 + 2) / 2
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...
- Attachments
-
- spline.rar
- Contains the Spline Class, two example schematics and the manual as pdf.
- (1001.09 KiB) Downloaded 1315 times
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Expansion: Spline Class
Just took a quick look at this ...
Not sure when/where I'd use it, once I get an understanding ... but
This is really cool and looks great.
Nice work ... and thanks for sharing
Not sure when/where I'd use it, once I get an understanding ... but
This is really cool and looks great.
Nice work ... and thanks for sharing
- RJHollins
- Posts: 1571
- Joined: Thu Mar 08, 2012 7:58 pm
Re: Ruby Expansion: Spline Class
Thanks for sharing, looks like a lot of effort went into this.
Took me a while to find the Spline class, it is well hidden
This is a great example for learning about splines and also a good example for well written Ruby code
I can grant you access to upload to Flowstone guru if you want a nice permanent home for it? Just sign up to the site using your forum name and I will add you to uploaders.
Or if you don't want to bother with that I will link to this through the special forumfiles account.
Took me a while to find the Spline class, it is well hidden
This is a great example for learning about splines and also a good example for well written Ruby code
I can grant you access to upload to Flowstone guru if you want a nice permanent home for it? Just sign up to the site using your forum name and I will add you to uploaders.
Or if you don't want to bother with that I will link to this through the special forumfiles account.
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: Ruby Expansion: Spline Class
This is beautiful, tulamide! Impressive work!
-
martinvicanek - Posts: 1328
- Joined: Sat Jun 22, 2013 8:28 pm
Re: Ruby Expansion: Spline Class
Thanks guys, it's very much appreciated!
I would love to, thank you. Will sign up right nowExo wrote:I can grant you access to upload to Flowstone guru if you want a nice permanent home for it? Just sign up to the site using your forum name and I will add you to uploaders.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Expansion: Spline Class
@tulamide done
You add your files on the download page, you should see a button called "Manage my downloads" everything is in there
Please make sure you have read the Upload Guidelines , welcome aboard
You add your files on the download page, you should see a button called "Manage my downloads" everything is in there
Please make sure you have read the Upload Guidelines , welcome aboard
- Exo
- Posts: 426
- Joined: Wed Aug 04, 2010 8:58 pm
- Location: UK
Re: Ruby Expansion: Spline Class
Heya,
I will look at this soon man-
seems to be a little genius involved.
If u r scrabbling for applications(I think it was asked),
I can think of 3--
envelopes, LFOs and oscillators.
If you want to do battle, tulamide(ty!),
I would love different spline shapes like triangle and square
muchly appreciated bro
I will look at this soon man-
seems to be a little genius involved.
If u r scrabbling for applications(I think it was asked),
I can think of 3--
envelopes, LFOs and oscillators.
If you want to do battle, tulamide(ty!),
I would love different spline shapes like triangle and square
muchly appreciated bro
-
nix - Posts: 817
- Joined: Tue Jul 13, 2010 10:51 am
Re: Ruby Expansion: Spline Class
Nubeat7 wrote:great Tulamide, thank you
You're welcome. And thank you so much for pointing me to the right direction with the 'heavy processing' issue!
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
Re: Ruby Expansion: Spline Class
From now on, the Spline Class will be maintained on Flowstone Guru. I will notify if a new version is up there.
Also, I stumbled upon an issue with Ruby. I will create an extra topic for that. But regarding the spline class: If you exit Flowstone, then start it fresh and open the example 2, you will be presented with an empty spline display and an error message about Flowstone's draw method. To resolve this, insert the following code as the first line of the draw method:
It should now look like this:
Hey nix,
I intended the Spline Class to be as open as possible. For example, I will use it to create a font designer (so that I am independent of the user's installed fonts). Therefore I would like to avoid adding functionality for special cases. But it is relatively easy to add such in your own projects. Just create methods that fill the spline with the neccessary nodes. I try to create an example soon, but it could take a while, since I want to dive into ASM and oscillators by KG and martin.
Also, I stumbled upon an issue with Ruby. I will create an extra topic for that. But regarding the spline class: If you exit Flowstone, then start it fresh and open the example 2, you will be presented with an empty spline display and an error message about Flowstone's draw method. To resolve this, insert the following code as the first line of the draw method:
- Code: Select all
init if @s == nil
It should now look like this:
- Code: Select all
def draw v
init if @s == nil
@s.draw v, [0, 0, v.width, v.height]
end
nix wrote:If you want to do battle, tulamide(ty!),
I would love different spline shapes like triangle and square
muchly appreciated bro
Hey nix,
I intended the Spline Class to be as open as possible. For example, I will use it to create a font designer (so that I am independent of the user's installed fonts). Therefore I would like to avoid adding functionality for special cases. But it is relatively easy to add such in your own projects. Just create methods that fill the spline with the neccessary nodes. I try to create an example soon, but it could take a while, since I want to dive into ASM and oscillators by KG and martin.
"There lies the dog buried" (German saying translated literally)
- tulamide
- Posts: 2714
- Joined: Sat Jun 21, 2014 2:48 pm
- Location: Germany
11 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 22 guests