xxxxxxxxxx
63
function setup() {
createCanvas(windowWidth, windowHeight);
frameRate(1);
rectMode(CENTER);
}
function draw(){
clear();
drawRandomTriangle();
drawRandomCircle();
drawRandomRect();
drawRandomLine();
}
function drawRandomCircle(){
noStroke();
fill('#f6d55c')
for(let i = 0; i < 5; i++){
let pos = createVector(random(width), random(height))
let randomDiameter = random(width/4);
circle(pos.x, pos.y, randomDiameter);
}
}
function drawRandomRect(){
noStroke();
fill('#ed553b')
for(let i = 0; i < 3; i++){
let pos = createVector(random(width), random(height))
let randomHeight = random(width/4);
let randomWidth = random(height/4);
rect(pos.x, pos.y, randomHeight, randomWidth);
}
}
function drawRandomLine(){
stroke('black');
strokeWeight(2);
noFill();
for(let i = 0; i < 5; i++){
let pos1 = createVector(random(width), random(height))
let pos2 = createVector(random(width), random(height))
let randomDiameter = random(width/4);
line(pos1.x, pos1.y, pos2.x, pos2.y);
}
}
function drawRandomTriangle(){
fill('#20639b');
noStroke();
for(let i = 0; i < 2; i++){
let pos1 = createVector(random(width), random(height))
let pos2 = createVector(random(width), random(height))
let pos3 = createVector(random(width), random(height))
let randomDiameter = random(width/4);
triangle(pos1.x, pos1.y, pos2.x, pos2.y, pos3.x, pos3.y);
}
}
function mousePressed(){
save('myCanvas.jpg');
}