Skip to content

Commit

Permalink
Merge pull request #102 from nichoth/main
Browse files Browse the repository at this point in the history
fix #101 - diagonal line
  • Loading branch information
jakubfiala authored May 19, 2024
2 parents 9f9c65d + 521885b commit c9ab1b5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
8 changes: 5 additions & 3 deletions dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,10 @@ class Atrament extends AtramentEventTarget {
const procX = x - (x - prevX) * smoothingFactor;
const procY = y - (y - prevY) * smoothingFactor;

// recalculate distance from previous point, this time relative to the
// smoothed coords
// fix line from top left corner
if (prevX === 0 && prevY === 0) return { x: procX, y: procY };

// recalculate distance from previous point, this time relative to the smoothed coords
const dist = lineDistance(procX, procY, prevX, prevY);

// Adaptive stroke allows an effect where thickness changes
Expand Down Expand Up @@ -472,7 +474,7 @@ class Atrament extends AtramentEventTarget {
this.#mouse.set(x, y);
this.#mouse.previous.set(newX, newY);
// Android Chrome sets pressure to constant 1 by default,
// which would break the algorithm
// which would break the algorithm.
// We also handle the case when pressure is 0.
this.#pressure = position.pressure === 1
? DEFAULT_PRESSURE
Expand Down
Loading

0 comments on commit c9ab1b5

Please sign in to comment.