Thursday, June 05, 2008

Processing Works#2 Cherry Blos.

Processing.js 作品.
マウスイベントとJavascriptを使用した作品です.
マウスで線を描いてください.

Cherry Blos.


size(400, 400);
int cnt=0; //Counter
float trs(float s) {
return 3.5*sqrt(s);
}
boolean fnc(float s, float r) {
if (s<5) {
return s+5 > r;
}
return s*s*4/75+26/3 > r;
}
void setup() {
background(230);
strokeWeight(35);
stroke(180, 120, 0, 80);
}
void mousePressed() {
point(mouseX, mouseY);
}
void mouseDragged() {
int dx=pmouseX-mouseX, dy=pmouseY-mouseY;
float s=sqrt(dx*dx+dy*dy);
s=trs(s);
strokeWeight(35-s)
line(pmouseX, pmouseY, mouseX, mouseY);

float r=random(3,35);
if (fnc(s, r)) {
noStroke();
fill(240, 180, 180, 180);
ellipse(pmouseX+40-random(80), pmouseY+40-random(80), r, r);
}
}
var btn=document.getElementById('button-09-clear');
if (btn) { btn.onclick=function () {setup();} }

0 comments:

Template Design. 2008 Jyun.