// week14_1_PFont_createFont_textSize_text
// 學過了 PImage PVector P...
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);
// week14_2_PFont_chinese_font1_font2_font_textFont_cursor
PFont font1, font2, font3;
void setup(){
size(300, 300);
font1 = createFont("Times New RomanBold 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);
}
// week14_3_inverse_kinematics_part1
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[0] += mouseX - pmouseX;
}
int ID = 0;
void keyPressed(){
if(key=='0') ID = 0;
if(key=='1') ID = 1;
}
//week14_4_ik_inverse_kinematics_part1
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;
}
//week14_5_ik_inverse_kinematics_part3
void setup(){
size(400, 400);
for(int i=0; i<2; i++){
p[i] = new PVector(200, 350+50*i);
}
}
PVector [] p = new PVector[6];
void draw(){
background(255);
for(int i=0; i<2; i++){
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);
}
}
//week14_6_ik_inverse_kinematics_part3
void setup(){
size(400, 400);
for(int i=0; i<2; i++){
p[i] = new PVector(200, 350+50*i);
}
}
PVector [] p = new PVector[6];
void draw(){
background(255);
for(int i=0; i<2; 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[0]).normalize().mult(50);
p[1].x = p[0].x + v.x;
p[1].y = p[0].y + v.y;
ellipse(mouseX, mouseY, 6, 6);
line(p[0].x, p[0].y, mouseX, mouseY);
}
//week14_7_ik_inverse_kinematics_part3
void setup(){
size(400, 400);
for(int i=0; i<2; i++){
p[i] = new PVector(200, 350+50*i);
}
}
PVector [] p = new PVector[6];
void draw(){
background(255);
for(int i=0; i<2; 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[0]).normalize().mult(50);
p[1].x = p[0].x + v.x;
p[1].y = p[0].y + v.y;
ellipse(mouseX, mouseY, 6, 6);
line(p[0].x, p[0].y, mouseX, mouseY);
}
//week14_8_ik_inverse_kinematics_part6
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[0]).normalize().mult(50);
p[1].x = p[0].x + v.x;
p[1].y = p[0].y + v.y;
ellipse(mouseX, mouseY, 6, 6);
line(p[0].x, p[0].y, mouseX, mouseY);
}
//week14_9_ik_inverse_kinematics_part6
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[0]).normalize().mult(50);
p[1].x = p[0].x + v.x;
p[1].y = p[0].y + v.y;
ellipse(mouseX, mouseY, 6, 6);
line(p[0].x, p[0].y, mouseX, mouseY);
}
沒有留言:
張貼留言