Skip to content

Manually creating paths? #34

Answered by steveruizok
shendrick asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @shendrick, good question! I've also been using the algo to manually create shapes and I often need to create many points between A and B. This is because the algorithm is tuned to the types of points that are generated when drawing, which tend to bunch at the start and end of the line. I've written a helper that I've been using to generate those kinds of points. It is available in @tldraw/vec but here's a snippet you can use, too.

 function add = (A: number[], B: number[]): number[] => {
    return [A[0] + B[0], A[1] + B[1]]
  }

function sub = (A: number[], B: number[]): number[] => {
    return [A[0] - B[0], A[1] - B[1]]
  }

 function mul = (A: number[], n: number): number[] => {

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@shendrick
Comment options

@shendrick
Comment options

@steveruizok
Comment options

@steveruizok
Comment options

Answer selected by steveruizok
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #32 on September 16, 2021 14:24.