0xb9eddce6…9dfbsent to0x0a1bbd57…3676·#19,705,421·view on Etherscan
var seed = parseInt(tokenData.hash.slice(0, 16), 16);
let projectNumber = Math.floor(parseInt(tokenData.tokenId) / 1000000);
let walletCount = parseInt(tokenData.tokenId) % 1000000;
let vertX = [0.59375, 0.40625, 0.59375, 0.40625, 0.59375, 0.40625];
let vertY = [0.75, 0.75, 0.5, 0.5, 0.25, 0.25];
let horiX = [0.75, 0.5, 0.25, 0.75, 0.5, 0.25];
let horiY = [0.59375, 0.59375, 0.59375, 0.40625, 0.40625, 0.40625];
let vertical;
let sixX, sixY;
let multiplyOn = false;
let mostShapeArr = [0, 0, 0, 0, 0, 0];
let shapesNames = ["Sun", "Shard", "Cargo", "Hive", "Pyramid", "Moon"];
p5.disableFriendlyErrors = true;
let rezs = [150, 200, 300];
let rezIndex = 2;
let lineThickness;
let lineDepth;
let lineLength;
let lineSpacing;
let depth = 255.0;
let displayRed = true;
let displayGreen = true;
let displayBlue = true;
let stillLifeDim = -1;
let stillLifeDepthNeg = 0;
let stillLifeDepthPos = 0;
let depthScalar = 1.0;
let speedScalar = 1.0;
let speeds = [0.25, 0.5, 1.0, 2.0, 0.0];
let speedIndex = 2;
let SEED = 0;
let lengthScalar = 1.3;
let combination = [];
let angle = 0.0;
let alphapix;
let overlay;
let cityNum;
let cla, cny, cberlin, ccdmx, clondon, ctokyo;
let s1, s2, s3, s4;
let sc;
let foregrounds = [];
let bColor = 246;
let shapes = [];
let gl;
let stillLifePO2 = 2;
let ext;
let pgl;
let viewDiagram = false;
let infoOverlay = false;
let viewMatrix;
let modelViewMatrix;
let dispMapTexture;
let CDMXSpin = 1;
const vertCode = `precision highp float;
uniform mat4 uViewMatrix;
uniform mat4 uProjectionMatrix;
uniform mat4 uModelViewMatrix;
uniform mat4 uModelViewProjectionMatrix;
uniform vec2 canvasSize;
uniform float stillLifeDim;
uniform float stillLifePO2;
uniform float stillLifeDepthNeg;
uniform float stillLifeDepthPos;
uniform float depthScalar;
uniform float lineThickness;
uniform float lineDepth;
uniform float lineLength;
uniform vec3 color;
uniform sampler2D displacementMap;
attribute vec3 coordinates;
float map(float value, float min1, float max1, float min2, float max2)
{
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}
struct Line
{
vec3 start;
vec3 end;
};
Line getLineFromDisplacementMap(int x_origin, int y_origin)
{
Line l;
vec2 imageCoords = vec2(x_origin, y_origin);
imageCoords.x += .5;
imageCoords.y += .5;
vec2 samplePos = imageCoords.xy/stillLifePO2;
vec4 dispMapColor = texture2D(displacementMap, samplePos);
float maxEdge = max(canvasSize.x, canvasSize.y);
float x = float(x_origin);
float y = float(y_origin);
float z = map(dot(dispMapColor.xyz, color), 0.0, 1.0, -stillLifeDepthNeg, stillLifeDepthPos);
l.start.x = map(x, 0.0, stillLifeDim, -maxEdge / 2.0, maxEdge / 2.0);
l.start.y = map(y, 0.0, stillLifeDim, -maxEdge / 2.0, maxEdge / 2.0);
l.start.z = -z;
l.end.x = map(x, 0.0, stillLifeDim, -maxEdge / 2.0, maxEdge / 2.0) - lineDepth;
l.end.y = map(y, 0.0, stillLifeDim, -maxEdge / 2.0, maxEdge / 2.0) - lineDepth;
l.end.z = -lineLength - z;
return l;
}
void main()
{
bool lineStart = false;
if (coordinates.y == 0.0) lineStart = true;
if (coordinates.y == 1.0) lineStart = true;
if (coordinates.y == 2.0) lineStart = false;
if (coordinates.y == 3.0) lineStart = true;
if (coordinates.y == 4.0) lineStart = false;
if (coordinates.y == 5.0) lineStart = false;
int imageCoordsY = int(floor(coordinates.x / stillLifeDim));
int imageCoordsX = int(floor(coordinates.x - float(imageCoordsY) * stillLifeDim));
Line l = getLineFromDisplacementMap(imageCoordsX, imageCoordsY);
vec3 vertexPosition;
if (lineStart) {
vertexPosition = l.start;
} else {
vertexPosition = l.end;
}
vec4 finalPos = vec4(vertexPosition, 1.0);
finalPos = uModelViewProjectionMatrix * finalPos;
vec4 projLineStart = uModelViewProjectionMatrix * vec4(l.start, 1.0);
vec4 projLineEnd = uModelViewProjectionMatrix * vec4(l.end, 1.0);
vec2 lineDirection = projLineStart.xy - projLineEnd.xy;
lineDirection = vec2(-lineDirection.y, lineDirection.x);
float maxEdge = max(canvasSize.x, canvasSize.y);
lineDirection /= canvasSize / maxEdge;
vec2 displacement = normalize(lineDirection);
displacement /= canvasSize;
displacement *= lineThickness;
if (coordinates.y == 0.0) finalPos.xy -= displacement;
if (coordinates.y == 2.0) finalPos.xy -= displacement;
if (coordinates.y == 5.0) finalPos.xy -= displacement;
if (coordinates.y == 1.0) finalPos.xy += displacement;
if (coordinates.y == 3.0) finalPos.xy += displacement;
if (coordinates.y == 4.0) finalPos.xy += displacement;
finalPos.z = 0.0;
gl_Position = finalPos;
}
`;
const fragCode = `precision highp float;
uniform vec3 color;
void main() {
gl_FragColor = vec4(color, 1.0);
}
`;
let triangle_buffer;
let numTris;
function setupGeometry() {
let triangles = [];
numTris = 0;
for (let y = 0; y < rezs[rezIndex]; y += 1) {
for (let x = 0; x < rezs[rezIndex]; x += 1) {
triangles.push(x + y * stillLifeDim, 0, 0);
triangles.push(x + y * stillLifeDim, 1, 0);
triangles.push(x + y * stillLifeDim, 2, 0);
triangles.push(x + y * stillLifeDim, 3, 0);
triangles.push(x + y * stillLifeDim, 4, 0);
triangles.push(x + y * stillLifeDim, 5, 0);
numTris += 6;
}
}
triangle_buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, triangle_buffer);
gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(triangles), gl.STATIC_DRAW);
gl.bindBuffer(gl.ARRAY_BUFFER, null);
}
function setupShapes() {
let sss = 0.3;
shapes = [];
let currSet = all_sets[walletCount];
mostShapeArr = [0, 0, 0, 0, 0, 0];
if (vertical) {
sixX = vertX;
sixY = vertY;
} else {
sixX = horiX;
sixY = horiY;
}
let currShapesArr = [];
for (let currCombo = 0; currCombo < currSet.length; currCombo++) {
setupCombination(currSet[currCombo]);
for (let i = 0; i < combination.length; i++) {
currShapesArr.push(
new VShape(
-stillLifeDim * sixX[currCombo],
-stillLifeDim * sixY[currCombo],
stillLifeDim * sss,
combination[i]
)
);
}
shapes.push(currShapesArr);
currShapesArr = [];
}
theDetails();
}
function theDetails() {
let maxSide = max(width, height);
if (maxSide < 400) {
depthScalar = map(maxSide, 50, 400, 0.05, 0.3);
} else {
depthScalar = map(maxSide, 400, 3840, 0.3, 2.0);
}
stillLifeDepthNeg = 255.0 / 4;
stillLifeDepthPos = 255.0 / 4;
lengthScalar = 1.0;
let cityDigit = mostShapeArr.indexOf(Math.max(...mostShapeArr)) + 1;
if (cityDigit == 1) {
tokyoParams();
} else if (cityDigit == 2) {
berlinParams();
} else if (cityDigit == 3) {
londonParams();
} else if (cityDigit == 4) {
nycParams();
} else if (cityDigit == 5) {
cdmxParams();
} else {
laParams();
}
}
let shaderProgram;
function setupShaders() {
let vertShader = gl.createShader(gl.VERTEX_SHADER);
gl.shaderSource(vertShader, vertCode);
gl.compileShader(vertShader);
const vertError = gl.getShaderInfoLog(vertShader);
if (vertError.length > 0) {
throw vertError;
}
let fragShader = gl.createShader(gl.FRAGMENT_SHADER);
gl.shaderSource(fragShader, fragCode);
gl.compileShader(fragShader);
const fragError = gl.getShaderInfoLog(fragShader);
if (fragError.length > 0) {
throw fragError;
}
shaderProgram = gl.createProgram();
gl.attachShader(shaderProgram, vertShader);
gl.attachShader(shaderProgram, fragShader);
gl.linkProgram(shaderProgram);
}
function createDisplacementMapTexture() {
dispMapTexture = gl.createTexture();
while (stillLifePO2 < stillLifeDim) {
stillLifePO2 *= 2;
}
}
function transferDisplacementMap() {
let img = alphapix.get();
img.loadPixels();
let uvTexture = Array(stillLifePO2 * stillLifePO2 * 4).fill(255);
const randomStuff = new Uint8Array(uvTexture);
for (let x = 0; x < stillLifeDim; ++x) {
for (let y = 0; y < stillLifeDim; ++y) {
const index1 = 4 * (y * stillLifePO2 + x);
const index2 = 4 * (y * stillLifeDim + x);
randomStuff[index1 + 0] = img.pixels[index2 + 0];
randomStuff[index1 + 1] = img.pixels[index2 + 1];
randomStuff[index1 + 2] = img.pixels[index2 + 2];
}
}
gl.bindTexture(gl.TEXTURE_2D, dispMapTexture);
gl.texImage2D(
gl.TEXTURE_2D,
0,
gl.RGBA,
stillLifePO2,
stillLifePO2,
0,
gl.RGBA,
gl.UNSIGNED_BYTE,
randomStuff
);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
gl.bindTexture(gl.TEXTURE_2D, null);
gl.activeTexture(gl.TEXTURE2);
gl.bindTexture(gl.TEXTURE_2D, dispMapTexture);
const displaceMapLocation = gl.getUniformLocation(
shaderProgram,
"displacementMap"
);
gl.uniform1i(displaceMapLocation, 2);
}
function setMatrices() {
const viewMatrix = this._renderer._curCamera.cameraMatrix;
const projectionMatrix = this._renderer.uPMatrix;
const modelViewMatrix = this._renderer.uMVMatrix;
const modelViewProjectionMatrix = modelViewMatrix.copy();
modelViewProjectionMatrix.mult(projectionMatrix);
gl.uniformMatrix4fv(
gl.getUniformLocation(shaderProgram, "uViewMatrix"),
false,
viewMatrix.mat4
);
gl.uniformMatrix4fv(
gl.getUniformLocation(shaderProgram, "uProjectionMatrix"),
false,
projectionMatrix.mat4
);
gl.uniformMatrix4fv(
gl.getUniformLocation(shaderProgram, "uModelViewMatrix"),
false,
modelViewMatrix.mat4
);
gl.uniformMatrix4fv(
gl.getUniformLocation(shaderProgram, "uModelViewProjectionMatrix"),
false,
modelViewProjectionMatrix.mat4
);
}
function setUniforms() {
gl.uniform2f(
gl.getUniformLocation(shaderProgram, "canvasSize"),
width,
height
);
gl.uniform1f(
gl.getUniformLocation(shaderProgram, "stillLifeDim"),
stillLifeDim
);
gl.uniform1f(
gl.getUniformLocation(shaderProgram, "stillLifePO2"),
stillLifePO2
);
gl.uniform1f(
gl.getUniformLocation(shaderProgram, "depthScalar"),
depthScalar
);
gl.uniform1f(
gl.getUniformLocation(shaderProgram, "stillLifeDepthNeg"),
stillLifeDepthNeg * depthScalar
);
gl.uniform1f(
gl.getUniformLocation(shaderProgram, "stillLifeDepthPos"),
stillLifeDepthPos * depthScalar
);
gl.uniform1f(
gl.getUniformLocation(shaderProgram, "lineThickness"),
lineThickness
);
gl.uniform1f(gl.getUniformLocation(shaderProgram, "lineLength"), lineLength);
gl.uniform1f(gl.getUniformLocation(shaderProgram, "lineDepth"), lineDepth);
}
function beginLinesShader() {
gl.useProgram(shaderProgram);
gl.bindBuffer(gl.ARRAY_BUFFER, triangle_buffer);
transferDisplacementMap();
setUniforms();
const coord = gl.getAttribLocation(shaderProgram, "coordinates");
gl.vertexAttribPointer(coord, 3, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(coord);
gl.enable(gl.BLEND);
gl.disable(gl.DEPTH_TEST);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
gl.viewport(0, 0, canvas.width, canvas.height);
}
function endLinesShader() {
gl.useProgram(null);
}
function drawLines() {
beginLinesShader();
setMatrices();
gl.uniform3f(gl.getUniformLocation(shaderProgram, "color"), 1, 1, 0);
if (displayRed) {
gl.drawArrays(gl.TRIANGLES, 0, numTris);
}
translate(lineSpacing, 0.0, 0.1);
setMatrices();
gl.uniform3f(gl.getUniformLocation(shaderProgram, "color"), 0, 1, 1);
if (displayGreen) {
gl.drawArrays(gl.TRIANGLES, 0, numTris);
}
translate(lineSpacing, 0.0, 0.1);
setMatrices();
gl.uniform3f(gl.getUniformLocation(shaderProgram, "color"), 1, 0, 1);
if (displayBlue) {
gl.drawArrays(gl.TRIANGLES, 0, numTris);
}
endLinesShader();
}
function setupTransform() {
ortho();
scale(1.45);
rotateY(0.33);
rotateX(-0.33);
}
function setupCombination(code) {
combination = [];
let comb = str(code);
for (let i = 0; i < comb.length; i++) {
let char = comb[i];
if (char != "0") {
mostShapeArr[char - 1] += 1;
let c = int(comb[i]) - 1;
combination.push(c);
}
}
}
function defineColors() {
let aaa = 254;
ctokyo = color(227, 143, 53, aaa);
cberlin = color(53, 155, 227, aaa);
clondon = color(231, 71, 71, aaa);
cny = color(166, 79, 206, aaa);
ccdmx = color(76, 205, 82, aaa);
cla = color(238, 211, 30, aaa);
foregrounds = [ctokyo, cberlin, clondon, cny, ccdmx, cla];
s1 = color(255, 226, 204);
s2 = color(204, 255, 226);
s3 = color(225, 204, 226);
s4 = color(164, 204, 255);
sc = [s1, s2, s3, s4];
}
function changeAspectRatio() {
if (vertical) {
sixX = horiX;
sixY = horiY;
} else {
sixX = vertX;
sixY = vertY;
}
vertical = !vertical;
for (let i = 0; i < shapes.length; i++) {
for (let j = 0; j < shapes[i].length; j++) {
shapes[i][j].changeXandY(
-stillLifeDim * sixX[i],
-stillLifeDim * sixY[i]
);
}
}
}
function allCenter() {
for (let i = 0; i < shapes.length; i++) {
for (let j = 0; j < shapes[i].length; j++) {
shapes[i][j].changeXandY(-stillLifeDim * 0.5, -stillLifeDim * 0.5);
shapes[i][j].changeScale(3.0);
}
}
}
function allRandom() {
for (let i = 0; i < shapes.length; i++) {
for (let j = 0; j < shapes[i].length; j++) {
shapes[i][j].changeXandY(
-stillLifeDim * r.rb(0, 1),
-stillLifeDim * r.rb(0, 1)
);
shapes[i][j].changeScale(1.5);
}
}
}
function allGrid() {
for (let i = 0; i < shapes.length; i++) {
for (let j = 0; j < shapes[i].length; j++) {
shapes[i][j].changeXandY(
-stillLifeDim * sixX[i],
-stillLifeDim * sixY[i]
);
shapes[i][j].changeScale(1.0);
}
}
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
if (windowWidth > windowHeight && vertical) {
changeAspectRatio();
} else if (windowHeight > windowWidth && !vertical) {
changeAspectRatio();
}
}
function setup() {
createCanvas(windowWidth, windowHeight, WEBGL);
if (windowWidth > windowHeight) {
vertical = false;
} else if (windowHeight > windowWidth) {
vertical = true;
}
r = new RND(seed);
defineColors();
imageMode(CENTER);
gl = document.getElementById("defaultCanvas0").getContext("webgl");
stillLifeDim = rezs[rezIndex];
alphapix = createGraphics(stillLifeDim, stillLifeDim, WEBGL);
pgl = alphapix._renderer.GL;
pgl.disable(gl.DEPTH_TEST);
overlay = createGraphics(1200, 1200);
setupShaders();
doIt();
}
function doIt() {
stillLifeDim = rezs[rezIndex];
alphapix.resizeCanvas(stillLifeDim, stillLifeDim);
setupShapes();
setupGeometry();
createDisplacementMapTexture();
createStillLife();
}
function createGround() {
if (speedIndex != 4) {
angle += 0.0005;
}
let ss = map(sin(angle), -1, 1, 0, 1);
let c1 = lerpColor(sc[0], sc[1], ss);
let c2 = lerpColor(sc[1], sc[2], ss);
let c3 = lerpColor(sc[2], sc[3], ss);
let c4 = lerpColor(sc[3], sc[1], ss);
alphapix.background(255);
alphapix.blendMode(BLEND);
alphapix.beginShape();
alphapix.fill(c1);
alphapix.vertex(-alphapix.width / 2, -alphapix.height / 2);
alphapix.fill(c2);
alphapix.vertex(alphapix.width / 2, -alphapix.height / 2);
alphapix.fill(c3);
alphapix.vertex(alphapix.width / 2, alphapix.height / 2);
alphapix.fill(c4);
alphapix.vertex(-alphapix.width / 2, alphapix.height / 2);
alphapix.endShape();
}
function createStillLife() {
createGround();
if (multiplyOn) {
alphapix.blendMode(MULTIPLY);
} else {
alphapix.blendMode(BLEND);
}
for (let i = 0; i < shapes.length; i++) {
for (let j = 0; j < shapes[i].length; j++) {
shapes[i][j].move();
shapes[i][j].display(alphapix);
}
}
}
function makeOverlay() {
push();
switch (cityNum) {
case 1:
overlay.background(128, 255, 128);
break;
case 2:
overlay.background(204, 204, 255);
break;
case 3:
overlay.background(255, 255, 0);
break;
case 4:
overlay.background(255, 0, 255);
break;
case 5:
overlay.background(0, 255, 255);
break;
case 6:
overlay.background(255, 191, 64);
break;
default:
overlay.background(0);
}
const totalShapes = mostShapeArr.reduce((a, b) => a + b, 0);
const mostUsed = Math.max(...mostShapeArr);
const indices = mostShapeArr.reduce((result, element, index) => {
if (element == mostUsed) {
result.push(index);
}
return result;
}, []);
let totalLinesPx = 568 + 36 + indices.length * 44;
let lineCoord = (1200 - totalLinesPx) / 2;
fill(0, 0, 0);
noStroke();
overlay.textAlign(CENTER, TOP);
overlay.textFont("Arial", 36);
overlay.text("Wallet:", 600, lineCoord);
lineCoord += 44;
overlay.text(all_wallets[walletCount], 600, lineCoord);
lineCoord += 72;
overlay.text("Sets:", 600, lineCoord);
lineCoord += 44;
overlay.text(all_sets[walletCount].join(" "), 600, lineCoord);
lineCoord += 72;
overlay.text(totalShapes.toString() + " Total Shapes: ", 600, lineCoord);
for (let i = 0; i < mostShapeArr.length; i++) {
lineCoord += 44;
if (mostShapeArr[i] == 1) {
overlay.text(
mostShapeArr[i].toString() + " " + shapesNames[i],
600,
lineCoord
);
} else {
overlay.text(
mostShapeArr[i].toString() + " " + shapesNames[i] + "s",
600,
lineCoord
);
}
}
lineCoord += 72;
overlay.text("Most Used Shape:", 600, lineCoord);
if (indices.length > 1) {
for (let iShape = 0; iShape < indices.length; iShape++) {
lineCoord += 44;
if (mostUsed > 1) {
overlay.text(
mostUsed.toString() +
" " +
shapesNames[indices[iShape]].toString() +
"s",
600,
lineCoord
);
} else {
overlay.text(
mostUsed.toString() + " " + shapesNames[indices[iShape]].toString(),
600,
lineCoord
);
}
}
} else {
lineCoord += 44;
overlay.text(
mostUsed.toString() + " " + shapesNames[indices[0]].toString() + "s",
600,
lineCoord
);
}
pop();
}
function draw() {
let scaleFactor = max(width, height) / 1200.0;
if (rezIndex == 2) {
lineThickness = 1.66 * scaleFactor;
lineLength = 3.0 * lengthScalar * scaleFactor;
} else if (rezIndex == 0) {
lineThickness = 3.33 * scaleFactor;
lineLength = 8.0 * lengthScalar * scaleFactor;
} else {
lineThickness = 2.22 * scaleFactor;
lineLength = 12.0 * lengthScalar * scaleFactor;
}
lineDepth = 2 * scaleFactor;
lineSpacing = 2.22 * scaleFactor;
createStillLife();
background(bColor);
push();
setupTransform();
drawLines();
pop();
if (viewDiagram) {
fill(255);
noStroke();
rect(0, 0, -stillLifeDim / 2, -stillLifeDim / 2);
image(alphapix, 0, 0);
}
if (infoOverlay) {
push();
makeOverlay();
rectMode(CENTER);
fill(255);
noStroke();
rect(0, 0, max(width, height) / 3, max(width, height) / 3);
image(overlay, 0, 0, max(width, height) / 3, max(width, height) / 3);
pop();
}
if (speedIndex != 4) {
CDMXSpin++;
}
}
class VShape {
constructor(xin, yin, uin, win) {
this.scale = 1.0;
this.targetScale = 1.0;
this.scaleStep = 0.2;
this.dia = uin * 0.75;
this.mdia = uin * 0.8;
this.rdia = uin * 0.66;
this.ddia = uin * 0.55;
this.tdia = uin * 0.8;
this.tdia2 = uin * 0.7;
this.hu = uin * 0.5;
this.qr1 = uin * 0.3;
this.qr2 = uin * 0.2;
this.sr = uin * 0.4;
this.unit = stillLifeDim;
this.x = xin;
this.y = yin;
this.rx = this.x + (this.unit - this.rdia) / 2;
this.ry = this.y + (this.unit - this.rdia) / 2;
this.cx = this.x + this.unit / 2;
this.cy = this.y + this.unit / 2;
this.cindex = win;
this.sindex = win;
this.movex = r.rb(0, TWO_PI);
this.movey = r.rb(0, TWO_PI);
this.hexx = uin * 0.2;
this.hexy = uin * 0.346;
this.moonAngle = r.rb(0, TWO_PI);
this.moveyval = r.rb(0.0005, 0.002);
this.movexval = r.rb(0.0005, 0.002);
if (r.rb(1) > 0.5) {
this.moveyval *= -1;
}
if (r.rb(1) > 0.5) {
this.movexval *= -1;
}
}
resetScale() {
this.targetScale = 1.0;
}
upScale() {
this.targetScale += this.scaleStep;
}
downScale() {
this.targetScale -= this.scaleStep;
this.targetScale = max(0.0, this.targetScale);
}
changeScale(newScale) {
this.targetScale = newScale;
}
move() {
this.movex += this.movexval * speedScalar;
this.movey += this.moveyval * speedScalar;
this.scale = (this.targetScale - this.scale) * 0.05 + this.scale;
}
changeXandY(xin, yin) {
this.x = xin;
this.y = yin;
this.rx = this.x + (this.unit - this.rdia) / 2;
this.ry = this.y + (this.unit - this.rdia) / 2;
this.cx = this.x + this.unit / 2;
this.cy = this.y + this.unit / 2;
}
display(pg) {
if (this.sindex == 0) {
this.sTokyo(pg);
} else if (this.sindex == 1) {
this.sBerlin(pg);
} else if (this.sindex == 2) {
this.sLondon(pg);
} else if (this.sindex == 3) {
this.sNYC(pg);
} else if (this.sindex == 4) {
this.sCDMX(pg);
} else if (this.sindex == 5) {
this.sLA(pg);
}
}
sTokyo(pg) {
pg.noStroke();
pg.push();
pg.translate(this.cx, this.cy);
pg.scale(this.scale);
pg.rotateY(this.movey);
pg.rotateX(this.movex);
pg.fill(foregrounds[this.cindex]);
pg.ellipse(0, 0, this.dia, this.dia);
pg.pop();
}
sBerlin(pg) {
pg.noStroke();
pg.fill(foregrounds[this.cindex]);
pg.push();
pg.beginShape();
pg.translate(this.cx, this.cy);
pg.scale(this.scale);
pg.rotateX(this.movex);
pg.rotateY(this.movey);
pg.vertex(-this.qr1, -this.hu);
pg.vertex(this.qr1, -this.qr2);
pg.vertex(this.qr1, this.hu);
pg.vertex(-this.qr1, this.qr2);
pg.endShape();
pg.pop();
}
sLondon(pg) {
pg.push();
pg.translate(this.rx + this.rdia / 2, this.ry + this.rdia / 2);
pg.scale(this.scale);
pg.rotateY(this.movey);
pg.rotateX(this.movex);
pg.noStroke();
pg.fill(foregrounds[this.cindex]);
pg.beginShape();
pg.vertex(-this.rdia / 2, -this.rdia / 2);
pg.vertex(this.rdia / 2, -this.rdia / 2);
pg.vertex(this.rdia / 2, this.rdia / 2);
pg.vertex(-this.rdia / 2, this.rdia / 2);
pg.endShape();
pg.pop();
}
sNYC(pg) {
pg.push();
pg.translate(this.rx + this.rdia / 2, this.ry + this.rdia / 2);
pg.scale(this.scale);
pg.rotateY(this.movey);
pg.rotateX(this.movex);
pg.noStroke();
pg.fill(foregrounds[this.cindex]);
pg.beginShape();
pg.vertex(this.hexx, -this.hexy);
pg.vertex(this.hexx * 2, 0);
pg.vertex(this.hexx, this.hexy);
pg.vertex(-this.hexx, this.hexy);
pg.vertex(-this.hexx * 2, 0);
pg.vertex(-this.hexx, -this.hexy);
pg.endShape();
pg.pop();
}
sCDMX(pg) {
pg.push();
pg.translate(this.rx + this.rdia / 2, this.ry + this.rdia / 2.66);
pg.scale(this.scale);
pg.rotateY(this.movey);
pg.rotateX(this.movex);
pg.rotateZ(CDMXSpin / 1000.0);
pg.noStroke();
pg.fill(foregrounds[this.cindex]);
pg.beginShape();
pg.vertex(0, -this.tdia / 2);
pg.vertex(this.tdia / 2, this.tdia2 / 2);
pg.vertex(-this.tdia / 2, this.tdia2 / 2);
pg.endShape();
pg.pop();
}
sLA(pg) {
pg.noStroke();
pg.fill(foregrounds[this.cindex]);
pg.push();
pg.translate(this.cx, this.cy);
pg.scale(this.scale);
pg.rotate(this.moonAngle);
pg.rotateX(this.movex);
pg.rotateY(this.movey);
pg.rotateZ(CDMXSpin / 1000.0);
pg.arc(0, 0, this.mdia, this.mdia, 0.7, TWO_PI - 0.7, CHORD);
pg.pop();
}
}