@@ -35,11 +35,11 @@ ncontrols(b::BezierCurve) = length(b.controls)
3535
3636degree (b:: BezierCurve ) = ncontrols (b) - 1
3737
38- == (b₁:: BezierCurve , b₂:: BezierCurve ) = b₁ . controls == b₂ . controls
38+ == (b₁:: BezierCurve , b₂:: BezierCurve ) = controls (b₁) == controls (b₂)
3939
4040Base. isapprox (b₁:: BezierCurve , b₂:: BezierCurve ; atol= atol (lentype (b₁)), kwargs... ) =
41- length (b₁. controls ) == length (b₂. controls ) &&
42- all (isapprox (p₁, p₂; atol, kwargs... ) for (p₁, p₂) in zip (b₁ . controls, b₂ . controls ))
41+ ncontrols (b₁) == ncontrols (b₂) &&
42+ all (isapprox (p₁, p₂; atol, kwargs... ) for (p₁, p₂) in zip (controls (b₁), controls (b₂) ))
4343
4444"""
4545Evaluation method used to obtain a point along
@@ -64,15 +64,15 @@ See <https://en.wikipedia.org/wiki/Horner%27s_method>.
6464"""
6565struct Horner <: BezierEvalMethod end
6666
67- (curve :: BezierCurve )(t) = curve (t, DeCasteljau ())
67+ (b :: BezierCurve )(t) = b (t, DeCasteljau ())
6868
6969# Apply DeCasteljau's method
70- function (curve :: BezierCurve )(t, :: DeCasteljau )
70+ function (b :: BezierCurve )(t, :: DeCasteljau )
7171 if t < 0 || t > 1
7272 throw (DomainError (t, " b(t) is not defined for t outside [0, 1]." ))
7373 end
74- ss = segments ( Rope (curve . controls))
75- points = [s (t) for s in ss ]
74+ rope = Rope (controls (b ))
75+ points = [s (t) for s in segments (rope) ]
7676 if length (points) == 1
7777 points[1 ]
7878 else
8585# curve, aᵢ = binomial(n, i) * pᵢ * t̄ⁿ⁻ⁱ and t̄ = (1 - t).
8686# Horner's rule recursively reconstructs B from a sequence bᵢ
8787# with bₙ = aₙ and bᵢ₋₁ = aᵢ₋₁ + bᵢ * t until b₀ = B.
88- function (curve :: BezierCurve )(t, :: Horner )
88+ function (b :: BezierCurve )(t, :: Horner )
8989 if t < 0 || t > 1
9090 throw (DomainError (t, " b(t) is not defined for t outside [0, 1]." ))
9191 end
92- T = numtype (lentype (curve ))
93- cs = curve . controls
92+ T = numtype (lentype (b ))
93+ cs = controls (b)
9494 t̄ = one (T) - t
95- n = degree (curve )
95+ n = degree (b )
9696 pₙ = to (last (cs))
9797 aₙ = pₙ
9898
@@ -109,7 +109,7 @@ function (curve::BezierCurve)(t, ::Horner)
109109 end
110110
111111 b₀ = bᵢ₋₁
112- withcrs (curve , b₀)
112+ withcrs (b , b₀)
113113end
114114
115115# -----------
@@ -119,14 +119,14 @@ end
119119function Base. show (io:: IO , b:: BezierCurve )
120120 ioctx = IOContext (io, :compact => true )
121121 print (io, " BezierCurve(controls: [" )
122- join (ioctx, b . controls, " , " )
122+ join (ioctx, controls (b) , " , " )
123123 print (io, " ])" )
124124end
125125
126126function Base. show (io:: IO , :: MIME"text/plain" , b:: BezierCurve )
127127 summary (io, b)
128128 println (io)
129129 print (io, " └─ controls: [" )
130- join (io, b . controls, " , " )
130+ join (io, controls (b) , " , " )
131131 print (io, " ]" )
132132end
0 commit comments