91



size(200,200);
background(0);
int totalPts = 300;
float steps = totalPts + 1;
stroke(255);
float rand = 0;

for(int i = 1; i < steps; i++){
point((width/steps)*i, (height/2)+random(-rand,rand));
rand += random(-5,5);
}

コメント

  1. // P5面白いですね!初めて知りました。
    // 早速本文を改造してみました。
    int i = 1;
    int totalPts = 400/2.5;
    float steps = totalPts + 1;
    float rand = 0;
    void setup() {
    size(400, 400);
    background(0x33,0x99,0x00);
    noFill();
    stroke(0xff,0xff,0x00);
    frameRate(8);
    }
    void draw() {
    py = height - 10 - (height/steps)*i;
    px = (width/2) + random(-rand, rand);
    heart = new Array(5);
    heart[0] = new Array(0,0,1,1,1,1,0,0,0,0);
    heart[1] = new Array(0,0,1,1,1,1,0,0,0,0);
    heart[2] = new Array(1,1,1,1,1,1,1,1,0,0);
    heart[3] = new Array(1,1,1,1,1,1,1,1,0,0);
    heart[4] = new Array(0,0,1,1,1,1,1,1,1,1);
    heart[5] = new Array(0,0,1,1,1,1,1,1,1,1);
    heart[6] = new Array(1,1,1,1,1,1,1,1,0,0);
    heart[7] = new Array(1,1,1,1,1,1,1,1,0,0);
    heart[8] = new Array(0,0,1,1,1,1,0,0,0,0);
    heart[9] = new Array(0,0,1,1,1,1,0,0,0,0);
    for(int k=0; k<10; k++){
    for(int j=0; j<10; j++){
    if(heart[j][k]) point(px+j, py+k);
    }
    }
    rand += random(-16, 16);
    i+=4;
    }

    返信削除
  2. // processing.jsでやってたので、
    // Processing.appで試してみたら
    // 動かないことが分かりました。
    // こちらは本家のP5で動くバージョンです。
    int i = 1;
    float totalPts = 400/2.5;
    float steps = totalPts + 1;
    float rand = 0;
    void setup() {
    size(400, 400);
    background(0x33,0x99,0x00);
    noFill();
    stroke(0xff,0xff,0x00);
    frameRate(8);
    }
    void draw() {
    float py = height - 10 - (height/steps)*i;
    float px = (width/2) + random(-rand, rand);
    int[][] Heart = { {0,0,1,1,1,1,0,0,0,0},
    {0,0,1,1,1,1,0,0,0,0},
    {1,1,1,1,1,1,1,1,0,0},
    {1,1,1,1,1,1,1,1,0,0},
    {0,0,1,1,1,1,1,1,1,1},
    {0,0,1,1,1,1,1,1,1,1},
    {1,1,1,1,1,1,1,1,0,0},
    {1,1,1,1,1,1,1,1,0,0},
    {0,0,1,1,1,1,0,0,0,0},
    {0,0,1,1,1,1,0,0,0,0} };
    for(int k=0; k<10; k++){
    for(int j=0; j<10; j++){
    if(Heart[j][k]==1) point(px+j, py+k);
    }
    }
    rand += random(-16, 16);
    i+=4;
    }
    // 何度もすみません!

    返信削除

コメントを投稿