Hi everyone, I was messing around with the Pen object and found out that when I set the background color to clear(Window.background_(Color.clear)) it leaves a outline behind like the picture I am posting does anybody have any insight on why this is happening??
//Here is the code
(
Window.closeAll;
w = Window.new("text", Rect(0,0, 200, 200), false).front
.alwaysOnTop_(true)
//this or background_(Color.clear));
.background_(Color(1,1,1,0.01));
u = UserView.new(w, Rect(0,0,200,200))
.animate_(true)
.frameRate_(25)
.drawFunc_({
arg i;
var time = u.frame*0.01;
Pen.moveTo(50@50);
Pen.line(50@50, 100@100);
Pen.line(150@10, 150@100);
Pen.curveTo(
10@150,
20@3,
sin(time)*200@sin(time*0.1)*2
);
Pen.curveTo(
sin(time*0.5)*300@10,
120@20,
sin(time)*30@sin(time*0.1)*10
);
Pen.draw;
});)
I tried to run your code on windows on sc 3.10.2 and got a completely black window.
Next, I ran it on linux sc latest dev version and I got a black window again, both with Color.clear and Color(1,1,1,0.01);
Then, just before the line Pen.moveTo(50@50) I inserted a Pen.color_(Color(1,1,1,1)) and then it seems to behave correctly here both with background_(Color.clear) and background_(Color(1,1,1,0.01))
I then played some more with Pen properties (fillColor_, color_, width_, .stroke instead .draw, etc) but everything kept working as expected.
I find, if I run the example with @shiihs’s change, it works as expected.
But…
(
w.tryPerform(\close);
w = Window.new("text", Rect(0,0, 200, 200), false).front
.alwaysOnTop_(true);
// do NOT set the background initially!
// w.background_(Color(1,1,1,0.01));
u = UserView.new(w, Rect(0,0,200,200))
.animate_(true)
.frameRate_(25)
.drawFunc_({
arg i;
var time = u.frame*0.01;
Pen.color_(Color.white).moveTo(50@50);
Pen.line(50@50, 100@100);
Pen.line(150@10, 150@100);
Pen.curveTo(
10@150,
20@3,
sin(time)*200@sin(time*0.1)*2
);
Pen.curveTo(
sin(time*0.5)*300@10,
120@20,
sin(time)*30@sin(time*0.1)*10
);
Pen.draw;
});
)
// now set the background after it's running
w.background_(Color(1,1,1,0.01));
… the animation stops erasing and the white blob gets bigger and bigger.
That is strange because for me setting the background color after the animation gives me a black background with the animation still visible. I’m running mac osx and sc 3.10.2 I’ll try on my windows and linux machine once I get access thank you!
hmm strange I still get the weird outlines with your suggestions, I’ll try stuff out on my other machines running linux and windows. I’ll have a go and report back soon. Thanks for the replies!