Skip to content

Commit 24c67a8

Browse files
committed
curve: add segments rendering
1 parent d643534 commit 24c67a8

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

app/build/mojs-curve-editor.js

Lines changed: 27 additions & 27 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 = "4180f42de19836a486f4"; // eslint-disable-line no-unused-vars
78+
/******/ var hotCurrentHash = "94929f4bc804254be486"; // eslint-disable-line no-unused-vars
7979
/******/ var hotCurrentModuleData = {};
8080
/******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars
8181
/******/
@@ -3798,7 +3798,7 @@ return /******/ (function(modules) { // webpackBootstrap
37983798
/* WEBPACK VAR INJECTION */(function(riot) {
37993799
__webpack_require__(13);
38003800

3801-
riot.tag2('curve', '<div class="{this.CLASSES[\'curve__svg-wrapper\']}" riot-style="{this.styles.transform}"> <point each="{point, _index in points}" points-count="{parent.points.length}"></point> <svg height="358" viewbox="0 0 100 100" preserveaspectratio="none" class="{this.CLASSES[\'curve__svg\']}"> <path riot-d="{this.path}" stroke="#000000" stroke-opacity="1.35" stroke-width="4" vector-effect="non-scaling-stroke" transform="translate(.75,.75)" fill="none"></path> <g id="js-segments"> <path each="{this.segments}" riot-d="{string}" data-index="{index}" stroke="white" stroke-width="" vector-effect="non-scaling-stroke" class="{this.CLASSES[\'curve__svg-segment\']}"></path> </g> </svg> </div>', '', 'class="{this.CLASSES[\'curve\']}" riot-style="{this.styles.background}"', function(opts) {
3801+
riot.tag2('curve', '<div class="{this.CLASSES[\'curve__svg-wrapper\']}" riot-style="{this.styles.transform}"> <point each="{point, _index in points}" points-count="{parent.points.length}"></point> <svg height="358" viewbox="0 0 100 100" preserveaspectratio="none" class="{this.CLASSES[\'curve__svg\']}"> <path riot-d="{this.path}" stroke="#000000" stroke-opacity="0.35" stroke-width="4" vector-effect="non-scaling-stroke" transform="translate(.75,.75)" fill="none"></path> <g id="js-segments"> <path each="{this.segments}" riot-d="{str}" data-index="{index}" stroke="white" fill="none" stroke-width="" vector-effect="non-scaling-stroke" class="{this.CLASSES[\'curve__svg-segment\']}"></path> </g> </svg> </div>', '', 'class="{this.CLASSES[\'curve\']}" riot-style="{this.styles.background}"', function(opts) {
38023802
'use strict';
38033803

38043804
var _this = this;
@@ -3854,29 +3854,45 @@ return /******/ (function(modules) { // webpackBootstrap
38543854
}
38553855

38563856
var str = '';
3857+
var segmentStr = '';
38573858

38583859
var x = point.x + point.tempX,
38593860
y = point.y + point.tempY,
38603861
xNext = nextPoint.x + nextPoint.tempX,
38613862
yNext = nextPoint.y + nextPoint.tempY;
38623863

3864+
var part1 = 'M' + x + ', ' + y / _constants2.default.CURVE_PERCENT + ' ';
38633865
if (i === 0) {
3864-
str += 'M' + x + ', ' + y / _constants2.default.CURVE_PERCENT + ' ';
3866+
str += part1;
38653867
}
3866-
str += getPoint(point, 2);
3867-
str += getPoint(nextPoint, 1);
3868-
str += xNext + ', ' + yNext / _constants2.default.CURVE_PERCENT + ' ';
3868+
segmentStr += part1;
38693869

3870-
return str;
3870+
var part2 = getPoint(point, 2);
3871+
str += part2;
3872+
segmentStr += part2;
3873+
3874+
var part3 = getPoint(nextPoint, 1);
3875+
str += part3;
3876+
segmentStr += part3;
3877+
3878+
var part4 = xNext + ', ' + yNext / _constants2.default.CURVE_PERCENT + ' ';
3879+
str += part4;
3880+
segmentStr += part4;
3881+
3882+
return { str: str, segmentStr: segmentStr };
38713883
};
38723884

38733885
var getPath = function getPath() {
38743886
var str = '';
3887+
_this.segments = [];
38753888
for (var i = 0; i < _this.points.length - 1; i++) {
38763889
var point = _this.points[i],
38773890
nextPoint = _this.points[i + 1];
38783891

3879-
str += getSegment(point, nextPoint, i);
3892+
var segment = getSegment(point, nextPoint, i);
3893+
str += segment.str;
3894+
console.log(i);
3895+
_this.segments.push({ index: i, str: segment.segmentStr });
38803896
}
38813897

38823898
_this.path = str;
@@ -3902,24 +3918,6 @@ return /******/ (function(modules) { // webpackBootstrap
39023918
};
39033919
};
39043920

3905-
var getSegments = function getSegments() {
3906-
_this.segments = [];
3907-
for (var i = 1; i < _this.points.length; i++) {
3908-
var pPoint = _this.points[i - 1],
3909-
point = _this.points[i],
3910-
px = pPoint.x + pPoint.tempX,
3911-
py = pPoint.y + pPoint.tempY,
3912-
x = point.x + point.tempX,
3913-
y = point.y + point.tempY;
3914-
3915-
// const startChar = (i === 1) ? 'M' : 'L'
3916-
_this.segments.push({
3917-
index: i,
3918-
string: 'M' + px + ', ' + py / _constants2.default.CURVE_PERCENT + ' L' + x + ', ' + y / _constants2.default.CURVE_PERCENT
3919-
});
3920-
}
3921-
};
3922-
39233921
var getState = function getState() {
39243922
_this.state = _store2.default.getState();
39253923
};
@@ -3930,7 +3928,7 @@ return /******/ (function(modules) { // webpackBootstrap
39303928
_this.styles = _this.getStyle();
39313929
};
39323930
var get = function get() {
3933-
getState();getPoints();getSegments();getPath();getStyles();
3931+
getState();getPoints();getPath();getStyles();
39343932
};
39353933

39363934
get();
@@ -3951,6 +3949,8 @@ return /******/ (function(modules) { // webpackBootstrap
39513949
y = ev.offsetY * _constants2.default.CURVE_PERCENT,
39523950
index = parseInt(target.getAttribute('data-index'));
39533951

3952+
console.log(index);
3953+
39543954
_store2.default.dispatch({
39553955
type: 'POINT_ADD',
39563956
data: { x: x, y: y, index: index },

0 commit comments

Comments
 (0)