Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ガイダンス - Bio Media Art Workshopについて Processingの復習

ガイダンス - Bio Media Art Workshopについて Processingの復習

Atsushi Tadokoro

June 02, 2014
Tweet

More Decks by Atsushi Tadokoro

Other Decks in Technology

Transcript

  1. ৭ ‣ എܠ৭ ‣ CBDLHSPVOE (SBZ άϨΠεέʔϧ ‣ CBDLHSPVOE 3

    ( # 3(# ‣ CBDLHSPVOE 3 ( # " 3(#" ˞"͸ಁ໌౓  ! ‣ ృΓͷ৭ ‣ pMM (SBZ  ‣ pMM 3 ( #  ‣ pMM 3 ( # "  ! ‣ ڥքઢͷ৭ ‣ TUSPLF (SBZ  ‣ TUSPLF 3 ( #  ‣ TUSPLF 3 ( # " 
  2. جຊਤܗ ‣ ৭Λࢦఆͯ͠ΈΔ background(15); //എܠ৭ stroke(63,191,255); //ઢͷ৭ fill(0,127,255,127); //ృΓͷ৭ size(640,

    480); //640x480pixelͷը໘Λੜ੒ point(300, 200); //(300,200)ͷ৔ॴʹ఺Λඳ͘ line(50, 100, 400, 300); //(50,100)ͷ఺͔Β(400,300)ͷ఺΁ઢΛҾ͘ rect(400, 100, 100, 300); //(400,100)ͷ఺͔Βɺ෯100ɺߴ͞300ͷ࢛֯ܗΛඳ͘ ellipse(200, 340, 300, 200); //(200,340)ͷ఺Λத৺ʹɺ෯300ɺߴ͞200ͷପԁΛඳ͘
  3. Ξχϝʔγϣϯ ‣ ྫԁ͕Ҡಈ͢ΔΞχϝʔγϣϯ PVector location; //ҐஔͷϕΫτϧ PVector velocity; //଎౓ͷϕΫτϧ !

    void setup() { size(640, 480); //640x480pixelͷը໘Λੜ੒ frameRate(60); //ϑϨʔϜϨʔτ stroke(63, 191, 255); //ઢͷ৭ fill(0, 127, 255, 127); //ృΓͷ৭ location = new PVector(40, 40); //ҐஔͷϕΫτϧͷॳظઃఆ velocity = new PVector(3, 2); //଎౓ͷϕΫτϧͷॳظઃఆ } !
  4. Ξχϝʔγϣϯ ‣ ྫԁ͕Ҡಈ͢ΔΞχϝʔγϣϯ void draw() { background(15); //എܠΛඳը ellipse(location.x, location.y,

    20, 20); //ࢦఆͨ͠ҐஔʹԁΛඳը location.add(velocity); //ҐஔͷϕΫτϧʹ଎౓ͷϕΫτϧΛՃࢉɺ࣍ͷҐஔʹͳΔ if ((location.x > width) || (location.x < 0)) { //΋͠ը໘ͷࠨ·ͨ͸ӈ୺ʹ౸ୡͨ͠Β velocity.x *= -1; //Xํ޲ͷεϐʔυΛ൓స } if ((location.y > height) || (location.y < 0)) { //΋͠ը໘ͷԼ·ͨ͸্୺ʹ౸ୡͨ͠Β velocity.y *= -1; //Yํ޲ͷεϐʔυΛ൓స } }
  5. ͘Γฦ͠ʹΑΔ૿৩ ‣ Ґஔ MPDBUJPO ɺ଎౓ WFMPDJUZ ΛͦΕͧΕ഑ྻʹมߋ int NUM =

    100; //഑ྻͷ਺ PVector[] location = new PVector[NUM]; //ҐஔͷϕΫτϧͷ഑ྻ PVector[] velocity = new PVector[NUM]; //଎౓ͷϕΫτϧͷ഑ྻ</p> ! void setup() { size(640, 480); //640x480pixelͷը໘Λੜ੒ frameRate(60); //ϑϨʔϜϨʔτ stroke(63, 191, 255); //ઢͷ৭ fill(0, 127, 255, 127); //ృΓͷ৭ for (int i = 0; i < NUM; i++) { //഑ྻͷ਺͚ͩ܁Γฦ͠ location[i] = new PVector(random(width), random(height)); //ҐஔͷϕΫτϧ velocity[i] = new PVector(random(-4, 4), random(-4, 4)); //଎౓ͷϕΫτϧ } }
  6. ͘Γฦ͠ʹΑΔ૿৩ ‣ Ґஔ MPDBUJPO ɺ଎౓ WFMPDJUZ ΛͦΕͧΕ഑ྻʹมߋ void draw() {

    background(15); //എܠΛඳը for (int i = 0; i < NUM; i++) { //഑ྻͷ਺͚ͩ܁Γฦ͠ ellipse(location[i].x, location[i].y, 20, 20); //ࢦఆͨ͠ҐஔʹԁΛඳը location[i].add(velocity[i]); //ҐஔͷϕΫτϧʹ଎౓ͷϕΫτϧΛՃࢉɺ࣍ͷҐஔʹͳΔ if ((location[i].x > width) || (location[i].x < 0)) { velocity[i].x *= -1; //Xํ޲ͷεϐʔυΛ൓స } if ((location[i].y > height) || (location[i].y < 0)) { velocity[i].y *= -1; //Yํ޲ͷεϐʔυΛ൓స } } }
  7. ͘Γฦ͠ʹΑΔ૿৩ ‣ Ґஔ MPDBUJPO ɺ଎౓ WFMPDJUZ ɺ৭ DPM ɺେ͖͞ EJBNFUFS

    ΛϥϯμϜʹ int NUM = 500; //഑ྻͷ਺ PVector[] location = new PVector[NUM]; //ҐஔͷϕΫτϧͷ഑ྻ PVector[] velocity = new PVector[NUM]; //଎౓ͷϕΫτϧͷ഑ྻ color[] col = new color[NUM]; //ృΓͷ৭ͷ഑ྻ float[] diameter = new float[NUM]; //ԁͷେ͖͞(௚ܘ)ͷ഑ྻ</p> ! void setup() { size(640, 480); //640x480pixelͷը໘Λੜ੒ frameRate(60); //ϑϨʔϜϨʔτ noStroke(); for (int i = 0; i < NUM; i++) { //഑ྻͷ਺͚ͩ܁Γฦ͠ location[i] = new PVector(random(width), random(height)); //ҐஔͷϕΫτϧͷॳظઃఆ velocity[i] = new PVector(random(-4, 4), random(-4, 4)); //଎౓ͷϕΫτϧͷॳظઃఆ col[i] = color(random(255), random(255), random(255), 127); //৭ͷॳظઃఆ diameter[i] = random(3, 40); //େ͖͞ͷॳظઃఆ } }
  8. ͘Γฦ͠ʹΑΔ૿৩ ‣ Ґஔ MPDBUJPO ɺ଎౓ WFMPDJUZ ɺ৭ DPM ɺେ͖͞ EJBNFUFS

    ΛϥϯμϜʹ void draw() { background(15); //എܠΛඳը for (int i = 0; i < NUM; i++) { //഑ྻͷ਺͚ͩ܁Γฦ͠ fill(col[i]); //৭Λࢦఆ ellipse(location[i].x, location[i].y, diameter[i], diameter[i]); //ࢦఆͨ͠ҐஔʹԁΛඳը location[i].add(velocity[i]); //ҐஔͷϕΫτϧʹ଎౓ͷϕΫτϧΛՃࢉɺ࣍ͷҐஔʹͳΔ if ((location[i].x > width) || (location[i].x < 0)) { //΋͠ը໘ͷࠨӈ୺ʹ౸ୡͨ͠Β velocity[i].x *= -1; //Xํ޲ͷεϐʔυΛ൓స } if ((location[i].y > height) || (location[i].y < 0)) { //΋͠ը໘ͷ্Լ୺ʹ౸ୡͨ͠Β velocity[i].y *= -1; //Yํ޲ͷεϐʔυΛ൓స } } }