JuliaGraphics / Luxor.jl

Simple drawings using vector graphics; Cairo "for tourists!"
http://juliagraphics.github.io/Luxor.jl/
Other
576 stars 72 forks source link

Add support for `zero(Point)` #221

Closed hyrodium closed 2 years ago

hyrodium commented 2 years ago

I thought it would be nice to have a method zero(Point) to get Point(0.0, 0.0).

julia> using Luxor

julia> zero(Point)
ERROR: MethodError: no method matching zero(::Type{Point})
Closest candidates are:
  zero(::Union{Type{P}, P}) where P<:Dates.Period at ~/julia/julia-1.7.2/share/julia/stdlib/v1.7/Dates/src/periods.jl:53
  zero(::AbstractIrrational) at ~/julia/julia-1.7.2/share/julia/base/irrationals.jl:150
  zero(::T) where T<:Dates.TimeType at ~/julia/julia-1.7.2/share/julia/stdlib/v1.7/Dates/src/types.jl:450
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[2]:1

Would this change be desirable? If so, I'll make a PR.

cormullion commented 2 years ago

I haven't yet felt the need for it (I use O whenever I need Point(0, 0), but if you think it would be a valuable and non-disruptive addition, go for it...!