xxxxxxxxxx
151
// this is a painting sketch I experimented with
var SP = {
startingpointX : 200,
startingpointY : 200,
startingpointX2: 200,
startingpointY2 : 200,
startingpointX3 : 200,
startingpointY3 : 200,
startingpointX4 : 200,
startingpointY4 : 200,
startingpointX5 : 200,
startingpointY5 : 200,
startingpointX6 : 200,
startingpointY6 :200,
startingpointX7 : 200,
startingpointY7 : 200,
x: 200,
y: 200
}
// let startingpointX2
// let startingpointY2
// let startingpointX3
// let startingpointY3
// let startingpointX4
// let startingpointY4
// let startingpointX5
// let startingpointY5
// let startingpointX6
// let startingpointY6
// let x;
// let y;
function setup() {
createCanvas(400, 400);
}
function draw(){
right();
left();
topLeft()
topRight()
bottomRight()
bottomLeft()
horizontalSpeed();
mouseControl();
}
function mousePressed() {
background(255); }
function right() {
//right
noStroke();
fill(63, 124, 172, 10);
ellipse (SP.startingpointX, SP.startingpointY, 50,50);
SP.startingpointX +=3;
}
function left(){
if (SP.startingpointX > width) {
//left
fill(149, 175, 186, 10);
ellipse (SP.startingpointX2, SP.startingpointY2, 50,50);
SP.startingpointX2 -=3;
}
}
function topLeft(){
if (SP.startingpointX2 < 0) {
//top left
fill(189, 196, 167, 10);
ellipse (SP.startingpointX3, SP.startingpointY3, 50,50);
SP.startingpointX3 -=3;
SP.startingpointY3 -=3;
}
}
function topRight(){
if (SP.startingpointX3 < 0 & SP.startingpointY3 <0) {
//top right
fill(63, 136, 197, 10);
ellipse (SP.startingpointX4, SP.startingpointY4, 50,50);
SP.startingpointX4 +=3;
SP.startingpointY4 -=3;
}
}
function bottomRight() {
if (SP.startingpointX4 > width & SP.startingpointY4 < 0) {
//bottom right
fill(213, 225, 163, 10);
ellipse (SP.startingpointX5, SP.startingpointY5, 50,50);
SP.startingpointX5 +=3;
SP.startingpointY5 +=3;
}
}
function bottomLeft(){
if (SP.startingpointX5 > width & SP.startingpointY5 > height) {
//bottom left
fill(226, 248, 156, 10);
ellipse (SP.startingpointX6, SP.startingpointY6, 50,50);
SP.startingpointX6 -=3;
SP.startingpointY6 +=3;
}
}
function horizontalSpeed(){
fill(19, 111, 99, 10);
ellipse(SP.x, SP.y, 50, 50);
//calculate horizontal speed
let xSpeed= (mouseX- SP.x)/100
let ySpeed= (mouseY- SP.y)/100
SP.x += xSpeed
SP.y += ySpeed
}
//controlled by mouse
function mouseControl(){
let r = random(255);
var g = random(255);
let b = random(255);
fill(r, g, b, 100);
ellipse(mouseX, mouseY, 10, 10);
}