このウィキの読者になる
更新情報がメールで届きます。
このウィキの読者になる
カテゴリー
最近更新したページ
2011-12-05
2010-02-05
2008-01-31
2007-12-09
2007-11-22
2007-11-04
2007-10-06
2007-05-17
2007-05-13
2007-05-11
2007-05-10
最新コメント
1-14 by awesome things!
117 by stunning seo guys
Processing4 Data by stunning seo guys
送信ボタンの仕組み by stunning seo guys
511 by stunning seo guys
510 by music production software
ProStr by awesome things!
FrontPage by check it out
CSV形式とは by check it out
Menu

Processing9 Motion

/*--Motion--*/
float a = 100;

void setup()
{
size(200, 200); stroke(255); frameRate(30);
}

void draw()
{
background(51); a = a - 1; if (a < 0) { a = height; } line(0, a, width, a);
}
int size = 60; // Width of the shape
float xpos, ypos; // Starting position of shape

float xspeed = 2.8; // Speed of the shape
float yspeed = 2.2; // Speed of the shape

int xdirection = 1; // Left or Right
int ydirection = 1; // Top to Bottom


void setup()
{
size(200, 200); noStroke(); frameRate(30); smooth(); // Set the starting position of the shape xpos = width/2; ypos = height/2;
}

void draw()
{
background(102); // Update the position of the shape xpos = xpos + ( xspeed * xdirection ); ypos = ypos + ( yspeed * ydirection ); // Test to see if the shape exceeds the boundaries of the screen // If it does, reverse its direction by multiplying by -1 if (xpos > width-size || xpos < 0) { xdirection *= -1; } if (ypos > height-size || ypos < 0) { ydirection *= -1; }

// Draw the shape ellipse(xpos+size/2, ypos+size/2, size, size);
}
int size = 8;
int legth = 50;

int aSize; // Height of the shape
float aPos; // Position of shape
float aSpeed; // Speed of the shape
int aDirection = 1; // Left or Right

float bPos;
float bSpeed;
int bDirection = 1;

float cPos;
float cSpeed;
int cDirection = 1;

float dPos;
float dSpeed;
int dDirection = 1;


void setup()
{
size(200, 200); noStroke(); frameRate(60); aPos = bPos = cPos = dPos = width/2;
}

void draw()
{
background(102); fill(255);

aSpeed = squared(aPos/float(width-size)) * 2.0; aPos = aPos + ((aSpeed*2.0+0.5) * aDirection ); if (aPos > width-size || aPos < 0) { aDirection = aDirection * -1; } rect(aPos, 0, size, 50); bSpeed = quad(bPos/float(width-size)) * 2.0; bPos = bPos + ((bSpeed*2.0+0.5) * bDirection ); if (bPos > width-size || bPos < 0) { bDirection = bDirection * -1; } rect(bPos, 50, size, 50); cSpeed = hump(cPos/float(width-size)) * 2.0; cPos = cPos + ((cSpeed*2.0+0.5) * cDirection ); if (cPos > width-size || cPos < 0) { cDirection = cDirection * -1; } rect(cPos, 100, size, 50); dSpeed = quadHump(dPos/float(width-size)) * 2.0; dPos = dPos + ((dSpeed*2.0+0.5) * dDirection ); if (dPos > width-size || dPos < 0) { dDirection = dDirection * -1; } rect(dPos, 150, size, 50);
}

float quad(float sa) {
return sa*sa*sa*sa;
}

float quadHump(float sa) {
sa = (sa - 0.5); //scale from -2 to 2 sa = sa*sa*sa*sa * 16; return sa;
}

float hump(float sa) {
sa = (sa - 0.5) * 2; //scale from -2 to 2 sa = sa*sa; if(sa > 1) { sa = 1; } return 1-sa;
}

float squared(float sa) {
sa = sa*sa; return sa;
}

int e1_size = 18;
float e1_x, e1_y = 0;
float e1_speed = 1.0;
int e1_direction = 1;

int e2_size = 10;
float e2_x, e2_y = 0;
float e2_speed = 0.80;
int e2_direction = 1;

int e3_size = 14;
float e3_x, e3_y = 0;
float e3_speed = 0.65;
int e3_direction = 1;


void setup()
{
size(200, 200); stroke(102); smooth(); frameRate(30);
}

void draw()
{
background(0); stroke(102); beginShape(); for(int i=0; i<width; i++) { vertex(i, singraph((float)i/width)*height); } endShape(); beginShape(); for(int i=0; i<width; i++) { vertex(i, quad((float)i/width)*height); } endShape(); beginShape(); for(int i=0; i<width; i++) { vertex(i, hump((float)i/width)*height); } endShape(); e1_x += e1_speed * e1_direction; if (e1_x > width || e1_x < 0) { e1_direction = e1_direction * -1; } e1_y = singraph((float)e1_x/width)*height; noStroke(); fill(255); ellipse(e1_x, e1_y, e1_size, e1_size); e2_x += e2_speed * e2_direction; if (e2_x > width || e2_x < 0) { e2_direction = e2_direction * -1; } e2_y = quad((float)e2_x/width)*height; noStroke(); fill(255); ellipse(e2_x, e2_y, e2_size, e2_size); e3_x += e3_speed * e3_direction; if (e3_x > width || e3_x < 0) { e3_direction = e3_direction * -1; } e3_y = hump((float)e3_x/width)*height; noStroke(); fill(255); ellipse(e3_x, e3_y, e3_size, e3_size);
}

float singraph(float sa) {
sa = (sa - 0.5) * 1.0; //scale from -1 to 1 sa = sin(sa*PI)/2 + 0.5; return sa;
}

float quad(float sa) {
return sa*sa*sa*sa;
}

float hump(float sa) {
sa = (sa - 0.5) * 2; //scale from -2 to 2 sa = sa*sa; if(sa > 1) { sa = 1; } return 1-sa;
}

int num = 2000;
int range = 4;

float[] ax = new float[num];
float[] ay = new float[num];


void setup()
{
size(200, 200); for(int i=0; i<num; i++) { ax[i] = 50; ay[i] = height/2; } frameRate(30);
}

void draw()
{
background(51); // Shift all elements 1 place to the left for(int i=1; i<num; i++) { ax[i-1] = ax[i]; ay[i-1] = ay[i]; }

// Put a new value at the end of the array ax[num-1] += random(-range, range); ay[num-1] += random(-range, range);

// Constrain all points to the screen ax[num-1] = constrain(ax[num-1], 0, width); ay[num-1] = constrain(ay[num-1], 0, height); // Draw a line connecting the points for(int i=1; i<num; i++) { float val = float(i)/num * 204.0 + 51; stroke(val); line(ax[i-1], ay[i-1], ax[i], ay[i]); }
}

float ball_x;
float ball_y;
float ball_dir = 1;
float ball_size = 5; // Radius
float dy = 0; // Direction

int paddle_width = 5;
int paddle_height = 20;

int dist_wall = 15;

void setup()
{
size(200, 200); rectMode(CENTER_RADIUS); ellipseMode(CENTER_RADIUS); noStroke(); smooth(); ball_y = height/2; ball_x = 1;
}

void draw()
{
background(51); ball_x += ball_dir * 1.0; ball_y += dy; if(ball_x > width+ball_size) { ball_x = -width/2 - ball_size; ball_y = random(0, height); dy = 0; } // Constrain paddle to screen float paddle_y = constrain(mouseY, paddle_height, height-paddle_height);

// Test to see if the ball is touching the paddle float py = width-dist_wall-paddle_width-ball_size; if(ball_x == py && ball_y > paddle_y - paddle_height - ball_size && ball_y < paddle_y + paddle_height + ball_size) { ball_dir *= -1; if(mouseY != pmouseY) { dy = (mouseY-pmouseY)/2.0; if(dy > 5) { dy = 5; } if(dy < -5) { dy = -5; } } } // If ball hits paddle or back wall, reverse direction if(ball_x < ball_size && ball_dir == -1) { ball_dir *= -1; } // If the ball is touching top or bottom edge, reverse direction if(ball_y > height-ball_size) { dy = dy * -1; } if(ball_y < ball_size) { dy = dy * -1; }

// Draw ball fill(255); ellipse(ball_x, ball_y, ball_size, ball_size); // Draw the paddle fill(153); rect(width-dist_wall, paddle_y, paddle_width, paddle_height);
}
2006年11月18日(土) 10:39:28 Modified by ID:hElD8hu5PA




スマートフォン版で見る