White Q-Z Logo

qiqi.y.zhou@gmail.com

Pixel by Pixel Final Project

Tools

  • Processing JS

Timeline

  • April 2022 - May 2022

Overview

  • Using the Processing software, I aimed to create an interactive game which allowed the user to draw 3D shapes in space.

Objective

For my final project for Pixel by Pixel taught by Daniel Rozin, we were assigned to create a processing sketch that was interactive. We had a lot of freedom to choose what we wanted to do.

Therefore, I wanted to created a some sort of drawing pad that anyone of any age could understand how to use.

The Proposal

Processing Code

Scroll through to see the whole code!

ArrayList < MarkPoint > brushMarkPoints = new ArrayList < MarkPoint > ();
float canvasRotY;
float canvasRotX;
float xPivot, yPivot;
float hu;int rotatevar = 1;
int sphereSize= 30;void setup() {
 size(1024, 768, P3D);
 colorMode(HSB, 255);
 xPivot = width/2;
 yPivot = height/2;
}void draw() {
 lights();
 pointLight(255, 255, 255, 0, 0, 200);
 directionalLight(51, 102, 126, 0, -1, 0);
 background(0, 0, 50);
 translate(xPivot, yPivot);
 if (keyPressed) {
   if (keyCode == LEFT) {
     canvasRotY-= 0.04;
   }    if (keyCode == RIGHT) {
     canvasRotY += 0.04;
   }    if (keyCode == UP) {
     canvasRotX -= 0.04;
   }    if (keyCode == DOWN) {
     canvasRotX += 0.04;
   }  }  if (rotatevar == 1) {
   canvasRotY += 0;
 }
 if (rotatevar >= 2) {
   canvasRotY += 0.005;
 }  for (MarkPoint brushMarkPoint : brushMarkPoints) {
   brushMarkPoint.render();
 }  if (mousePressed) {
   fill(hu, 100, 255);
   brushMarkPoints.add(new MarkPoint(mouseX - xPivot, mouseY - yPivot, sphereSize));
   hu++;
   if (hu > 255) hu = 0;
 }
}void keyPressed() {  if (key == ' ') {
   rotatevar++;
   if (rotatevar >= 3) {
     rotatevar = 1;
   }
 }
 if (key=='1') {
   sphereSize = 20;
 }
 if (key=='2') {
   sphereSize = 30;
 }
 if (key=='3') {
   sphereSize = 40;
 }
 if (key=='4') {
   sphereSize = 50;
 }
 if (keyCode==ENTER) {
   saveFrame("out/visual####.jpg");
 }
 
}
class MarkPoint {
 // atributes
 float xPos, yPos, yRot, xRot;
 int sphereSize;  // constructer
 MarkPoint(float x, float y, float size) {
   xPos = x;
   yPos = y;
   yRot = canvasRotY;
   xRot = canvasRotX;
   sphereSize = (int) size;
 }  // methods
 void render() {
   pushMatrix();
   noStroke();
   rotateY (canvasRotY - yRot);
   rotateX (canvasRotX - xRot);
   translate(xPos, yPos);
   sphere(sphereSize);
   popMatrix();
 }
}