bmcminn / cross-stitch-designer

A web app for designing simple cross stitch patterns and sharing them with your friends
MIT License
0 stars 0 forks source link

feat(tools): add straight stitch and seam ripper tool(s) #20

Open bmcminn opened 3 years ago

bmcminn commented 3 years ago

Add ability to draw straight line stitches between points at corners of stitches

Add ability to remove straight line stitches from design via a seam ripper tool

lineStitch: [
    [ x1, y1, x2, y2, colorId ],
    ...
]

// example:
let [ x1, y1, x2, y2, colorId ] = lineStitch[INDEX]
bmcminn commented 3 years ago

Issue:

Lines are currently drawn based on their start and end coordinates (x1,y1 | x2,y2) which causes a few issues:

  1. it is possible to draw lines on top of lines
    • I can fix this by making lines[] an object list like tiles{} so a given coordinate pair will overwrite a matching coordinate pair
    • I am not currently enforcing coordinate order from origin, so there is no convenient way to overwrite matching inverse pairs...
      • EX: 2,4|10,12 == 10,12|2,4 but my system wouldn't know that without rearranging the coordinate order before pushing to the lines[] array
  2. it is possible for multiple lines to start/end on the same coordinate, making it extremely difficult to pick which line to delete
  3. If I fix issue#1 like I said, I can't think of a performant way to highlight the current line since you can overlap lines without conflicting coordinates
    • EX: line1 = 2,4|10,12 completely overlaps line2 = 5,7|8,10 but it wouldn't be possible to determine which line to delete here...

Interim solution:

Going forward...

It's possible that eventually upgrading the system to D3.js/SVG would be the better option going forward. Vector tooling would simplify scaling, and native hover event targets would make identifying lines to delete easier... not to mention being able to adjust existing geometry