瀏覽代碼

Improves drawing

main
Steve Ruiz 4 年之前
父節點
當前提交
58c9fc9f83
共有 2 個檔案被更改,包括 13 行新增9 行删除
  1. 13
    5
      state/sessions/draw-session.ts
  2. 0
    4
      state/state.ts

+ 13
- 5
state/sessions/draw-session.ts 查看文件

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
     const temporaryPoints = [0.7, 0.9, 0.95, 1].map((v) =>
92
     const temporaryPoints = [0.7, 0.9, 0.95, 1].map((v) =>
85
       vec.round([
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
         pressure,
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
     // Don't add duplicate points. It's important to test against the
102
     // Don't add duplicate points. It's important to test against the
95
     // adjusted (low-passed) point rather than the input point.
103
     // adjusted (low-passed) point rather than the input point.
96
 
104
 

+ 0
- 4
state/state.ts 查看文件

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

Loading…
取消
儲存