Bitmap/Bézier curves/Cubic: Difference between revisions
→{{header|Processing}}
Line 1,092:
It can be run on line [https://www.openprocessing.org/sketch/846556/ here.]
<lang>
float[]x = new float[4];
float[]y = new float[4];
Line 1,100 ⟶ 1,099:
size(300, 300);
smooth();
//
x[0] = x[1] = 50;
y[1] = y[
y[
▲ }
}
Line 1,116 ⟶ 1,111:
background(255);
noFill();
▲ stroke(0, 30, 200);
bezier (x[1], y[1], x[0], y[0], x[3], y[3], x[2], y[2]);
//
strokeWeight(1);
stroke(100);
line(x[0], y[0], x[1], y[1]);
line(x[2], y[2], x[3], y[3]);
//
stroke(0);
fill(0);
Line 1,131 ⟶ 1,125:
fill(255, 100, 10);
rectMode(CENTER);
rect(x[i], y[i],
} else {
fill(0);
ellipse(x[i], y[i],
}
}
//
for (int i =0; i< 4; i++) {
if (permitDrag[i]) {
Line 1,147 ⟶ 1,141:
}
void mouseReleased () {
for (int i =0; i< 4; i++) {
Line 1,154 ⟶ 1,147:
}
void mousePressed () {
for (int i =0; i< 4; i++) {
if (mouseX>=x[i]-5 && mouseX<=x[i]+
permitDrag[i] = true;
}
Line 1,164 ⟶ 1,155:
}
//
void mouseMoved () {
cursor(ARROW);
for (int i =0; i< 4; i++) {
if (mouseX>=x[i]-5 && mouseX<=x[i]+
mouseY>=y[i]-5 && mouseY<=y[i]+
cursor(HAND);
}
|