js-draw 1.13.2 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -147,7 +147,7 @@ class StrokeSmoother {
147
147
  }
148
148
  let exitingVec = this.computeExitingVec();
149
149
  // Find the intersection between the entering vector and the exiting vector
150
- const maxRelativeLength = 1.7;
150
+ const maxRelativeLength = 2.4;
151
151
  const segmentStart = this.buffer[0];
152
152
  const segmentEnd = newPoint.pos;
153
153
  const startEndDist = segmentEnd.minus(segmentStart).magnitude();
@@ -168,18 +168,11 @@ class StrokeSmoother {
168
168
  if (intersection) {
169
169
  controlPoint = intersection.point;
170
170
  }
171
- // No intersection?
172
- if (!controlPoint) {
173
- // Estimate the control point position based on the entering tangent line
174
- controlPoint = segmentStart
175
- .lerp(segmentEnd, 0.5)
176
- .lerp(segmentStart.plus(enteringVec.times(startEndDist)), 0.25);
177
- }
178
- // Equal to an endpoint?
179
- else if (segmentStart.eq(controlPoint) || segmentEnd.eq(controlPoint)) {
171
+ // No intersection or the intersection is one of the end points?
172
+ if (!controlPoint || segmentStart.eq(controlPoint) || segmentEnd.eq(controlPoint)) {
180
173
  // Position the control point closer to the first -- the connecting
181
174
  // segment will be roughly a line.
182
- controlPoint = segmentStart.plus(enteringVec.times(startEndDist / 5));
175
+ controlPoint = segmentStart.plus(enteringVec.times(startEndDist / 4));
183
176
  }
184
177
  console.assert(!segmentStart.eq(controlPoint, 1e-11), 'Start and control points are equal!');
185
178
  console.assert(!controlPoint.eq(segmentEnd, 1e-11), 'Control and end points are equal!');
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = {
4
- number: '1.13.2',
4
+ number: '1.14.0',
5
5
  };
@@ -144,7 +144,7 @@ export class StrokeSmoother {
144
144
  }
145
145
  let exitingVec = this.computeExitingVec();
146
146
  // Find the intersection between the entering vector and the exiting vector
147
- const maxRelativeLength = 1.7;
147
+ const maxRelativeLength = 2.4;
148
148
  const segmentStart = this.buffer[0];
149
149
  const segmentEnd = newPoint.pos;
150
150
  const startEndDist = segmentEnd.minus(segmentStart).magnitude();
@@ -165,18 +165,11 @@ export class StrokeSmoother {
165
165
  if (intersection) {
166
166
  controlPoint = intersection.point;
167
167
  }
168
- // No intersection?
169
- if (!controlPoint) {
170
- // Estimate the control point position based on the entering tangent line
171
- controlPoint = segmentStart
172
- .lerp(segmentEnd, 0.5)
173
- .lerp(segmentStart.plus(enteringVec.times(startEndDist)), 0.25);
174
- }
175
- // Equal to an endpoint?
176
- else if (segmentStart.eq(controlPoint) || segmentEnd.eq(controlPoint)) {
168
+ // No intersection or the intersection is one of the end points?
169
+ if (!controlPoint || segmentStart.eq(controlPoint) || segmentEnd.eq(controlPoint)) {
177
170
  // Position the control point closer to the first -- the connecting
178
171
  // segment will be roughly a line.
179
- controlPoint = segmentStart.plus(enteringVec.times(startEndDist / 5));
172
+ controlPoint = segmentStart.plus(enteringVec.times(startEndDist / 4));
180
173
  }
181
174
  console.assert(!segmentStart.eq(controlPoint, 1e-11), 'Start and control points are equal!');
182
175
  console.assert(!controlPoint.eq(segmentEnd, 1e-11), 'Control and end points are equal!');
@@ -1,3 +1,3 @@
1
1
  export default {
2
- number: '1.13.2',
2
+ number: '1.14.0',
3
3
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-draw",
3
- "version": "1.13.2",
3
+ "version": "1.14.0",
4
4
  "description": "Draw pictures using a pen, touchscreen, or mouse! JS-draw is a drawing library for JavaScript and TypeScript. ",
5
5
  "types": "./dist/mjs/lib.d.ts",
6
6
  "main": "./dist/cjs/lib.js",
@@ -86,5 +86,5 @@
86
86
  "freehand",
87
87
  "svg"
88
88
  ],
89
- "gitHead": "9a48e4d746783977e2b2808be9d97f3521fb830f"
89
+ "gitHead": "6870036bd8c8160dcb00ded1a4e13b3d9b75071a"
90
90
  }