Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // get the x:y position at this ratio (t)
- Point _positionAtBezierRatio(num t, EditableBezierPoint p1, EditableBezierPoint p2) {
- return new Point(_xAtBezierRatio(t, p1, p2), _yAtBezierRatio(t, p1, p2));
- }
- num _xAtBezierRatio(num t, EditableBezierPoint p1, EditableBezierPoint p2) {
- num sX = p1.x;
- num cX1 = p1.cx2;
- num eX = p2.x;
- num cX2 =p2.cx1;
- num xTmp = (pow(1 - t, 3) * sX) +
- (3 * pow(1 - t, 2) * t * cX1) +
- (3 * (1 - t) * pow(t, 2) * cX2) +
- (pow(t, 3) * eX);
- return xTmp;
- }
- num _yAtBezierRatio(num t, EditableBezierPoint p1, EditableBezierPoint p2) {
- num sY = p1.y;
- num cY1 = p1.cy2;
- num eY = p2.y;
- num cY2 =p2.cy1;
- num yTmp = (pow(1 - t, 3) * sY) +
- (3 * pow(1 - t, 2) * t * cY1) +
- (3 * (1 - t) * pow(t, 2) * cY2) +
- (pow(t, 3) * eY);
- return yTmp;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement