Skip to content

Commit cbec1a0

Browse files
committed
curve: working on handles -> path rendering
1 parent 5f1c8a9 commit cbec1a0

File tree

3 files changed

+69
-12
lines changed

3 files changed

+69
-12
lines changed

app/build/mojs-curve-editor.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ return /******/ (function(modules) { // webpackBootstrap
7575
/******/ }
7676
/******/
7777
/******/ var hotApplyOnUpdate = true;
78-
/******/ var hotCurrentHash = "0c12eca309296d90b0aa"; // eslint-disable-line no-unused-vars
78+
/******/ var hotCurrentHash = "3082a6b3aa4ce9ad3025"; // eslint-disable-line no-unused-vars
7979
/******/ var hotCurrentModuleData = {};
8080
/******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars
8181
/******/
@@ -3828,17 +3828,43 @@ return /******/ (function(modules) { // webpackBootstrap
38283828
this.CLASSES = __webpack_require__(111);
38293829
__webpack_require__(112);
38303830

3831+
var angleToPoint = function angleToPoint(angle, radius) {
3832+
return mojs.h.getRadialPoint({ angle: angle, radius: radius, center: { x: 0, y: 0 } });
3833+
};
3834+
38313835
var getPath = function getPath() {
38323836
var str = '';
38333837
for (var i = 0; i < _this.points.length; i++) {
38343838
var point = _this.points[i],
38353839
x = point.x + point.tempX,
38363840
y = point.y + point.tempY;
3841+
38373842
if (i === 0) {
3843+
var nextPoint = _this.points[i + 1];
3844+
var xNext = nextPoint.x + nextPoint.tempX,
3845+
yNext = nextPoint.y + nextPoint.tempY;
3846+
38383847
str += 'M' + x + ', ' + y / _constants2.default.CURVE_PERCENT + ' ';
3839-
} else {
3840-
str += 'L' + x + ', ' + y / _constants2.default.CURVE_PERCENT + ' ';
3841-
}
3848+
if (point.type !== 'straight') {
3849+
var handle2 = angleToPoint(point.handle2.angle, point.handle2.radius);
3850+
str += 'C' + (point.x + handle2.x) + ', ' + (point.y / 3.58 + handle2.y / 3.58) + ' ';
3851+
} else {
3852+
str += 'C' + point.x + ', ' + point.y / 3.58 + ' ';
3853+
}
3854+
3855+
if (nextPoint.type !== 'straight') {
3856+
var handle1 = angleToPoint(nextPoint.handle1.angle, nextPoint.handle1.radius);
3857+
str += nextPoint.x + handle1.x + ', ' + (nextPoint.y / 3.58 + handle1.y / 3.58) + ' ';
3858+
} else {
3859+
str += nextPoint.x + ', ' + nextPoint.y / 3.58 + ' ';
3860+
}
3861+
3862+
str += nextPoint.x + ', ' + nextPoint.y / 3.58 + ' ';
3863+
} else {}
3864+
// str += `L${x}, ${y/C.CURVE_PERCENT} ` ;
3865+
3866+
// if ( i === 0) { str += `M${x}, ${y/C.CURVE_PERCENT} `; }
3867+
// else { str += `L${x}, ${y/C.CURVE_PERCENT} ` ; }
38423868
}
38433869
_this.path = str;
38443870
};

0 commit comments

Comments
 (0)