import React, { useState } from 'react' import { getProps, defaultComponents as patternComponents, } from '@freesewing/react/components/Pattern' import { H5, H6 } from '@freesewing/react/components/Heading' import { KeyVal } from '@freesewing/react/components/KeyVal' import { Highlight } from '@freesewing/react/components/Highlight' import { round, pathLength } from '@freesewing/utils' const coords = (point) => `${point.x},${point.y}` const Cp = ({ at }) => ( ) export const PathXray = ({ stackName, pathName, part, path, settings, components, strings, drillProps = {}, }) => { if (path.hidden) { return null } /* * We use the Path component from Pattern here * If we would extract Path from the components passed down, * we'd create a recursion loop as the Path we call below * would be this very PathXray component. */ const { Path } = patternComponents const { info = {} } = drillProps const output = [] let prev let i = 0 for (const op of path.ops) { if (op.type === 'curve') { output.push( , , ) } prev = op i++ } output.push( , info?.set ? info.set() : null } > ) return ( {output} ) } const PathXrayInfo = ({ path, pathName, stackName }) => { const [rounded, setRounded] = useState(true) const rounder = rounded ? round : (val) => val return (
Path {pathName} of {stackName}
{Object.keys(path.attributes.list).length > 0 ? ( <>
Attributes
{Object.entries(path.attributes.list).map(([k, val]) => ( ))}
) : null}
Dimensions
Type Coordinates
TopLeft
BottomRight
Width
Height
Path Length
Drawing operations
{path.ops.map((op, i) => ( {['move', 'line'].includes(op.type) ? ( ) : null} {op.type === 'close' ? : null} {op.type === 'curve' ? ( ) : null} ))}
Type Coordinates
{op.type} To:
Cp1:
Cp2:
To:
Pathstring
{path.d}
) }