[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] drawHook and do loops




On 6 Mar 2006, at 22:51, Jascha Narveson wrote:



does anyone know why does the do loop in this simple Pen example executes multiple times?  this is a concise version of a problem which is showing up in a much longer piece of code-in-progress, and i can't figure it out.

You've got the win.refresh inside the win.drawHook function, so that creates a recursive loop.

I took it out of the loop so this should work:


f = { 
var win;
win = SCWindow.new("penplot", Rect(100,100,400,200));
win.view.background_(Color.white);
win.drawHook = {
Pen.translate(0,100);
Color.grey.set;
Pen.moveTo(Point(0,0));
Pen.lineTo(Point(400,0));
Pen.stroke;
2.do({|i| i.postln});
};
win.refresh;
win.front;

};

f.value;