((In short (if you don't want to read the rest of this post) I'm looking to get the "static final int sqdim = 80;" line of code below to decrease by 10, every 10 seconds). Is this possible?))
It's by a user called Daniel Simionato.
It's a series of simple squares but basically I have taken it and made it bigger (by changing the size resolution). However what I'd really like to do is have the size of the squares (i.e the amount of squares on screen increasing) get smaller in number every 5 or 10 seconds but I'm having trouble figuring out how to do this.
I have made 10 videos altering the size of the square (i.e making them smaller and even increasing the padding) that I could edit together in Final Cut Pro - however it's much less messy is I could just have one long recording of the squares getting smaller and thus increasing the number of squares. Does anyone know how i'd go about doing this?
I'm not looking to take credit for this patch - I'm merely going to record me playing with it and then compose some sounds for it (to play as the recording plays - not interactively).
- static final int sqdim = 80;
- static final int winwidth = 1280;
- static final int winheight = 720;
- static final int numsqrow = (winwidth/sqdim);
- static final int numsqcol = (winheight/sqdim);
- static final int sqpadding = 5;
- static final int fadevel = 10; //fading velocity
- static final int randomness = 255;
- static final int randbase = 16; //base value, to avoid "flashing" squares (squares that change colour too fast)
- static boolean looping = false;
- class MySquare{
- final int xpos;
- final int ypos;
- float randseed;
- float updated = 0;
- float sred = 0;
- float sgreen = 0;
- float sblue = 0;
- float salpha = 255;
- MySquare(int x, int y, float rand){
- xpos = x;
- ypos = y;
- randseed = rand;
- }
- MySquare(){
- xpos = 0;
- ypos = 0;
- randseed = 0;
- }
- final void display(){
- if(updated-randseed > 0){
- sred = random(256) ;
- sgreen = random(256);
- sblue = random(256);
- salpha = random(256);
- fill(sred, sgreen, sblue, salpha);
- rect(xpos, ypos, sqdim-sqpadding, sqdim-sqpadding);
- updated = 0;
- }
- else{
- fill(sred, sgreen, sblue, salpha - (updated+fadevel));
- rect(xpos, ypos, sqdim-sqpadding, sqdim-sqpadding);
- updated++;
- }
- }
- }
- MySquare[][] squares = new MySquare[numsqrow][numsqcol];
- void setup(){
- size(winwidth, winheight, P2D);
- noSmooth();
- background(0.0f, 0.0f, 0.0f);
- PFont font;
- font = loadFont("courier12.vlw");
- textFont(font);
- textMode(SCREEN);
- fill(128.0f, 128.0f, 128.0f, 256);
- String str = "C L I C K T O \nS T A R T / P A U S E" ;
- text(str, winwidth/8, winheight/2);
- noStroke();
- for(int i=0; i<numsqrow; i++){
- for(int j=0; j<numsqcol; j++){
- squares[i][j] = new MySquare(i*sqdim, j*sqdim, random(randomness)+randbase);
- }
- }
- noLoop();
- }
- void draw(){
- if(looping){
- background(0.0f, 0.0f, 0.0f);
- for(int i=0; i<numsqrow; i++){
- for(int j=0; j<numsqcol; j++){
- squares[i][j].display();
- }
- }
- }
- }
- void mousePressed(){
- if(!looping){
- loop();
- looping = true;
- }
- else{
- noLoop();
- looping = false;
- }
- }
1