xxxxxxxxxx
69
var z;
var pg;
var myFont;
var stars_loc = [];
function preload() {
myFont = loadFont('20db.otf');
}
function setup() {
frameRate(10);
createCanvas(400, 400, WEBGL);
pg = createGraphics(200, 200);
z = 0;
// larger number means larger cells = fewer stars
setStarLocations(15);
}
function draw() {
background(0);
strokeWeight(0.5);
stroke(155);
drawStars();
pg.background(0);
pg.fill('yellow');
// Set font size
drawTitleFrame(48);
}
function setStarLocations(gridSize) {
for (var x = gridSize; x <= width - gridSize; x += gridSize) {
for (var y = gridSize; y <= height - gridSize; y += gridSize) {
var px = random(-width/2, width/2);
var py = random(-height/2, height/2);
stars_loc.push([px, py]);
}
}
}
function drawStars() {
for (var i = 0; i < stars_loc.length; i++) {
point(stars_loc[i][0], stars_loc[i][1])
}
}
function drawTitleFrame(textSize) {
pg.textAlign(CENTER);
pg.textFont(myFont);
pg.textSize(textSize);
pg.text('Star Wars', -85, 25, 400, 400);
//pass image as texture
push()
translate(0, 0, z);
texture(pg);
plane(400);
z-=5;
pop();
}