AAD

(Algoritmicly Aided Desing)

Monday, June 16, 2014

#FLcreativecoding Week 3, 01 hyperspace transition

/*
 * Creative Coding
 * Week 3, 01 - using map() to map mouse co-ordinates to background colour
 * by Indae Hwang
 * Copyright (c) 2014 Monash University
 *
 * This program allows you to change the background color.
 * Press and hold 'left mouse button' to change color.

 modified by Marius Ivaskevicius
 used HSB color model
 mouseX mapped to H
 mouseY mapped to S
 B is always 255
 special feature "hyperspace transition"
 */
float h;
float s;
float b;
void setup() {
  colorMode(HSB);
  size(500, 500);
  // initialise the colour variables
  h = 0;
  s = 0;
  b = 0;
  background(0);
  noStroke();
  rectMode(CENTER);
}
float speed=1.1;
int skipFrameCounter=0;
int skipFrames=10;
boolean record=false; //enable this to record every 10th frame to files
void draw() {
  fill(h,s,b);
  rect(mouseX,mouseY,20,20);
  PImage c = get();
  tint(255,100);
  image(c, mouseX-mouseX*speed,mouseY-mouseY*speed, width*speed,height*speed);
  h = map(mouseX, 0, width, 0, 255);
  s = map(mouseY, 0, height, 0, 255);
  b = 255;
  if (mousePressed) {
    println("red: "+h+", green: "+s+", blue: "+b);
  }
  if(skipFrameCounter++>skipFrames && record){
    skipFrameCounter=0;
    saveFrame("hs####.jpg");
  }
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home