瀏覽代碼

Fixes missing lines in line/ray, fixes dots

main
Steve Ruiz 4 年之前
父節點
當前提交
5b053f7c4e
共有 3 個檔案被更改,包括 16 行新增12 行删除
  1. 8
    5
      components/canvas/misc.tsx
  2. 5
    4
      lib/shape-utils/line.tsx
  3. 3
    3
      lib/shape-utils/ray.tsx

+ 8
- 5
components/canvas/misc.tsx 查看文件

1
-import styled from "styles"
1
+import styled from 'styles'
2
 
2
 
3
-const DotCircle = styled("circle", {
4
-  transform: "scale(var(--scale))",
5
-  strokeWidth: "2",
3
+export const DotCircle = styled('circle', {
4
+  transform: 'scale(var(--scale))',
5
+  fill: '$canvas',
6
+  strokeWidth: '2',
6
 })
7
 })
7
 
8
 
8
-export { DotCircle }
9
+export const ThinLine = styled('line', {
10
+  zStrokeWidth: 1,
11
+})

+ 5
- 4
lib/shape-utils/line.tsx 查看文件

4
 import { registerShapeUtils } from './index'
4
 import { registerShapeUtils } from './index'
5
 import { boundsContained } from 'utils/bounds'
5
 import { boundsContained } from 'utils/bounds'
6
 import { intersectCircleBounds } from 'utils/intersections'
6
 import { intersectCircleBounds } from 'utils/intersections'
7
-import { DotCircle } from 'components/canvas/misc'
7
+import { DotCircle, ThinLine } from 'components/canvas/misc'
8
 import { translateBounds } from 'utils/utils'
8
 import { translateBounds } from 'utils/utils'
9
+import styled from 'styles'
9
 
10
 
10
 const line = registerShapeUtils<LineShape>({
11
 const line = registerShapeUtils<LineShape>({
11
   boundsCache: new WeakMap([]),
12
   boundsCache: new WeakMap([]),
33
   },
34
   },
34
 
35
 
35
   render({ id, direction }) {
36
   render({ id, direction }) {
36
-    const [x1, y1] = vec.add([0, 0], vec.mul(direction, 100000))
37
-    const [x2, y2] = vec.sub([0, 0], vec.mul(direction, 100000))
37
+    const [x1, y1] = vec.add([0, 0], vec.mul(direction, 10000))
38
+    const [x2, y2] = vec.sub([0, 0], vec.mul(direction, 10000))
38
 
39
 
39
     return (
40
     return (
40
       <g id={id}>
41
       <g id={id}>
41
-        <line x1={x1} y1={y1} x2={x2} y2={y2} />
42
+        <ThinLine x1={x1} y1={y1} x2={x2} y2={y2} />
42
         <DotCircle cx={0} cy={0} r={3} />
43
         <DotCircle cx={0} cy={0} r={3} />
43
       </g>
44
       </g>
44
     )
45
     )

+ 3
- 3
lib/shape-utils/ray.tsx 查看文件

4
 import { registerShapeUtils } from './index'
4
 import { registerShapeUtils } from './index'
5
 import { boundsContained } from 'utils/bounds'
5
 import { boundsContained } from 'utils/bounds'
6
 import { intersectCircleBounds } from 'utils/intersections'
6
 import { intersectCircleBounds } from 'utils/intersections'
7
-import { DotCircle } from 'components/canvas/misc'
7
+import { DotCircle, ThinLine } from 'components/canvas/misc'
8
 import { translateBounds } from 'utils/utils'
8
 import { translateBounds } from 'utils/utils'
9
 
9
 
10
 const ray = registerShapeUtils<RayShape>({
10
 const ray = registerShapeUtils<RayShape>({
34
   },
34
   },
35
 
35
 
36
   render({ id, direction }) {
36
   render({ id, direction }) {
37
-    const [x2, y2] = vec.add([0, 0], vec.mul(direction, 100000))
37
+    const [x2, y2] = vec.add([0, 0], vec.mul(direction, 10000))
38
 
38
 
39
     return (
39
     return (
40
       <g id={id}>
40
       <g id={id}>
41
-        <line x1={0} y1={0} x2={x2} y2={y2} />
41
+        <ThinLine x1={0} y1={0} x2={x2} y2={y2} />
42
         <DotCircle cx={0} cy={0} r={3} />
42
         <DotCircle cx={0} cy={0} r={3} />
43
       </g>
43
       </g>
44
     )
44
     )

Loading…
取消
儲存