xxxxxxxxxx
//Landing Page Graphic; Arjun, January 2022.
let vc;
var vcWidth = 800;
var vcHeight = 820;
let headFont;
let squareWidth;
let squareHeight;
let imgSquares = [];
let tiles = [];
let toggle = false;
let margin = 200;
let bg;
let fg;
let divisor = 30;
function preload(){
headFont = loadFont ('EBGaramond-Italic.ttf');
}
function setup() {
createCanvas(1000, 1000);
bg = color ('#0D0D0D');
fg = color ('#1F26D8');
//noSmooth();
const horizontalSquareCount = int(vcWidth/divisor);
const verticalSquareCount = int(vcHeight/divisor);
vc = createGraphics (vcWidth, vcHeight);
push();
var sizer = textSize();
//DrawTheText
//vc.background (190);
vc.textFont (headFont);
vc.textSize (200);
vc.fill (fg);
//vc.noFill();
//vc.stroke(255);
//vc.strokeWeight (2);
vc.noStroke();
vc.textAlign (LEFT, TOP);
vc.textLeading(190);
vc.text("gravity is working against me", 35, 0, vc.width, vc.height);
squareWidth = vc.width / horizontalSquareCount;
squareHeight = vc.height / verticalSquareCount;
pop();
//vc.loadPixels();
//pixelDensity (1);
for (var y = 0; y < vc.height; y += squareHeight) {
for (var x = 0; x < vc.width; x += squareWidth) {
imgSquares.push(vc.get(x, y, squareWidth, squareHeight));
}
}
let squareX = 0;
let squareY = 0;
let centerX = width/2-vc.width/2;
let centerY = height/2-vc.height/2;
for (const square of imgSquares) {
// Draw this square.
//image(square, squareX, squareY);
tiles.push(new Tiles (square, squareX+centerX, squareY+centerY));
// Draw the next square to the right of this square.
squareX += squareWidth;
// If the square went off the right edge, move down
// one row and start over at the left edge.
if (squareX >= vc.width) {
squareX = 0;
squareY += squareHeight;
}
}
// Add a general description of the canvas.
describe("A typographic sketch with the word 'gravity' on a black background that displaces with horizontal mouse movement.");
}
function draw() {
background(bg);
//For debug
//image (vc, 0, 0);
//translate (width/2-vc.width/2, height/2-vc.height/2);
for (let i = 0; i<tiles.length; i++){
tiles[i].display();
tiles[i].move();
}
/*
noCursor();
fill (140);
ellipse (mouseX, mouseY, 30, 30);
*/
}
function mousePressed(){
save ('still.jpeg');
}