xxxxxxxxxx
84
let label = "Session 3_Buffer";
let buffer2;
let buffer;
let ourMode = 1;
function preload() {
font = loadFont("DaysOne-Regular.ttf");
}
function setup() {
createCanvas(650, 650, WEBGL);
buffer2 = createGraphics(340, 300);
buffer2.textFont(font);
// buffer2.background(290, 88);
buffer2.fill(227, 178, 195); //font color
buffer2.textSize(100);
// buffer2.textLeading(900);
// buffer2.translate(30, 100);
buffer2.text("DAMN", 0, 185);
buffer = createGraphics(340, 300);
buffer.textFont(font);
// buffer2.background(290, 88);
buffer.fill(3, 166, 74); //font color
buffer.textSize(90);
// buffer2.textLeading(900);
// buffer2.translate(30, 100);
buffer.text("OK", 0, 185);
// buffer2.text(txt, 0, 100, buffer2.width, height);
}
function draw() {
background(0);
texture(buffer2);
textureMode(NORMAL);
for (let i = 0; i < 10; i++) {
for (let j = 0; j < 10; j++) {
let x = sin((frameCount + j * 10 + i) * 0.1) * 0.02;
// let y = sin((frameCount + i * 3) * 110) * 2;
let y = -cos(frameCount * 0.0008) * 10;
translate(x - 20, y * 0.109);
push();
rotate(frameCount * 0.0005);
translate(j * 200, (frameCount * j - 100) * 0.11);
image(buffer2, 30, x, 4000 * x, 80);
image(buffer, 30, x, 4000 * x, 120);
pop();
push();
// rotate(frameCount * 0.04);
// translate(j * 20, (frameCount * j + 100) * 0.11);
pop();
}
}
blendMode(BLEND);
}
function keyPressed() {
if (key === "s") {
if (this._renderer.elt.svg !== undefined) {
saveSVG(label + ".svg");
} else {
saveCanvas(label + ".png");
}
}
if (key === "g") {
isShowGrid = !isShowGrid;
}
}