Skip to content
Open
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
8 changes: 8 additions & 0 deletions src/primitives/rectangles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,14 @@ function Base.isapprox(r1::Rect, r2::Rect; kwargs...)
return isapprox(origin(r1), origin(r2); kwargs...) && isapprox(widths(r1), widths(r2); kwargs...)
end

##
# Rect1 decomposition
function coordinates(rect::Rect{1, T}) where {T}
w = widths(rect)
o = origin(rect)
return [Point{1,T}(o[1]), Point{1,T}(o[1]+w[1])]
Comment thread
thchr marked this conversation as resolved.
end

##
# Rect2 decomposition

Expand Down
8 changes: 8 additions & 0 deletions test/geometrytypes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,14 @@ end
r = Rect2i(2, 4, 2, 4)
@test M[r] == [53 63 73 83; 54 64 74 84]

# Rect1 coordinates/texturecoordinates
r = Rect{1,Float32}(0.2, 0.5)
@test eltype(coordinates(r)) == Point{1,Float32}
@test coordinates(r) == [Point{1,Float32}(0.2), Point{1,Float32}(0.7)]

r64 = Rect{1,Float64}(-0.2, 1.3)
@test eltype(coordinates(r64)) == Point{1,Float64}
@test coordinates(r64) == [Point{1,Float64}(-0.2), Point{1,Float64}(1.1)]
end

@testset "LineStrings" begin
Expand Down
Loading