How are offsets calculated? #20
-
Hi, I'm quite amazed how smooth the lines are! I'm quite curious as to how you came up with the formula for calculating the offsets when adding points (link): I noticed that it used to be I tried drawing a few diagrams but it doesn't seem obvious to me how it works (why linearly interpolate the dot product between the two unit vectors?). Also, when drawing caps at a point, why is the offset Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Ah the many weird corners of this algorithm. The answer is generally “lots of trial and error” mixed with “trying everything and seeing what worked”. The first question has to do with pressure: the more pressure, the greater the radius, and so the greater the risk (iirc) of strange corners when a corner is not quite enough to create a cap. You can try the using the old offset code and drawing some upper case “M”s, and see if you can spot the difference. The second question is easier to answer specifically: if we find a sharp corner, then the current vector is thrown out; we need to start the cap using the previous vector (which would have pointed to the current point). |
Beta Was this translation helpful? Give feedback.
Ah the many weird corners of this algorithm. The answer is generally “lots of trial and error” mixed with “trying everything and seeing what worked”.
The first question has to do with pressure: the more pressure, the greater the radius, and so the greater the risk (iirc) of strange corners when a corner is not quite enough to create a cap. You can try the using the old offset code and drawing some upper case “M”s, and see if you can spot the difference.
The second question is easier to answer specifically: if we find a sharp corner, then the current vector is thrown out; we need to start the cap using the previous vector (which would have pointed to the current point).