File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ <#
3+ . SYNOPSIS
4+ Draws a Bezier Curve
5+ . DESCRIPTION
6+ Draws a simple Bezier curve.
7+ . EXAMPLE
8+ turtle @(
9+ 'CubicBezierCurve',
10+ 200,0, # Start Control Point
11+ 0,200, # End Control Point
12+ 200,200 # End Point
13+ ) save ./cubic.svg
14+ . LINK
15+ https://en.wikipedia.org/wiki/B%C3%A9zier_curve
16+ #>
17+ param (
18+ # The X control point
19+ [double ]
20+ $ControlStartX ,
21+
22+ # The Y control point
23+ [double ]
24+ $ControlStartY ,
25+
26+ # The X control point
27+ [double ]
28+ $ControlEndX ,
29+
30+ # The Y control point
31+ [double ]
32+ $ControlEndY ,
33+
34+ # The delta X
35+ [double ]
36+ $DeltaX ,
37+
38+ # The delta Y
39+ [double ]
40+ $DeltaY
41+ )
42+
43+
44+
45+ if ($DeltaX -or $DeltaY ) {
46+ $this.Position = $DeltaX , $DeltaY
47+ # If the pen is down
48+ if ($this.IsPenDown ) {
49+ # draw the curve
50+ $this.Steps.Add (" c $ControlStartX $ControlStartY $ControlEndX $ControlEndY $DeltaX $DeltaY " )
51+ } else {
52+ # otherwise, move to the deltaX/deltaY
53+ $this.Steps.Add (" m $DeltaX $DeltaY " )
54+ }
55+ }
56+
57+ return $this
58+
You can’t perform that action at this time.
0 commit comments