adds fill for draw shapes

feature/ste-6-copy-as-svg
Steve Ruiz 2021-06-20 09:29:46 +01:00
rodzic 9de38aa9da
commit 3cd30869a3
2 zmienionych plików z 16 dodań i 6 usunięć

Wyświetl plik

@ -40,7 +40,6 @@ const draw = registerShapeUtils<DrawShape>({
style: {
...defaultStyle,
...props.style,
isFilled: false,
},
}
},
@ -60,7 +59,20 @@ const draw = registerShapeUtils<DrawShape>({
)
}
return <path id={id} d={pathCache.get(points)} fill={styles.stroke} />
return (
<g id={id}>
{points.length > 3 &&
vec.dist(points[0], points[points.length - 1]) < 8 && (
<polyline
points={points.map((pt) => pt.slice(0, 2)).join(',')}
fill={styles.fill}
stroke="none"
strokeWidth={0}
/>
)}
<path d={pathCache.get(points)} fill={styles.stroke} />
</g>
)
},
getBounds(shape) {
@ -151,7 +163,6 @@ const draw = registerShapeUtils<DrawShape>({
applyStyles(shape, style) {
const styles = { ...shape.style, ...style }
styles.isFilled = false
styles.dash = DashStyle.Solid
shape.style = styles
shape.points = [...shape.points]
@ -170,7 +181,7 @@ const draw = registerShapeUtils<DrawShape>({
return this
},
canStyleFill: false,
canStyleFill: true,
})
export default draw

Wyświetl plik

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