Undocumented Ruby feature

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

Undocumented Ruby feature

Post by tulamide »

Just a quick visit to tell you about a Ruby feature I discovered while working on the sprite font engine.

Code: Select all

# myimage = Bitmap.new "the path"
myimage = Bitmap.new "C:\image.png"


This mimics the green Bitmap prim. It creates a bitmap and fills it with the image found at the given path. If no image is found, nil is returned. Just take care to never use an empty string, it will crash Flowstone immediatly. Wrong strings, like "abc" are ok, nil will be returned then. You can of course use a variable for the path string.
After having created a bitmap this way, all functionality described in the manual is valid for this one as well (.width, .height, .widthPixels, .heightPixels ...)
"There lies the dog buried" (German saying translated literally)
Exo
Posts: 426
Joined: Wed Aug 04, 2010 8:58 pm
Location: UK
Contact:

Re: Undocumented Ruby feature

Post by Exo »

Very cool, nice find :D

I think that must have been added recently and Malc forgot to put it on the change list.
Flowstone Guru. Blog and download site for Flowstone.
Best VST Plugins. Initial Audio.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Undocumented Ruby feature

Post by tulamide »

Even more undocumented features:

Color object

setARGB
set any or all color channels using the same options as with .new (one number sets opaque grey shade, 2 numbers set alpha and grey, 4 numbers set argb)

Code: Select all

c = Color.new 255, 8, 16, 24
c.setARGB 128, 8, 16, 24


getARGB
get the color channel values as a four-element-array

Code: Select all

c = Color.new 255, 8, 16, 24
argb = c.getARGB
#returns [255, 8, 16, 24]
"There lies the dog buried" (German saying translated literally)
Post Reply