1.week04_1_PShape_loadShape_shape
// week04_1_PShape_loadShape_shape // google: taiwan svg 下載 svg 檔(檔案總管-檢視-副檔名) //PImage img = loadImage("image.jpg"); //上週教的 //image(img, 0, 0); // week03_1_PImage_loadImage_image size(500, 500); //本周要教的 PShape loadShape shape PShape taiwan = loadShape("Taiwan-icon.svg"); //本周要教的 PShape taiwan2 = loadShape("tw.svg"); //第2張svg檔 shape(taiwan); shape(taiwan2);
2.week04_2_pushMatrix_scale_popMatrix
// week04_2_pushMatrix_scale_popMatrix size(500, 500); PShape taiwan = loadShape("Taiwan-icon.svg"); //本周要教的 PShape taiwan2 = loadShape("tw.svg"); //第2張svg檔 pushMatrix(); scale(10); shape(taiwan2); popMatrix(); pushMatrix(); scale(0.5); shape(taiwan2); popMatrix();
3.week04_3_void_setup_void_draw_void_mouseWheel
// week04_3_void_setup_void_draw_void_mouseWheel PShape taiwan, taiwan2; //宣告變數 void setup(){ size(500, 500); taiwan = loadShape("Taiwan-icon.svg"); taiwan2 = loadShape("tw.svg"); } float taiwanScale = 1; void draw(){ background(#92C2F5); pushMatrix(); scale(10*taiwanScale); shape(taiwan); popMatrix(); pushMatrix(); scale(0.5*taiwanScale); shape(taiwan2); popMatrix(); } void mouseWheel(MouseEvent e){ float d = e.getCount(); if(d>0) taiwanScale *= 1.1; else taiwanScale *= 0.9; }
4.week04_4_world_svg_float_s_scale_s_void_mouseWheel_s
// week04_4_world_svg_float_s_scale_s_void_mouseWheel_s PShape world; void setup(){ size(800, 400); world = loadShape("world.svg"); } float s = 0.4; void draw(){ background(#92C2F5); scale(s); //改用變數s初始值是0.4 shape(world); } void mouseWheel(MouseEvent e){ if(e.getCount()>0) s *= 1.1; else s *= 0.9; }
5.week04_5_world_svg_translate_x_y_void_mouseDragged
// week04_5_world_svg_translate_x_y_void_mouseDragged PShape world; void setup(){ size(800, 400); world = loadShape("world.svg"); } float s = 0.4, x = 0, y = 0; void draw(){ background(#92C2F5); translate(x, y); //要在加上一個移動量 x, y scale(s); //改用變數s初始值是0.4 shape(world); } void mouseDragged(){ x += mouseX - pmouseX; y += mouseY - pmouseY; } void mouseWheel(MouseEvent e){ // mouseWheel if(e.getCount()>0) s *= 1.1; else s *= 0.9; }
6.week04_6_better_scale
// week04_6_better_scale PShape world; void setup(){ size(800, 400); world = loadShape("world.svg"); } float s = 0.4, x = 0, y = 0; float realX = 0, realY = 0; void draw(){ background(#92C2F5); translate(x, y); //要在加上一個移動量 x, y scale(s); //改用變數s初始值是0.4 shape(world); ellipse(realX, realY, 10, 10); } void mouseDragged(){ x += mouseX - pmouseX; y += mouseY - pmouseY; } void mouseWheel(MouseEvent e){ //void mouseWheel(MouseEvent e) realX = (mouseX - x) / s; realY = (mouseY - y) / s; float oldS = s; if(e.getCount()>0) s *= 1.1; else s *= 0.9; x = x + realX*oldS - realX*s; y = y + realY*oldS - realY*s; }
7.week04_7_carrot01_background_stroke_fill_ellipse
// week04_7_carrot01_background_stroke_fill_ellipse size(600, 500); background(0); stroke(255); fill(0); ellipse(50, 50, 100, 100);
8.week04_8_carrot02_void_setup_void_draw_void_mouseDragged
// week04_8_carrot02_void_setup_void_draw_void_mouseDragged void setup(){ size(600, 500); background(0); //黑畫1次 stroke(255); fill(0); } void draw(){ //ellipse(mouseX, mouseY, 100, 100); } void mousePressed(){ //mousePressed ellipse(mouseX, mouseY, 100, 100); }
9.week04_9_carrot03_float_s_mouseButton_LEFT_RIGHT
// week04_9_carrot03_float_s_mouseButton_LEFT_RIGHT void setup(){ size(600, 500); background(0); //黑畫1次 stroke(255); fill(0); } void draw(){ //ellipse(mouseX, mouseY, 100, 100); } float s = 25; void mousePressed(){ //mousePressed ellipse(mouseX, mouseY, s, s); if(mouseButton==LEFT) s *= 1.1; if(mouseButton==RIGHT) s *= 0.9; }
10.week04_a_carrot04_float_t_cos_t_sin_t
// week04_a_carrot04_float_t_cos_t_sin_t void setup(){ size(600, 500); background(0); //黑畫1次 stroke(255); fill(0); } void draw(){ //ellipse(mouseX, mouseY, 100, 100); } float s = 25, t = 0; void mousePressed(){ //mousePressed ellipse(300+200*cos(t), 250+200*sin(t), s, s); t += 0.06; if(mouseButton==LEFT) s *= 1.1; if(mouseButton==RIGHT) s *= 0.9; }
沒有留言:
張貼留言