Vector path trajectory imitation
An example vector path trajectory imitation system is configured to create a new vector path or to extend an existing vector path based on a reference. In this manner, a user (e.g., artist, illustrator, or designer) does not need to tweak individual anchor points to align a trajectory of the new vector path with the trajectory of the reference. Instead, the user moves a position indicator (e.g., a mouse cursor) on a digital canvas in a freehand fashion while the vector path trajectory imitation system provides visual feedback to show the user how a resultant curve will look. When the user reaches a position on the digital canvas where a new vector path is to be drawn, the user can perform an action (e.g., releasing a mouse button) and the new vector path, which follows the trajectory of the reference, is created.
1 . A method comprising:
receiving, by a processing device, a selection of a reference curve from one or more vector paths displayed in a user interface;
receiving, by the processing device, an input via the user interface defining a path in the user interface;
selecting, by the processing device, reference points along the reference curve based on the path;
calculating, by the processing device, a resultant curve offset from the reference curve that imitates a trajectory of the reference curve based on the path and the selected reference points along the reference curve; and
displaying, by the processing device, the resultant curve in the user interface as offset from the reference curve.
2 . The method as described in claim 1 , wherein the resultant curve extends the reference curve in the user interface.
3 . The method as described in claim 1 , wherein the resultant curve replaces the path in the user interface.
4 . The method as described in claim 3 , wherein the receiving the path includes identifying a last anchor position as a first anchor point and a current anchor position of a position indicator as a second anchor point.
5 . The method as described in claim 4 , wherein selecting the reference points along the reference curve comprises:
receiving the first anchor point and the second anchor point;
finding a first reference point nearest the first anchor point;
finding a second reference point nearest the second anchor point;
defining a first distance between the first anchor point and the first reference point; and
defining a second distance between the second anchor point and the second reference point.
6 . The method as described in claim 5 , wherein the calculating the resultant curve includes calculating the resultant curve based on the first distance, the second distance, the first reference point, and the second reference point.
7 . The method as described in claim 5 , wherein the calculating the resultant curve further comprises executing a vector path trajectory imitation algorithm based on the first distance, the second distance, the first reference point, and the second reference point.
8 . The method as described in claim 1 , further comprising refining, by the processing device, the resultant curve.
9 . The method as described in claim 8 , wherein the refining the resultant curve includes removing a loop artifact.
10 . The method as described in claim 8 , wherein the refining the resultant curve includes applying a corner handling algorithm to the resultant curve to create a refined resultant curve.
11 . The method as described in claim 8 , wherein the refining the resultant curve includes applying a nearest neighbor curve refining algorithm to the resultant curve to create a refined resultant curve.
12 . The method as described in claim 11 , wherein the refining the resultant curve further includes applying an intersection detection algorithm to the refined resultant curve to create a further refined resultant curve.
13 . A system comprising:
a processing device; and
a computer-readable storage medium storing instructions that, responsive to execution by the processing device, causes the processing device to perform operations including:
identifying a path as a freeform line in a user interface having a first anchor point and a second anchor point;
selecting reference points along one or more vector paths of a reference curve offset from the path based on the first and second anchor points;
calculating a resultant curve offset from the reference curve based on the path, the first and second anchor points, and the selected reference points of the reference curve; and
outputting the resultant curve in the user interface as offset from the reference curve.
14 . The system as described in claim 13 , wherein the resultant curve extends the reference curve.
15 . The system as described in claim 13 , wherein the resultant curve replaces the path in the user interface.
16 . The system as described in claim 13 , wherein the operations further comprise applying a corner handling algorithm to the resultant curve to create a refined resultant curve.
17 . The system as described in claim 13 , wherein the operations further comprise applying a nearest neighbor algorithm to the resultant curve to create a refined resultant curve.
18 . The system as described in claim 17 , wherein the operations further comprise applying an intersection detection algorithm to the refined resultant curve to create a further refined resultant curve.
19 . One or more computer-readable storage media storing instructions that, responsive to execution by a processing device, causes the processing device to perform operations comprising:
selecting a reference curve having a first reference point and a second reference point from one or more vector paths displayed in a user interface;
identifying a path having a first anchor point and a second anchor point as input via the user interface at a location offset from the reference curve;
calculating a resultant curve based on the location of the path in the user interface and a trajectory of the reference curve in the user interface based at least in part on:
determining a length of the reference curve between the first reference point and the second reference point;
determining a first distance between the first anchor point and the first reference point,
determining a second distance between the second anchor point and the second reference point; and
executing a vector path trajectory imitation algorithm based on the length of the reference curve, the first distance, and the second distance; and
outputting the resultant curve in the user interface with the resultant curve as offset from the reference curve based on the location.
20 . The one or more computer-readable storage media as described in claim 19 , wherein the operations further comprise:
refining the resultant curve to remove an unintentional loop artifact by applying one or more curve refining algorithms, wherein the one or more curve refining algorithms comprise a corner handling algorithm, a nearest neighbor algorithm, and an intersection detection algorithm.