Page 1 of 1

Undocumented Ruby feature

Posted: Wed Dec 31, 2014 12:03 pm
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 ...)

Re: Undocumented Ruby feature

Posted: Wed Dec 31, 2014 12:17 pm
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.

Re: Undocumented Ruby feature

Posted: Sat Jan 03, 2015 4:55 pm
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]