mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-08-29 02:59:58 +02:00
curve moulding
This commit is contained in:
@@ -2,10 +2,6 @@ var React = require("react");
|
||||
var Graphic = require("../../Graphic.jsx");
|
||||
var SectionHeader = require("../../SectionHeader.jsx");
|
||||
|
||||
var map = function(v, ds,de, ts,te) {
|
||||
return ts + (v-ds)/(de-ds) * (te-ts);
|
||||
};
|
||||
|
||||
var Tracing = React.createClass({
|
||||
getDefaultProps: function() {
|
||||
return {
|
||||
@@ -17,6 +13,7 @@ var Tracing = React.createClass({
|
||||
var curve = api.getDefaultCubic();
|
||||
api.setCurve(curve);
|
||||
api.steps = 8;
|
||||
this.map = curve.getUtils().map;
|
||||
},
|
||||
|
||||
generate: function(api, curve, offset, pad, fwh) {
|
||||
@@ -28,8 +25,8 @@ var Tracing = React.createClass({
|
||||
t = v/100;
|
||||
d = curve.split(t).left.length();
|
||||
pts.push({
|
||||
x: map(t, 0,1, 0,fwh),
|
||||
y: map(d, 0,len, 0,fwh),
|
||||
x: this.map(t, 0,1, 0,fwh),
|
||||
y: this.map(d, 0,len, 0,fwh),
|
||||
d: d,
|
||||
t: t
|
||||
});
|
||||
@@ -111,8 +108,8 @@ var Tracing = React.createClass({
|
||||
}
|
||||
|
||||
ts.forEach(p => {
|
||||
var pt = { x: map(p.t,0,1,0,fwh), y: 0 };
|
||||
var pd = { x: 0, y: map(p.d,0,len,0,fwh) };
|
||||
var pt = { x: this.map(p.t,0,1,0,fwh), y: 0 };
|
||||
var pd = { x: 0, y: this.map(p.d,0,len,0,fwh) };
|
||||
api.setColor("black");
|
||||
api.drawCircle(pt, 3, offset);
|
||||
api.drawCircle(pd, 3, offset);
|
||||
|
Reference in New Issue
Block a user