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

[sc-users] drawOnRefresh?





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);
)