// Trail of Gradients and Images // Draws a trail of gradient in a column, where the mouse is pressed. // Author: Byungwook Ethan Yoon // Class: PUDT 1203 Creative Computing int numberOfSquaresHorizontal = 8; int numberOfSquaresVertical = 5; int lengthOfSquares = 100; int windowWidth = numberOfSquaresHorizontal * lengthOfSquares; int windowHeight = numberOfSquaresVertical * lengthOfSquares; int counter = 0; //keeps track of the movement of each block moving down float swap = 255; float store = 255; float [][] grid = new float[numberOfSquaresVertical][numberOfSquaresHorizontal]; PImage [][] imageGrid = new PImage [numberOfSquaresVertical][numberOfSquaresHorizontal]; PImage imageSwap; PImage imageStore; void setup(){ frameRate(10); noStroke(); size(windowWidth, windowHeight); //assigns and draw all arrays with white blocks renew(); } void draw(){ //when mouse is pressed, then the trail of blocks fall in a single column where the cursor is placed. if(mousePressed){ //when mouse cursor stays within the width of the column, then the trail of blocks fall in that column if(floor(mouseX/lengthOfSquares)==floor(pmouseX/lengthOfSquares)){ if(floor(mouseX/lengthOfSquares)%2 == 1){ colorPlacement(floor(mouseX/lengthOfSquares)); drawSquares(floor(mouseX/lengthOfSquares)); } else{ preLoadImages(floor(mouseX/lengthOfSquares), floor(mouseX/lengthOfSquares)); placeImages(floor(mouseX/lengthOfSquares)); } } //when the mouse cursor leaves the column, the trail stops and turns blank else{ renew(); } } //when mouse is released, the trail stops and turns blank else{ renew(); } } //this function assigns color value to the trail of arrays in an assigned column void colorPlacement(int column){ //when the counter is less than or equal to the number of squares vertically, then assign a gradient of blacks if(counter<=numberOfSquaresVertical){ //first block is black, then pushes each block down with the lighter gradient block for(int row=0; row<=counter; row++){ if(row