[sc-users] scwindow .refresh clear
Till Bovermann
tboverma at techfak.uni-bielefeld.de
Mon Dec 4 18:14:23 PST 2006
On 04 Dec 2006, at 17:43, Fredrik Olofsson wrote:
> hi list,
> is there any way to _not clear a SCWindow completely when
> calling .refresh? i think not but please prove me wrong.
Unfortunately you're right... :-/
It would require to have an NSImage (I think thats the name) to draw
in which currently is not available...
> i'd like to clear it manually by drawing a full-sized rectangle
> alpha 0.5 or something. this'd let you do cool and efficient trail
> effects with the Pen class.
>
> i know i can store the trails in an fifo buffer and thereby let
> them survive a .refresh but that's really not realtime friendly.
> so something like this but without the need to run all the 50
> frames all at once.
>
neat, but you have to do it like this currently:
(
var width= 640, height= 480, run= true, w, theta= 0, i = 1;
w= SCWindow("trail test", Rect(128, 64, width, height));
w.view.background= Color.black;
w.front;
w.drawHook= {
//i would like to sequence these 25 frames. but routine not allowed
inside drawHook
//and refresh clears the window completely
i.do{
var x= 60*sin(theta), y= 40*cos(theta);
theta= theta+0.015;
//--clear with alpha
Color.grey(0, 0.1).set;
Pen.fillRect(Rect(0, 0, width, height));
//--rects
Color.white.set;
Pen.push;
Pen.translate(width*0.6, height*0.6);
5.do{|i|
Pen.scale(i+0.6, i+0.6);
Pen.rotate(theta);
Pen.strokeRect(Rect.aboutPoint(x at y, 60, 40));
};
Pen.pop;
}
};
// awful:
{
25.do{|j|
i = j+1;
0.125.wait;
{w.refresh;}.defer
}
}.fork
)
More information about the sc-users
mailing list