Browse Source

Improves drawing

main
Steve Ruiz 4 years ago
parent
commit
58c9fc9f83
2 changed files with 13 additions and 9 deletions
  1. 13
    5
      state/sessions/draw-session.ts
  2. 0
    4
      state/state.ts

+ 13
- 5
state/sessions/draw-session.ts View File

@@ -80,17 +80,25 @@ export default class BrushSession extends BaseSession {
80 80
       }
81 81
     }
82 82
 
83
-    // Round the new point (helps keep our data tidy)
83
+    // Low pass the current input point against the previous one
84
+    const nextPrev = vec.med(this.previous, point)
85
+
86
+    // A delta to project the projected point
87
+    const offset = vec.mul(vec.sub(nextPrev, this.previous), 2)
88
+
89
+    this.previous = nextPrev
90
+
91
+    // Generate some temporary points towards a projected point
84 92
     const temporaryPoints = [0.7, 0.9, 0.95, 1].map((v) =>
85 93
       vec.round([
86
-        ...vec.sub(vec.lrp(this.previous, point, v), this.origin),
94
+        ...vec.sub(
95
+          vec.lrp(this.previous, vec.add(point, offset), v),
96
+          this.origin
97
+        ),
87 98
         pressure,
88 99
       ])
89 100
     )
90 101
 
91
-    // Low pass the current input point against the previous one
92
-    this.previous = vec.med(this.previous, point)
93
-
94 102
     // Don't add duplicate points. It's important to test against the
95 103
     // adjusted (low-passed) point rather than the input point.
96 104
 

+ 0
- 4
state/state.ts View File

@@ -19,9 +19,6 @@ import {
19 19
   getShape,
20 20
   screenToWorld,
21 21
   setZoomCSS,
22
-  translateBounds,
23
-  getParentOffset,
24
-  getParentRotation,
25 22
   rotateBounds,
26 23
   getBoundsCenter,
27 24
   getDocumentBranch,
@@ -45,7 +42,6 @@ import {
45 42
   DashStyle,
46 43
   SizeStyle,
47 44
   ColorStyle,
48
-  Bounds,
49 45
 } from 'types'
50 46
 import session from './session'
51 47
 import { pointInBounds } from 'utils/bounds'

Loading…
Cancel
Save