size(300,300);
textSize(50); // 50 號字
text("Hello",10,50); // 預設的字型
PFont font = createFont("Times New Roman",50);
textFont(font); // 換字型
text("Hello",10,100); // 放下面一點點
//print(PFont.list());
for(String name : PFont.list()) println(name);
PFont font1, font2,font3;
void setup(){
size(300,300);
font1 = createFont("Times New Roman Bold Italic",50);
font2 = createFont("微軟正黑體 Bold",50);
font3 = createFont("elffont-rock.otf",50);
}
void draw(){
background(0);
cursor(CROSS);
fill(255);
textFont(font1);
text("Hello 中文",mouseX+20,mouseY-20);
fill(#FF8E8E);
textFont(font2);
text("Hello 中文",mouseX+20,mouseY+50);
textFont(font3);
text("ㄅㄆㄇ",mouseX+20,mouseY+100);
}
void setup(){
size(400,400);
}
float [] angle = new float[5];
void draw(){
background(255);
translate(200, 350);
ellipse(0, 0, 12, 12);
pushMatrix();
rotate(radians(angle[0]));
rect(0, -5, 50, 10);
popMatrix();
}
void mouseDragged(){
angle[0] += mouseX - pmouseX;
}
void setup(){
size(400,400);
}
float [] angle = new float[5];
void draw(){
background(255);
translate(200, 350);
ellipse(0, 0, 12, 12);
pushMatrix();
rotate(radians(angle[0]));
rect(0, -5, 50, 10);
pushMatrix();
translate(50, 0);
rotate(radians(angle[1]));
rect(0, -5, 50, 10);
popMatrix();
popMatrix();
}
void mouseDragged(){
angle[ID] += mouseX - pmouseX;
}
int ID = 0;
void keyPressed(){
if(key=='0') ID = 0;
if(key=='1') ID = 1;
}
void setup(){
size(400, 400);
for(int i=0;i<6;i++){
p[i] = new PVector(200,350-50*i);
}
}
PVector [] p = new PVector[6];
void draw(){
background(255);
for(int i=0;i<6;i++){
if(i>0) line(p[i-1].x,p[i-1].y,p[i].x,p[i].y);
fill(255, 0, 0);
ellipse(p[i].x,p[i].y, 8, 8);
fill(0);
text("p:"+i,p[i].x+10,p[i].y);
}
PVector now = new PVector(mouseX,mouseY);
PVector v = PVector.sub(now,p[4]).normalize().mult(50);
p[5].x = p[4].x + v.x;
p[5].y = p[4].y + v.y;
ellipse(mouseX,mouseY,6,6);
line(p[4].x,p[4].y,mouseX,mouseY);
}
void setup(){
size(400, 400);
for(int i=0;i<N;i++){
p[i] = new PVector(200,350-L*i);
}
}
int N = 20, L = 300 / N;
PVector [] p = new PVector[N];
void draw(){
background(255);
for(int i=0;i<N;i++){
if(i>0) line(p[i-1].x,p[i-1].y,p[i].x,p[i].y);
fill(255, 0, 0);
ellipse(p[i].x,p[i].y, 8, 8);
fill(0);
text("p:"+i,p[i].x+10,p[i].y);
}
PVector now = new PVector(mouseX,mouseY);
p[N-1].x = now.x;
p[N-1].y = now.y;
for(int i=N-2;i>0;i--){
PVector v = PVector.sub(p[i+1],p[i]).normalize().mult(L);
p[i].x = p[i+1].x - v.x;
p[i].y = p[i+1].y - v.y;
}
for(int i=1;i<N;i++){
PVector v = PVector.sub(p[i],p[i-1]).normalize().mult(L);
p[i].x = p[i-1].x + v.x;
p[i].y = p[i-1].y + v.y;
}
ellipse(mouseX,mouseY,6,6);
//line(p[4].x,p[4].y,mouseX,mouseY);
}
沒有留言:
張貼留言