Procházet zdrojové kódy

adds fill for draw shapes

main
Steve Ruiz před 4 roky
rodič
revize
3cd30869a3
2 změnil soubory, kde provedl 16 přidání a 6 odebrání
  1. 15
    4
      lib/shape-utils/draw.tsx
  2. 1
    2
      pages/auth-test.tsx

+ 15
- 4
lib/shape-utils/draw.tsx Zobrazit soubor

40
       style: {
40
       style: {
41
         ...defaultStyle,
41
         ...defaultStyle,
42
         ...props.style,
42
         ...props.style,
43
-        isFilled: false,
44
       },
43
       },
45
     }
44
     }
46
   },
45
   },
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
   getBounds(shape) {
78
   getBounds(shape) {
151
 
163
 
152
   applyStyles(shape, style) {
164
   applyStyles(shape, style) {
153
     const styles = { ...shape.style, ...style }
165
     const styles = { ...shape.style, ...style }
154
-    styles.isFilled = false
155
     styles.dash = DashStyle.Solid
166
     styles.dash = DashStyle.Solid
156
     shape.style = styles
167
     shape.style = styles
157
     shape.points = [...shape.points]
168
     shape.points = [...shape.points]
170
     return this
181
     return this
171
   },
182
   },
172
 
183
 
173
-  canStyleFill: false,
184
+  canStyleFill: true,
174
 })
185
 })
175
 
186
 
176
 export default draw
187
 export default draw

+ 1
- 2
pages/auth-test.tsx Zobrazit soubor

1
 import Head from 'next/head'
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
 export default function Home() {
4
 export default function Home() {
6
   const [session, loading] = useSession()
5
   const [session, loading] = useSession()

Načítá se…
Zrušit
Uložit