(
var func, views, counter= 0;
func = {
if(counter>0, {
//clear+fadeout - or in your case just don't draw anything
Pen.fillColor_(Color.grey(1, 0.07));
Pen.fillRect(Rect(0, 0, w.bounds.width, w.bounds.height));
}, {
//draw only when counter= 0
Pen.use{
10.do{
Color.red(rrand(0.0, 1), rrand(0.0, 0.5)).set;
Pen.addArc((400.exprand(2))@(100.rand), rrand(10, 100),
2pi.rand, pi);
Pen.perform([\stroke, \fill].choose);
}
}
})
};
w = SCWindow.new("DrawFunc Examples").front;
w.view.background_(Color.white);
views = {|i|
v = SCUserView(w, Rect(20+(i*120), 100, 100, 100)).relativeOrigin_
(true);
v.drawFunc = func;
v.clearOnRefresh_(false)
} ! 3;
Routine({
inf.do{
w.refresh;
0.1.wait;
counter= counter-1%20;
}
}).play(AppClock);
)
Am 17.12.2007 um 17:57 schrieb thor:
Hi
Is it possible to add .drawOnRefresh_ to SCUserView?
I'd like to draw once and then disable SCUserView's draw
functionality
until I tell it to draw again. (other views are being updated
which forces
SCUserView to draw repeatedly).
The following code from the example works, but it's kind of ugly
to have to
repeatedly set the drawFunc to nil and then back to the intended
drawFunc
when needed.
And I'm not sure if clearOnRefresh saves any CPU...
t
prevent redrawing:
(
var func, views;
func = {|me|
Pen.use{
10.do{
Color.red(rrand(0.0, 1), rrand(0.0, 0.5)).set;
Pen.addArc((400.exprand(2))@(100.rand), rrand(10, 100),
2pi.rand, pi);
Pen.perform([\stroke, \fill].choose);
}
}
};
w = SCWindow.new("DrawFunc Examples").front;
w.view.background_(Color.white);
views = {|i|
v = SCUserView(w, Rect(20+(i*120), 100, 100, 100)).relativeOrigin_
(true);
v.drawFunc = func;
} ! 3;
w.refresh;
{views.do{|v| v.clearOnRefresh_(false);v.drawFunc = nil}}.defer(0.4);
)
#|
fredrikolofsson.com klippav.org musicalfieldsforever.com
|#
_______________________________________________
sc-users mailing list
sc-users@xxxxxxxxxxxxxxx
http://www.create.ucsb.edu/mailman/listinfo/sc-users