xxxxxxxxxx
112
let font;
let x = 0;
let y = 0;
let rZ = 0;
let rC = [];
let input, check1,check2,check3,button4,button5;
let b1 = true;
let b2 = true;
let b3 = true;
let currentFrame;
function preload() {
font = loadFont("SpaceMono-Regular.ttf");
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
background(255);
rZ = random(TWO_PI);
rC = [155,225];
input = createInput("insert text here");
button4 = createButton('randomize');
button4.mousePressed(b4Pressed);
button5 = createButton('save');
button5.mousePressed(b5Pressed);
check1 = createCheckbox('background', false);
check1.changed(b1Pressed);
check2 = createCheckbox('movement', true);
check2.changed(b2Pressed);
check3 = createCheckbox('spinning', true);
check3.changed(b3Pressed);
input.position(10,10);
button4.position(200,10);
button5.position(300,10);
check1.position(10,45);
check2.position(10,70);
check3.position(10,95);
}
function draw() {
if (!b1) {
background(100,100,100);
}
textAlign(CENTER, BASELINE);
colorMode(HSL);
textFont(font);
let size = height/20;
textSize(size);
if (x < width/2 && b2) {
x++;
} else if (x >= width/2 && b2) {
x = -width/2;
} else if(!b2) {
x = x;
}
if (y > -height/2 && b2) {
y--;
} else if (y <= -height/2 && b2) {
y = height/2;
} else if (!b2) {
y = y;
}
translate(x,y);
for(let i=1; i<size; i++){
fill(map(i,1,size,rC[0],rC[1]),55, 55);
push();
if (b3) {
rotateY(frameCount/90 + i/PI);
} else if (!b3) {
rotateY(currentFrame/90 + i/PI);
}
rotateZ(rZ);
rotateX(rZ);
text(input.value(),0,height/2.5-i*size/2.5);
pop();
};
}
function b1Pressed() {
(b1 = !b1);
}
function b2Pressed() {
(b2 = !b2);
}
function b3Pressed() {
currentFrame = frameCount;
(b3 = !b3);
}
function b4Pressed () {
rZ = random(-TWO_PI,TWO_PI);
rC = [random(0,180),random(180,360)];
}
function b5Pressed() {
saveCanvas(input.value() + '.jpg')
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}