xxxxxxxxxx
let content = "This sketch creates his own lines, arcs and triangles by time. By moving the mouse to the left/right, you move a triangle corner on the X- Axis. Press „s“ on your Keyboard to safe a png. \n Have fun.";
// Umbrüche sind als \n (break) im Text zu deklarieren
let sora;
// Font laden
function preload() {
sora = loadFont('Sora-SemiBold.ttf');
}
function setup() {
createCanvas(1920, 1080);
textFont(sora); // Font setzen
}
function draw() {
background(220);
// Euer Code
translate(0, height / 30);
//mouseX/1000;
//let num = map(mouseX, 0, width, 10, 300);
let num = map(sin(millis()/1000), -1, 1, 10, 150);
for (let y = 0; y < num; y += 1) {
let rot = map(y, 0, num, 0, PI);
let posx = map(y, 0, num, 0, width);
//let col = map(y, 0, num, 0, 255);
//stroke(col);
push();
translate(posx, 0);
rotate(rot);
noFill();
stroke(166, 120, 41);
triangle(220,50,windowWidth,370, mouseX, 100);
arc(0, 300, windowHeight, 280, 340, 20);
arc(20, 340, 280, windowWidth, 300, 0);
pop();
}
// Wort
textSize(250);
textAlign(CENTER, CENTER);
fill(250);
//noStroke();
text("fact", width/2, height/2);
// Hilfe Text
fill(0);
textSize(32);
text("?", 15, -20);
if (windowWidth/32-10 > 0 && mouseX < 30 && mouseY > 0 && mouseY < windowHeight/10-2) {
cursor(HAND);
text(content, 40, -415, 450, height);
//text(content, 20, 40, width-20, height-20);
}
else {
cursor(ARROW);
}
}
// Bild speichern
function keyPressed() {
if (key == "s") {
save('tool_grafik.png');
}
}