Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/primitives/rectangles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ end
RectT{ T}(o::VecTypes{N}, w::VecTypes{N}) where {N, T} = Rect{N, T}(o, w)
Rect{N }(o::VecTypes{N, T1}, w::VecTypes{N, T2}) where {N, T1, T2} = Rect{N, promote_type(T1, T2)}(o, w)

# Arrays

Rect(o::AbstractVector{T1}, w::AbstractVector{T2}) where {T1, T2} = RectT{promote_type(T1, T2)}(Vec(o...), Vec(w...))
RectT{ T}(o::AbstractVector, w::AbstractVector) where {T} = RectT{T}(Vec(o...), Vec(w...))
Rect{N }(o::AbstractVector{T1}, w::AbstractVector{T2}) where {N, T1, T2} = Rect{N, promote_type(T1, T2)}(Vec(o...), Vec(w...))
Rect{N, T}(o::AbstractVector, w::AbstractVector) where {N, T} = Rect{N, T}(Vec(o...), Vec(w...))

# mixed number - vectype

Rect(o::VecTypes{N, <:Number}, args::Vararg{Number, N}) where {N} = Rect{N }(o, promote(args...))
Expand Down
6 changes: 6 additions & 0 deletions test/geometrytypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ end
@test Rect2{UInt32}(0.8, 0.1, 1.3, 1.9) == Rect2i(1,0,1,2)
@test Rect3i(0.3, 0.6, 0.9, 1.2, 1.5, 1.8) == Rect3i(0,1,1,1,2,2)
end
@testset "Vector inputs" begin
@test Rect([1,2], [2,3]) == Rect2i(1,2,2,3)
@test Rect2f([0,1], [2,3]) == Rect2f(0,1,2,3)
@test RectT{Float64}([0,1,0], [2,2,2]) == Rect3d(0,1,0, 2,2,2)
@test Rect3([0,1,0], [2,2,2]) == Rect3i(0,1,0, 2,2,2)
end

# TODO: These don't really make sense...
r = Rect2f()
Expand Down
Loading