Support

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

Encapsulate lines inside a panel and move that panel?

For general discussion related FlowStone

Encapsulate lines inside a panel and move that panel?

Postby Nowhk » Fri Nov 13, 2015 11:29 am

I'm trying to do an animation in Flowstone using Ruby. What I'd like to do is to draw some lines/points inside a "panel" (Bitmap?) and than moving it left or right, adding new lines/points later and get a unique panel movement. A sort of "sweep/transition" of points.

I guess there is a smart way instead of store each lines inside an array and at each event, redraw all lines, translated of x value: when I got many points, this will be a NxM iteration.

This is what I have for example:

Code: Select all
def draw v
   p = Pen.new (Color.new 200,0,200,0), 0.3
   v.drawBitmap @bitmap,"[0,0,50,50]"
   v.drawLine p, [10, 10],[20, 10]
   v.drawLine p, [10, 15],[20, 15]
end

def event i,v
   if(i == "trigger")      
      redraw 0
   end
end

but I have no idea how to encapsulate these lines inside the hypothetical Bitmap and move it later.
Any clues?

Thank you!
Last edited by Nowhk on Fri Nov 13, 2015 12:08 pm, edited 1 time in total.
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Encapsulate lines inside a panel and move that panel?

Postby Nowhk » Fri Nov 13, 2015 12:05 pm

Ok I think I understand how to add line to a "panel". The panel I need to use in this case is a Graphics Paths. Here my target, a sort of drawing random step LFO:

Code: Select all
def init
   @path = GraphicsPath.new
   @pen = Pen.new (Color.new 200,0,200,0), 0.3
   @h
   @old_x = 0
   @old_y = 0
   @lenght = 5
end

def draw v
   @h = rand(20)
   @path.addLine [@old_x, @h],[@old_x + @lenght, @h]
   @old_x = @old_x + @lenght
   v.drawPath @pen, @path
end

def event i,v
   if(i == "reset")
      @old_x = 0
      @old_y = 0
      @path = GraphicsPath.new      
   elsif(i == "draw")   
      redraw 0
   end
end

the problem is: when I trigger "draw", it starts to draw lines, but won't stop it :o I want to add the new point when I click again on "trigger". Instead, if I click with mouse on the FlowStone area, it add random lines. Where am I wrong? It seems that it auto call draw itself :shock:

And I still don't know how to move it (@path) left/right on x-axis, at some points (so watching the LFO go forward).
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Encapsulate lines inside a panel and move that panel?

Postby Nowhk » Sun Nov 15, 2015 11:46 am

No way? :ugeek:
Nowhk
 
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Re: Encapsulate lines inside a panel and move that panel?

Postby RJHollins » Sun Nov 15, 2015 4:10 pm

Hi Nowhk,

I tried to use your code box, but had to guess HOW you where hooking into it.

I did not get it to work.

Maybe you could post a schematic so that we can load it up and test what you have to this point.
RJHollins
 
Posts: 1571
Joined: Thu Mar 08, 2012 7:58 pm


Return to General

Who is online

Users browsing this forum: No registered users and 46 guests