Thursday, December 13, 2007

ICM final

::What's Mine is Yours::

Project Description
:: Sonia Sound Library
* import Sonia Sound Library;
* Sample sound object;
(background music and thunder)
* Start Sonia in Setup();
* Creat new sample objects for sound “airwar.wav” and “t.wav” in Setup();
* Play background music when mousePressed() in draw function;
* Play sound of thunder when keyPressed() in draw function;
* Close sound library;
:: Image
* upload image as background
(background image and picture of lighting)
* display picture of lighting when mousePressed();
:: Text
* String the message “YOURS” at the beginning;
* Load text font inSetup();
* Set 1st character of the text “YOURS” at pixel 380 in draw();
* Use a for loop and CharAt() function to display text character by character in draw();
* Set all characters 14 pixels apart;
* Set random color and textSize in draw();
* Display message “what’s”,”mine” and ”is” separately in draw();
:: Button objects (rainbow)
* initialize Button objects in Setup() by calling constructor which is defined by arguments;
* operate Button object in draw() by calling object methods;
* define a button class
Variables :x,y,width,height;
Constructor
Functions:display()
:: an array for multiple Arc objects as wave
* an array of 1000 Arc objects;
* initialize each Arc object using a for loop in Setup();
* run each Arc object using for loop in draw();
* run fall() when keyPressed();
* define an Arc class
variables: x1,y1,width1,height1;
constructors
function: jiggle(), display(),fall()
:: an array of 1000 drop objects
* initialize each drop object
* run
* define a drop class
variables: xpos,ypos,speed,rainSize
function: fall(),display()
Code
import pitaru.sonia_v2_9.*;
//upload image
PImage img;
PImage img1;
//sample sound object
Sample airwar;
Sample t;
//the message to be displayed
String message="YOURS";
PFont f;
//an array of multiple arc objects
Arc[] arcs=new Arc[1000];
//an array of drop objects
Drop[] drops =new Drop[1000];
int totalDrops=0;

Button myButton1;
Button myButton2;
Button myButton3;
Button myButton4;
Button myButton5;
Button myButton6;
Button myButton7;
Button myButton8;
Button myButton9;
//input the value of stop of each layer of rainbow
int stop=0;

void setup(){
frameRate(20);
size(468,700);
smooth();
Sonia.start(this);
//load background image
img=loadImage("couple.jpg");
img1=loadImage("lighting.jpg");
//load font
f=loadFont("D.vlw");
textFont(f,16);
//creat new samples object 4 sound
airwar= new Sample("airwar.wav");
t=new Sample("t.wav");
//initialize each Arc object using a for loop
for (int i=0;i //x=random(width),y=random(height),width=70,height=50
arcs[i]=new Arc(random(width),650,50,30);
}
//initialize each Drop object using a for loop
for(int i=0;i drops[i]=new Drop();
}
//initialize button objects by calling constructor which is defined with argument
myButton1=new Button(234,220,350,400);
myButton2=new Button(234,220,300,360);
myButton3=new Button(234,220,275,340);
myButton4=new Button(234,220,250,320);
myButton5=new Button(234,220,225,300);
myButton6=new Button(234,220,200,260);
myButton7=new Button(234,220,175,220);
myButton8=new Button(234,220,150,170);
myButton9=new Button(234,220,100,100);
}

void draw(){
background(255);
image(img,0,0);
//the first character starts at pixel 150
int pixel=143;
for(int i=0;i //random color of text
fill(random(255));
textSize(25);
text(message.charAt(i),pixel,380);
//all characters are spaced 10 pixels apart
pixel=pixel+14;
}

//run each Arc object using a for loop
for(int i=0; i arcs[i].display();
arcs[i].jiggle();
}
drops[totalDrops]=new Drop();
totalDrops++;
if(totalDrops>=drops.length){
totalDrops=0;
}
for(int i=0; i drops[i].display();
drops[i].fall();
}
//operate Button object by calling object methods
myButton1.display(mouseX,mouseY);
myButton2.display(mouseX,mouseY);
myButton3.display(mouseX,mouseY);
myButton4.display(mouseX,mouseY);
myButton5.display(mouseX,mouseY);
myButton6.display(mouseX,mouseY);
myButton7.display(mouseX,mouseY);
myButton8.display(mouseX,mouseY);
myButton9.display(mouseX,mouseY);
//draw a white arc to make arcs more rainbow like
noStroke();
fill(255);
arc(234,220,120,100,PI,0);
//display text"WHAT'S MINE IS"
textFont(f,16);
fill(200,200,200);
text("What's",150,330);
text("Mine",161,344);
text("is",175,357);
}

//play airwar while mouse click on the button
void mousePressed(){
if(myButton1.contains(mouseX,mouseY)){
airwar.play();
}

}
void keyPressed(){
tint(255,100);
image(img1,0,0);
for(int i=0;i arcs[i].fall();
}
t.play();
}
public void stop(){
Sonia.stop();
super.stop();
}
//a class to describe button
class Button{
float x;
float y;
float w;
float h;
//button's constructor
Button(float x_,float y_,float w_,float h_){
x=x_;
y=y_;
w=w_;
h=h_;
}
// if a point is inside the play button
boolean contains(float mx,float my){
if (dist(mx,my,x,y)<(w-100)){
return true;
}
else{
return false;
}
}
//display the button
void display(float mx,float my){
float r;
float g;
float b;
if (contains(mx,my)){
r=random(255);
g=random(255);
b=random(255);
fill(r,g,b);
}
else{
fill(119,152,202);
}
noStroke();
arc(x,y,w,h,PI,0);
}
}
//a class to describe arcs
class Arc{
//arcs' variables
float x1;
// float x2;
float y1;
// float y2;
float width1;
float height1;
//arcs' constructor
Arc(float x1_,float y1_,float width1_, float height1_){
x1=x1_;
y1=y1_;
width1=width1_;
height1=height1_;
}
//make arcs jiggle
void jiggle(){
float speed=20;
//change the y and x location of arrows randomly
x1=x1+random(-1,1)*speed;
y1=y1+random(-1,1)*speed;
//constrain arrows in the window
x1=constrain(x1,0,width);
y1=constrain(y1,400,height);
}
//display arcs
void display(){
fill(119,152,202,random(30,70));
strokeWeight(2);
stroke(119,152,202,100);
arc(x1,y1,width1,height1,PI,0);
}
void fall(){
float speed=50;
y1+= speed;
y1=constrain(y1,600,height);
}
}
//a class to describe rain
class Drop{
//drop variables
float xpos;
float ypos;
float speed;
float rainSize;
//drop constructor
Drop(){
rainSize=12;
xpos=random(width);
ypos=-rainSize*4;
speed=random(30,60);
}

void fall(){
ypos += speed;
ypos=constrain(ypos,-50,700);
}
boolean reachedBotton(){
if(ypos>height+rainSize*4){
return true;
}
else{
return false;
}
}
void display(){
fill(119,152,202,100);
noStroke();
for(int i=2;i ellipse(xpos,ypos+i*4,i*0.7,i*0.7);
}
}
}

PCOM final








Comlab final * What r u looking at?

Monday, December 10, 2007

Monday, November 19, 2007

Thursday, November 15, 2007

servo.1

what i could do next

replace flex sensor with sharp rangefinder;

program directly to servo, make servo moves in different range according to distance;

Wednesday, November 14, 2007

what do i do next for my Meow Meow Costume?

1. Get Servo to move in an oscilate pattern.

:: What's Servo?
http://www.seattlerobotics.org/guide/servos.html
http://tigoe.net/pcomp/motors.shtml

:: In what ways Servo moves?
http://flying-pig.co.uk/mechanisms/index.html

:: Related labs
http://itp.nyu.edu/physcomp/Labs/DCMotorControl
http://itp.nyu.edu/physcomp/Labs/Servo

:: This is what I look like













2. Use sharp IR rangefinder as motion sensor (GP2D120)


















:: output voltage dependant on the amount of IR light hitting the detector/corresponding to distance.

:: detecting distance from 4cm to 30cm.

:: examples of using it???

3. More to think about

:: how to place everything in costume to make it wearable and looks normal.

:: user test(very important).

:: keep drawing cute prototype and diagram.
...

Tuesday, November 13, 2007

Friday, September 21, 2007

Wednesday, September 19, 2007

Pcomm observation

my msn space just broke down where i post everything, from lame poetry of mine to london fashion week goodies to Vik's speech this Monday.I open the window and it's cold outside, makes me chill a lilttle bit.



counting digital devices people uses today
:: rm445 on ICM class, everyone was using a mac except me(IBM) and Yaminie(Dell?), oh, and actually Dan was using sth different as well, which he said people would sometimes make fun of, but i can't really remember. In fact, everyone looks like expert because i could hear that sound people made when they were typing really fast. As a slow typer(especially when i'm typing in english), that sounds kind of cool. Guess everyone interact with their laptop pretty well then.


:: we were all looking at the big screen, just like we are now probably, and that's awkward because what i'm writing now is silly and i don't want it to be read on class/in public.
back to the screen, which Dan would show everyone's processing homework to us on, Dan would 1st copy and paste the code to a new window in order to make a little change to it and make it runs better, he always did copy and paste very fast, like in half a second, so that part went well. but when he tried to type sth new, he misspelt the code a lot, even some simple ones like "void" . i think it has something to do with the fact that he's looking at the big screen instead of the screen of his own laptop while typing.


:: i figured it was a good idea to take a note while i was waiting for and on a school bus. when Route A stopped, there were 11 students in line and 6 of them were either on the phone(text message), or listening to ipod(or mp3), and 4 of the 6 were doing both.


:: there was a guy next to me who were on the phone as well. instead of holding his phone, he simply using headphones and left the phone in his pocket. It didn't look too weird though because you can see wire and the little rectangle speaker, then people knew that guy was on the phone. i know this other guy who began to use bluetooth years ago before i have any idea what it is, and it was like he talked to the air or himself all the time. so double check before you think somebody is crazy, he/she might be just on the phone.


:: i also noticed that some people walked around when they were on the phone(me included), and we all know why, you can't handle a mobile phone when you are still.


:: so i was on the bus now, finally. nearly everybody sat alone got music and they just stared at somewhere, and i was the only one looked around...a korean guy in front of me was playing gameboy/psp(?), i wasn't sure, he was so in that game that he sort of ignored the girl who kept talking to him.


:: i looked outside the window, there were ATM, doorman using intercoms, that photo machine(don't know exactly what it's called)


:: something i saw the other day when i walked around was nice and i'd like to mention it here, not sure if it has sth to do with digital though. it was the auto stairs that helped an old lady on wheelchair get off the bus. we don't have that in Beijing and i think we definitely needs it.


:: i met my cousin for dinner and she carried her Pearl and cellphone in her hand all the time, couldn't even put them in her bag. she gets hundreds of email everyday working as a headhunter, so she couldn't live without her pearl. she had a BB before that.


:: passed a church alike architecture on my way home, the girl before me took out her camera and took a picture of it, it was the flash of the camera made the night even creepier, she had this certain gothic look, so that dark church must be really attractive to her, but i just wanted to walk really fast.

i take my camera with me everywhere, so i think i'm going to do observation on that more
p.s. Noriaki's blog reminds me that i played wii last weekend too.