Hy janmaltel
hope you are ok.
I need your help again…
I would like to integrate the first sketch
into the second but when I do that the line only draws once and runs without leaving a trace …
Can you help me solve it?
first sketch : let imgW;
let ang1=0, ang2=0;
let raio=220;
let x1,y1,x2,y2;
function setup() {
createCanvas(1000, 1000);
background(0);
imgW = loadImage(‘Rosa_corymbifera.png’);
strokeWeight(1.5);
}
function draw() {
push() ;
stroke(random(220, 255), random(220, 255), random(220, 255));
ang1+=0.01;
if(ang1>2PI) ang1=0;
ang2+=0.05;
if(ang2>2PI) ang2=0;
let nx=sin(ang2)*raio/3;
let ny=cos(ang2)*raio/3;
let x1=nx-sin(ang1)*raio;
let y1=ny-cos(ang1)*raio;
let x2=nx+sin(ang1)*raio;
let y2=ny+cos(ang1)*raio;
translate(width/2,height/2);
line(x1,y1,x2,y2);
second sketch (is longer but a resume…)
push();
if (mouseX > 1305 && mouseX < 1325 && mouseY > 600 && mouseY < 620) {
stroke(255);
strokeWeight(4);
fill(0);
rect(620, 365, 570, 600);
image(imgMaq, random(1150, 1155), random(400, 405), 420, 660);
ele.autoplay(true);
// push();
stroke(random(220, 255), random(220, 255), random(220, 255));
ang1+= 0.01;
if (ang1 > 2 * PI) ang1 = 0;
ang2 += 0.05;
if (ang2 > 2 * PI) ang2 = 0;
let nx = sin(ang2) * raio/3;
let ny = cos(ang2) * raio/3;
let x1 = nx - sin(ang1) * raio;
let y1 = ny - cos(ang1) * raio;
let x2 = nx + sin(ang1) * raio;
let y2 = ny + cos(ang1) * raio;
translate(905, 670);
//rotate(ang1)
//translate(mouseX,mouseY);
line(x1, y1, x2, y2);
pop();
if you can tell me what i’m doing wrong i would appreciate it.
thanks
AKAC