Encapsulate lines inside a panel and move that panel?

For general discussion related FlowStone
Post Reply
Nowhk
Posts: 275
Joined: Mon Oct 27, 2014 6:45 pm

Encapsulate lines inside a panel and move that panel?

Post by Nowhk »

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?

Post by Nowhk »

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?

Post by Nowhk »

No way? :ugeek:
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

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

Post by RJHollins »

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.
Post Reply