Sfoglia il codice sorgente

Fixes missing lines in line/ray, fixes dots

main
Steve Ruiz 4 anni fa
parent
commit
5b053f7c4e
3 ha cambiato i file con 16 aggiunte e 12 eliminazioni
  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 Vedi File

@@ -1,8 +1,11 @@
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 Vedi File

@@ -4,8 +4,9 @@ import { LineShape, ShapeType } from 'types'
4 4
 import { registerShapeUtils } from './index'
5 5
 import { boundsContained } from 'utils/bounds'
6 6
 import { intersectCircleBounds } from 'utils/intersections'
7
-import { DotCircle } from 'components/canvas/misc'
7
+import { DotCircle, ThinLine } from 'components/canvas/misc'
8 8
 import { translateBounds } from 'utils/utils'
9
+import styled from 'styles'
9 10
 
10 11
 const line = registerShapeUtils<LineShape>({
11 12
   boundsCache: new WeakMap([]),
@@ -33,12 +34,12 @@ const line = registerShapeUtils<LineShape>({
33 34
   },
34 35
 
35 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 40
     return (
40 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 43
         <DotCircle cx={0} cy={0} r={3} />
43 44
       </g>
44 45
     )

+ 3
- 3
lib/shape-utils/ray.tsx Vedi File

@@ -4,7 +4,7 @@ import { RayShape, ShapeType } from 'types'
4 4
 import { registerShapeUtils } from './index'
5 5
 import { boundsContained } from 'utils/bounds'
6 6
 import { intersectCircleBounds } from 'utils/intersections'
7
-import { DotCircle } from 'components/canvas/misc'
7
+import { DotCircle, ThinLine } from 'components/canvas/misc'
8 8
 import { translateBounds } from 'utils/utils'
9 9
 
10 10
 const ray = registerShapeUtils<RayShape>({
@@ -34,11 +34,11 @@ const ray = registerShapeUtils<RayShape>({
34 34
   },
35 35
 
36 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 39
     return (
40 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 42
         <DotCircle cx={0} cy={0} r={3} />
43 43
       </g>
44 44
     )

Loading…
Annulla
Salva