Skip to content
This repository has been archived by the owner on Nov 22, 2023. It is now read-only.

Define a Simple (2D) rectangle with 2 points or 1 point and dimension #149

Open
s-celles opened this issue Sep 1, 2018 · 1 comment
Open

Comments

@s-celles
Copy link
Contributor

s-celles commented Sep 1, 2018

Hello,

I was looking for building a Simple (2D) rectangle with 2 points

julia> Rectangle(Point(0,0), Point(320, 200))
ERROR: MethodError: no method matching SimpleRectangle(::Point{2,Int64}, ::Point{2,Int64})
Closest candidates are:
  SimpleRectangle(::T, ::T, ::T, ::T) where T at /Users/scls/.julia/dev/GeometryTypes/src/types.jl:110
Stacktrace:
 [1] top-level scope at none:0

or

a Simple (2D) rectangle with one point and dimensions (width/height)

julia> Rectangle(Point(10,10), Vec(310, 190))
ERROR: MethodError: no method matching SimpleRectangle(::Point{2,Int64}, ::Vec{2,Int64})
Closest candidates are:
  SimpleRectangle(::Vec{2,T}, ::Vec{2,T}) where T at /Users/scls/.julia/dev/GeometryTypes/src/hyperrectangles.jl:229
  SimpleRectangle(::T, ::T, ::T, ::T) where T at /Users/scls/.julia/dev/GeometryTypes/src/types.jl:110
Stacktrace:
 [1] top-level scope at none:0

I saw

SimpleRectangle(val::Vec{2, T}) where {T} = SimpleRectangle{T}(0, 0, val...)
function SimpleRectangle(position::Vec{2,T}, width::Vec{2,T}) where T
SimpleRectangle{T}(position..., width...)
end

Maybe using Point type could help (to avoid confusion with Vec)?

Kind regards

@SimonDanisch
Copy link
Member

I need to move all the convenient functions i defined in Makie to GeometryTypes at some point:
https://github.com/JuliaPlots/AbstractPlotting.jl/blob/master/src/types.jl#L23

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants