GMU:Einführung ins Programmieren mit Processing/final/Lively Dots

From Medien Wiki
< GMU:Einführung ins Programmieren mit Processing‎ | final
Revision as of 17:55, 17 December 2011 by Ktrin (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Lively Dots

Lively dots is an interactive work that is based on camera input. Movement is detected to control an image, the image is not shown until something moves.

Interaction

  • mouse pressed can pause the video
  • key: s stands for save the picture
  • key: a stands for add the number of the balls
  • key: m stands for minus the number of the balls

Camera

Use library

import JMyron.*;
JMyron m;   //a camera object

Camera Settings

void drawCamera() {
  //get the normal image of the camera
  int[] img = m.differenceImage(); 
  loadPixels();
  //loop through all the pixels
  for (int i=0;i<width*height;i++) { 
    //draw each pixel to the screen 
    pixels[i] = img[i];
  }
  updatePixels();
}

Dots

Initial value

float objx = 320;
float objy = 240;
float objdestx = 320;
float objdesty = 240;

int numBalls = 25600;
float maxVelocity = 16; 
minAccel = 0.8; 
maxAccel = 1.8;

Location of the dots

if (!(avX==0&&avY==0)&&centers.length>0) {
  objdestx = avX;
  objdesty = avY;
}
objx += (objdestx-objx)/10.0f;
objy += (objdesty-objy)/10.0f;
for (int i=0; i<numBalls; i++) {
  ball[i].seek(new PVector(objx, objy));
  ball[i].render();

PROGRAM

File:Processing einfuehrung jin.zip

Processing einfuehrung final jin.jpg