xxxxxxxxxx
70
let inputElement, sliderElement;
let txts = [];
function setup() {
createCanvas(windowWidth, windowHeight);
colorMode(HSB, 255);
background(100);
// inputElement = createInput();
// inputElement.position(50, 150);
// inputElement.input(userInput);
// sliderElement = createSlider(.1, 1, 1, 0.1);
// sliderElement.position(50, 200);
// sliderElement.input(setGravity);
// buttonElement = createButton('Save Image');
// buttonElement.position(70, 250);
// buttonElement.mousePressed(saveImage);
setGravity()
userInput()
}
let ay = 0.1
let hu = 0;
function setGravity(){
ay = 100
}
/*
function saveImage(){
save('pix.jpg');
}
*/
function userInput(){
txts.push({
x: width / 2,
y: height / 2,
vx: random(-5, 5),
vy: 0,
text: 'what the fuckity fuck'
})
}
function draw() {
// background(245);
fill(0, 10);
rect(0, 0, width, height);
fill(255);
textSize(80);
for (var i=0; i<txts.length; i++){
fill(hu%255, 200, 255);
let txt = txts[txts.length - 1];
text(txt.text, txt.x, txt.y);
txt.x += 0.03 * txt.vx;
txt.y += 0.01 * txt.vy;
txt.vy += ay;
if(txt.x > width - 100){
txt.vx = -abs(txt.vx);
}
if(txt.x < 0){
txt.vx = abs(txt.vx);
}
if(txt.y > height - 100){
txt.vy = -abs(txt.vy);
}
hu+=0.5;
}
}