132
edits
No edit summary |
No edit summary |
||
Line 39: | Line 39: | ||
'''Proccessing 1'''(figure moved by potentiemeter) | '''Proccessing 1'''(figure moved by potentiemeter) | ||
import processing.serial.*; | import processing.serial.*; | ||
Serial myPort; | Serial myPort; | ||
int incomingVal; | int incomingVal; | ||
void setup() { | void setup() { | ||
size(1000, 700); | size(1000, 700); | ||
strokeWeight(5); | strokeWeight(5); | ||
smooth(); | smooth(); | ||
println(Serial.list()); | println(Serial.list()); | ||
myPort = new Serial(this,"/dev/tty.usbmodem411",9600); | myPort = new Serial(this,"/dev/tty.usbmodem411",9600); | ||
} | } | ||
void draw() { | void draw() { | ||
background(0); | background(0); | ||
while(myPort.available() > 0){ | while(myPort.available() > 0){ | ||
incomingVal = myPort.read(); | incomingVal = myPort.read(); | ||
println(incomingVal); | println(incomingVal); | ||
} | } | ||
fill(174,221,60); | fill(174,221,60); | ||
ellipse(500,350,250,250); | ellipse(500,350,250,250); | ||
ellipse(385,350,2,2); | ellipse(385,350,2,2); | ||
ellipse(615,350,2,2); | ellipse(615,350,2,2); | ||
ellipse(500,465,2,2); | ellipse(500,465,2,2); | ||
ellipse(500,235,2,2); | ellipse(500,235,2,2); | ||
ellipse(500,350,5,5); | ellipse(500,350,5,5); | ||
float hourAngle = map(incomingVal/12, 0, 255, 0, 360); | float hourAngle = map(incomingVal/12, 0, 255, 0, 360); | ||
pushMatrix(); | pushMatrix(); | ||
translate(500, 350); | translate(500, 350); | ||
rotate(radians(hourAngle*12) - radians(90)); | rotate(radians(hourAngle*12) - radians(90)); | ||
line(0, 0, 100, 0); | line(0, 0, 100, 0); | ||
float speed = dist(mouseX, mouseY, pmouseX, pmouseY); | float speed = dist(mouseX, mouseY, pmouseX, pmouseY); | ||
float diameter = speed * 2.0; | float diameter = speed * 2.0; | ||
fill(204, 221, 80); | fill(204, 221, 80); | ||
ellipse(250, 250, diameter/2, diameter/2); | ellipse(250, 250, diameter/2, diameter/2); | ||
popMatrix(); | popMatrix(); | ||
translate(500, 350); | |||
translate(500, 350); | rotate(radians(hourAngle) - radians(90)); | ||
rotate(radians(hourAngle) - radians(90)); | line(0, 0, 50, 0); | ||
line(0, 0, 50, 0); | } | ||
} | |||
'''Processing 2'''(video play and jump by data) | '''Processing 2'''(video play and jump by data) | ||
import processing.video.*; | import processing.video.*; | ||
Movie myMovie; | Movie myMovie; | ||
import processing.serial.*; | import processing.serial.*; | ||
Serial myPort; | Serial myPort; | ||
int incomingVal; | int incomingVal; | ||
void setup() { | void setup() { | ||
size(640,480,P2D); | size(640,480,P2D); | ||
Line 102: | Line 101: | ||
println(Serial.list()); | println(Serial.list()); | ||
myPort = new Serial(this,"/dev/tty.usbmodem411",9600); | myPort = new Serial(this,"/dev/tty.usbmodem411",9600); | ||
} | } | ||
void movieEvent(Movie myMovie) { | void movieEvent(Movie myMovie) { | ||
myMovie.read(); | myMovie.read(); | ||
} | } | ||
void draw() { | void draw() { | ||
while(myPort.available() > 0){ | while(myPort.available() > 0){ | ||
incomingVal = myPort.read(); | incomingVal = myPort.read(); | ||
Line 116: | Line 115: | ||
} | } | ||
image(myMovie, 0, 0); | image(myMovie, 0, 0); | ||
} | } | ||
void mousePressed(){ | void mousePressed(){ | ||
myMovie.jump(incomingVal); | myMovie.jump(incomingVal); | ||
} | } | ||
edits