Selaa lähdekoodia

adds fill for draw shapes

main
Steve Ruiz 4 vuotta sitten
vanhempi
commit
3cd30869a3
2 muutettua tiedostoa jossa 16 lisäystä ja 6 poistoa
  1. 15
    4
      lib/shape-utils/draw.tsx
  2. 1
    2
      pages/auth-test.tsx

+ 15
- 4
lib/shape-utils/draw.tsx Näytä tiedosto

@@ -40,7 +40,6 @@ const draw = registerShapeUtils<DrawShape>({
40 40
       style: {
41 41
         ...defaultStyle,
42 42
         ...props.style,
43
-        isFilled: false,
44 43
       },
45 44
     }
46 45
   },
@@ -60,7 +59,20 @@ const draw = registerShapeUtils<DrawShape>({
60 59
       )
61 60
     }
62 61
 
63
-    return <path id={id} d={pathCache.get(points)} fill={styles.stroke} />
62
+    return (
63
+      <g id={id}>
64
+        {points.length > 3 &&
65
+          vec.dist(points[0], points[points.length - 1]) < 8 && (
66
+            <polyline
67
+              points={points.map((pt) => pt.slice(0, 2)).join(',')}
68
+              fill={styles.fill}
69
+              stroke="none"
70
+              strokeWidth={0}
71
+            />
72
+          )}
73
+        <path d={pathCache.get(points)} fill={styles.stroke} />
74
+      </g>
75
+    )
64 76
   },
65 77
 
66 78
   getBounds(shape) {
@@ -151,7 +163,6 @@ const draw = registerShapeUtils<DrawShape>({
151 163
 
152 164
   applyStyles(shape, style) {
153 165
     const styles = { ...shape.style, ...style }
154
-    styles.isFilled = false
155 166
     styles.dash = DashStyle.Solid
156 167
     shape.style = styles
157 168
     shape.points = [...shape.points]
@@ -170,7 +181,7 @@ const draw = registerShapeUtils<DrawShape>({
170 181
     return this
171 182
   },
172 183
 
173
-  canStyleFill: false,
184
+  canStyleFill: true,
174 185
 })
175 186
 
176 187
 export default draw

+ 1
- 2
pages/auth-test.tsx Näytä tiedosto

@@ -1,6 +1,5 @@
1 1
 import Head from 'next/head'
2
-import { signIn, signOut, getSession, useSession } from 'next-auth/client'
3
-import { GetServerSidePropsContext } from 'next'
2
+import { signIn, signOut, useSession } from 'next-auth/client'
4 3
 
5 4
 export default function Home() {
6 5
   const [session, loading] = useSession()

Loading…
Peruuta
Tallenna