Closed typemytype closed 5 years ago
@typemytype this is amazing. Thanks much! I did feel like it was bloated, and I was gonna spend some time refactoring, so this is really helpful. I'll try to integrate what you wrote.
This is how I calculated where the new BCPs would go in mouseDragged()
, but I'm not sure if it's a good way to go since controlling it is kind of weird.
# self.pt2Pos and self.pt3Pos are 2 selected BCPs
bcp0X, bcp0Y = self.pt2Pos
bcp1X, bcp1y = self.pt3Pos
# New point = current point + delta (for now)
bcp0XtoUse = bcp0X + delta.x
bcp0YtoUse = bcp0Y + delta.y
bcp1XtoUse = bcp1X + delta.x
bcp1YtoUse = bcp1y + delta.y
# First BCP
if self.slope0 == 0:
bcp0YtoUse = bcp0Y
# Vertical line, so new x == old x
elif self.slope0 is None:
bcp0XtoUse = bcp0X
# Angled line, use y=mx+b to find out new x & y,
# using x, y calculated above... this seems weird.
else:
bcp0XtoUse = (bcp0YtoUse - self.intercept0) / self.slope0
bcp0YtoUse = self.slope0 * bcp0XtoUse + self.intercept0
# Repeat for the other BCP
self.pt2.position = (round(bcp0XtoUse), round(bcp0YtoUse))
self.pt3.position = (round(bcp1XtoUse), round(bcp1YtoUse))
Also, I can't believe I never thought of your version of isPointInLine()
...
wild guess: calculate the new off curve point while dragging based on the start position of the off curve on mouse down.
hmm ok, will look into that. thanks!
hope this helps!!