xxxxxxxxxx
function setup() {
createCanvas(559, 397);
background(255);
rectMode(CENTER);
}
function draw() {
//background(0);
// jump to the center of the sketch
translate(width/2, height/2);
let s = map(sin(millis()/500), -1, 1, -300, 300);
let sc = map(cos(millis()/1000), -1, 1, -300, 300);
noFill();
stroke(0);
translate(sc, 0)
rotate(millis()/400);
triangle (0, 0, 400, 400, 25, 25);
triangle (-40, 0, 600, -500, 25, -25);
rect(40, 500, 200)
}
/* Möglichkeit 1: Solange der Mausklick gehalten wird, stoppt die Zeichnung. Lässt man los, fährt sie fort.
function mousePressed() {
noLoop();
}
function mouseReleased() {
loop();
}
// Bild speichern
function keyPressed() {
if (key == "s") {
save('mySVG.svg');
}
}
*/
//Möglichkeit 2: Sobald die Taste "s" gedrückt wird, stoppt die Zeichnung. Bei Betätigung der Taste "c" macht sie weiter.
// freeze when key pressed "s", "c" for continue
function keyPressed() {
if (key == "s") {
noLoop();
} else if (key == "c") {
loop();}
}
function mousePressed() {
save("mySVG.svg");
}