Page 1 of 1

bitmap crop, loop (like css borderimage)

Posted: Mon Jun 17, 2013 8:33 am
by NightmareDream
I have so many projects... :o

Right now i'd like to get a grab on a flowstone ruby expression dictionnary and browse around so i could find how to crop a bitmap :P

I want to use a bitmap that has 3 areas, left side, center (stretch) and right side.. To make buttons and gui parts.
It could really be useful to planify in advance to include optionnal 9 areas setup for further uses . {top left, bottom-right, center, side-left (...)}

Also, alternatively, loop instead of stretch could be useful.
Even then, it could be mixed with @cells like the /on/off/ switches that uses this code function... Could allow the animation of a button that uses that "css-borderimage-like" code... :3

Right now, that's the only code that i've got and am lacking of knowledge as i am a slow learner that works more instinctively than in any organised way (my bad)...

Code: Select all

def draw v
   v.drawBitmap @bitmap,[0,0,v.width,v.height]
end
def event i,v
   redraw 0
end


I could end up with some results with primitives but it'd probably be 3times too much heavy :o

I'd also like to know how i could make a simple rotate code like the primitive rotate view module...

Well... I'd love to have Ruby alternatives for all processes from simple multiply to text formatting and stuff :o It's so hard to get informations about Flowstone's ruby or anything flowstone, synthmaker or dsprobotics :P


I am really close to achieve a software synthetizer that really is /OH-MY-GOD!/ but it's getting rough so before i try to make money with it (how does it work, legally? are there online stores on which i could display? how to make secure transactions?) When i'll be able to make marketable versions, i'll buy flowstone with yearly renew enabled :P :P

Where could i study flowstone like in college or something?

Re: bitmap crop, loop (like css borderimage)

Posted: Mon Jun 17, 2013 4:36 pm
by MyCo
Have a look into the code for the Bitmap Knobs in the Toolbox. It demonstrates how to display "stitched" Bitmaps. For a complete code reference look in the Ruby section of the user guide:
viewforum.php?f=23

For your problem you'll should take a look at this function:

Code: Select all

drawBitmapSection bitmap, source, position [, alpha, rotation, origin]



NightmareDream wrote:I'd also like to know how i could make a simple rotate code like the primitive rotate view module...


You can't rotate a view with Ruby. But you can do the rotation yourself, for all the parts you gonna draw in Ruby. That's basically just basic Math. You can take a look at the "rotatePoint" Method in the Knobs code. This is used to rotate a point around a center point. You can also rotate a bitmap using the "drawBitmapSection" method that I mentioned above.