Skip to content

Commit

Permalink
Added ability to mirror control point movement when holding the alt key.
Browse files Browse the repository at this point in the history
  • Loading branch information
keenanwoodall committed Feb 6, 2019
1 parent 53f0242 commit 592451e
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion PathCreator/Core/Editor/PathEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,37 @@ void DrawHandle(int i)
{
Undo.RecordObject(creator, "Move point");
bezierPath.MovePoint(i, handlePosition);
}

// If the use is holding alt, try and mirror the control point.
if (Event.current.modifiers == EventModifiers.Alt)
{
// If the control point we're selecting isn't at the beginning or end of the path
if (i > 1 && i < bezierPath.NumPoints - 2)
{
// 0 = Anchor, 1 = Left Control, 2 = Right Control
var pointType = i % 3;

// If we are selecting a control point
if (pointType != 0)
{
// If we are selecting the left control point
if (pointType == 2)
{
var anchorIndex = i + 1;
var anchorPoint = bezierPath[anchorIndex];
bezierPath.MovePoint (anchorIndex + 1, anchorPoint - (handlePosition - anchorPoint));
}
// If we are selecting the right control point
else if (pointType == 1)
{
var anchorIndex = i - 1;
var anchorPoint = bezierPath[anchorIndex];
bezierPath.MovePoint (anchorIndex - 1, anchorPoint - (handlePosition - anchorPoint));
}
}
}
}
}

}

Expand Down

0 comments on commit 592451e

Please sign in to comment.