このウィキの読者になる
更新情報がメールで届きます。
このウィキの読者になる
カテゴリー
最近更新したページ
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

Processing5 Drawing

/*--Drawing--*/
void setup() {
size(200, 200); background(102); }

void draw() { stroke(255); if(mousePressed) { line(mouseX, mouseY, pmouseX, pmouseY); } }
void setup()
{
size(200, 200); background(102); smooth(); }

void draw() { // Call the variableEllipse() method and send it the // parameters for the current mouse position // and the previous mouse position variableEllipse(mouseX, mouseY, pmouseX, pmouseY); }


// The simple method variableEllipse() was created specifically // for this program. It calculates the speed of the mouse // and draws a small ellipse if the mouse is moving slowly // and draws a large ellipse if the mouse is moving quickly

void variableEllipse(int x, int y, int px, int py) { float speed = abs(x-px) + abs(y-py); stroke(speed); ellipse(x, y, speed, speed); }
int dots = 1000;
float[] dX = new float[dots];
float[] dY = new float[dots];

float l_0 = 0.0;
float h_0 = 0.0;

float legX = 0.0;
float legY = 0.0;
float thighX = 0.0;
float thighY = 0.0;

float l = 30.0; // Length of the 'leg'
float h = 60.0; // Height of the 'leg'

float nmx, nmy = 0.0;
float mx, my = 0.0;

float offset;

int currentValue = 0;
int valdir = 1;

void setup()
{
size(200, 200); noStroke(); fill(102); rect(0, 0, width, height); offset = width/2; }

void draw() { // Smooth the mouse nmx = mouseX; nmy = mouseY; if((abs(mx - nmx) > 1.0) || (abs(my - nmy) > 1.0)) { mx = mx - (mx-nmx)/20.0; my = my - (my-nmy)/20.0; // Set the drawing value currentValue += 1* valdir; if(currentValue > 255 || currentValue <= 0) { valdir *= -1; } }

iKinematics(); kinematics(); pushMatrix(); translate(offset, offset); stroke(currentValue); line(thighX, thighY, legX, legY); popMatrix(); stroke(255); point(legX+offset, legY+offset); }

void kinematics() { thighX = h*cos(h_0); thighY = h*sin(h_0); legX = thighX + l*cos(h_0 - l_0); legY = thighY + l*sin(h_0 - l_0); }

void iKinematics() { float tx = mx - width/2.0; float ty = my - height/2.0; float c2 = (tx*tx + ty*ty - h*h - l*l)/(2*h*l); //in degrees float s2 = sqrt(abs(1 - c2*c2)); // the sign here determines the bend in the joint l_0 = -atan2(s2, c2); h_0 = atan2(ty, tx) - atan2(l*s2, h+l*c2); }
2006年11月16日(木) 11:48:53 Modified by notarejini06




スマートフォン版で見る