mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-13 20:24:16 +02:00
rewrite to handler.js format
This commit is contained in:
32
components/sections/pointvectors/handler.js
Normal file
32
components/sections/pointvectors/handler.js
Normal file
@@ -0,0 +1,32 @@
|
||||
module.exports = {
|
||||
setupQuadratic: function(api) {
|
||||
var curve = api.getDefaultQuadratic();
|
||||
api.setCurve(curve);
|
||||
},
|
||||
|
||||
setupCubic: function(api) {
|
||||
var curve = api.getDefaultCubic();
|
||||
api.setCurve(curve);
|
||||
},
|
||||
|
||||
draw: function(api, curve) {
|
||||
api.reset();
|
||||
api.drawSkeleton(curve);
|
||||
|
||||
var i,t,p,tg,n,m,nd=20;
|
||||
for(i=0; i<=10; i++) {
|
||||
t = i/10.0;
|
||||
p = curve.get(t);
|
||||
tg = curve.derivative(t);
|
||||
m = Math.sqrt(tg.x*tg.x + tg.y*tg.y);
|
||||
tg = {x:tg.x/m, y:tg.y/m};
|
||||
n = curve.normal(t);
|
||||
api.setColor("blue");
|
||||
api.drawLine(p, {x:p.x+tg.x*nd, y:p.y+tg.y*nd});
|
||||
api.setColor("red");
|
||||
api.drawLine(p, {x:p.x+n.x*nd, y:p.y+n.y*nd});
|
||||
api.setColor("black");
|
||||
api.drawCircle(p,3);
|
||||
}
|
||||
}
|
||||
};
|
Reference in New Issue
Block a user