week15
size(600,600);
PImage img=loadImage("JPG.jpg");
PVector pt=new PVector(10, 20, 0);
image(img, 0, 0);
println(pt.x);
float userX=10, userY=20, userZ=0;
float user2X=30, user2Y=40, user2Z=0;
PVector user=new PVector(10,20,0);
PVector user2=new PVector(30,40,0);
PVector user;
void setup(){
size(600,600);
user=new PVector(10,20);
}
void draw(){
background(255);
ellipse(user.x, user.y,20,20);
}
void setup(){
size(600,600);
user=new PVector(10,20);
}
void draw(){
background(255);
ellipse(user.x, user.y,20,20);
}
PVector user;
PVector Y;
void setup(){
size(600,400);
user=new PVector(100 ,300);
Y=new PVector(100 ,300);
}
void draw(){
background(255);
line(user.x, user.y,Y.x,Y.y);
textSize(40);
fill(255,0,0); text("Y",Y.x,Y.y);
fill(255); ellipse(user.x, user.y,20,20);
}
void mouseDragged(){
user.x=mouseX;
user.y=mouseY;
}
void mouseReleased(){
}
PVector user;
PVector Y, v=null;
void setup(){
size(600,400);
user=new PVector(100 ,300);
Y=new PVector(100 ,300);
}
void draw(){
background(255);
line(user.x, user.y,Y.x,Y.y);
textSize(40);
fill(255,0,0); text("Y",Y.x,Y.y);
fill(255); ellipse(user.x, user.y,20,20);
if(v!=null) user.add(v);
}
void mouseDragged(){
user.x=mouseX;
user.y=mouseY;
}
void mouseReleased(){
PVector diff=PVector.sub(Y,user);
v =diff.div(10);
}
void setup() {
pinMode(2, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
int x = analogRead(A0);
int y = analogRead(A1);
int sw = analogRead(2);
Serial.write(x);
Serial.write('+');
Serial.write(y);
Serial.write('+');
Serial.write(sw);
Serial.write(' ');
delay(20);
}
void setup() {
pinMode(2, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
int x = analogRead(A0);
int y = analogRead(A1);
int sw = analogRead(2);
Serial.write(x/4);
Serial.write(y/4);
Serial.write(sw);
delay(20);
}
import processing.serial.*;
Serial myPort;
void setup(){
size(256,256);
myPort = new Serial(this, "COM3,9600");
}
int ballX=0, ballY=0;
void draw(){
if(myPort.available()>=3){
int x = myPort.read();
int y = myPort.read();
int sw = myPort.read();
ballX=x;
ballY=y;
}
ellipse(ballX, ballY, 10,10);
}




沒有留言:
張貼留言