1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-02 12:54:23 +02:00

graphics-api docs

This commit is contained in:
Pomax
2020-09-19 12:29:43 -07:00
parent 7bf5a223bf
commit 7c530fee56
31 changed files with 420 additions and 103 deletions

View File

@@ -33,7 +33,7 @@ drawSlices(w, h, a, n) {
let area = 0;
let step = w/n;
for(let i=0, f=TAU/w, c, y; i<w; i += step) {
c = `rgba(150,150,255,${0.4 + 0.3 * random()}`;
c = `rgba(150,150,255,${random(0.4, 0.7)}`;
if (n > 50) setStroke(c);
setFill(c);
y = sin((i+step/2) * f) * a;

View File

@@ -25,7 +25,7 @@ draw() {
noStroke();
setFill(`rgba(100,255,100,0.4)`);
let a = this.angle;
arc(w/2, h/2, r, a < 0 ? a : 0, a < 0 ? 0 : a, w/2, h/2);
wedge(w/2, h/2, r, a < 0 ? a : 0, a < 0 ? 0 : a);
curve.drawSkeleton();
curve.drawCurve();

View File

@@ -26,7 +26,7 @@ draw() {
noStroke();
setFill(`rgba(100,255,100,0.4)`);
let a = this.angle;
arc(w/2, h/2, r, a < 0 ? a : 0, a < 0 ? 0 : a, w/2, h/2);
wedge(w/2, h/2, r, a < 0 ? a : 0, a < 0 ? 0 : a);
guess.drawSkeleton(`lightblue`);
guess.drawCurve(`lightblue`);

View File

@@ -53,7 +53,7 @@ computeCurvature(curve, t) {
dd = curve.dderivative(t),
num = d.x * dd.y - d.y * dd.x,
qdsum = d.x * d.x + d.y * d.y,
dnm = pow(qdsum, 3 / 2);
dnm = qdsum ** 3/2;
if (num === 0 || dnm === 0) return 0;

View File

@@ -5,8 +5,8 @@ setup() {
h = this.height;
for (let i=0; i<10; i++) {
points.push({
x: w/2 + random() * 20 + cos(PI*2 * i/10) * (w/2 - 40),
y: h/2 + random() * 20 + sin(PI*2 * i/10) * (h/2 - 40)
x: w/2 + random(20) + cos(PI*2 * i/10) * (w/2 - 40),
y: h/2 + random(20) + sin(PI*2 * i/10) * (h/2 - 40)
});
}
setMovable(points);