xxxxxxxxxx
70
//Declare - Note it is outside of draw() so it doesnt initialise every frame
let circleY = 0;
let circleX = 100;
let ySpeed = 1;
let xSpeed = 1;
function setup() {
createCanvas(windowWidth ,windowHeight);
background(255);
}
function draw() {
//Adds one y position per frame
circleY = circleY + ySpeed;
circleX = circleX + xSpeed;
//bounce off top & bottom
// if the position of the circle on the y axis is less than 0 (the top) OR || is greater than the height (The Bottom) then turn the direction (ySpeed * -1)
if(circleY < 0 || circleY > height) {
ySpeed = ySpeed * -1;
}
if(circleX < 0 || circleX > width) {
xSpeed = xSpeed * -1;
}
//Text size proportional to window size
textSize(windowWidth/45);
// 'Text Content', X, Y controlled by window size
//text('Bakk Heia Records',windowWidth/2 ,windowHeight/6)
// 'Text Content', X, Y controlled by window size
textWrap(CHAR);
text('COMPUTER LIBERATION DREAM MACHINE',mouseX, mouseY)
//shape fill controlled by mouse
fill(mouseY-mouseX)
//random values (linked to canvas dimensions)
x = random(0, width)
y = random(0, height)
//mapped colour change (influenced by random values i.e canvas position)
r = map(x , 0, 108, 0, 250);
g = map(y , 0, 720, 156, 0);
b = map(y , 0, 720, 0, 30);
//Colour for line - static
//fill(200 , 2, 100)
//stroke(50 , 20, 20)
//colour for line - gradient (influenced by variables)
fill(r , g, b)
stroke(b ,g ,r)
}
//Dot size & weight (x + y )
//strokeWeight(3)
//rect(circleX, circleY, 40, 35, 35, 150);
function keyPressed(){
if (key === 's'){
saveCanvas("Toolkit Project Generator - Array + Curves.jpg");
}
}