Skip to content

Commit fac7094

Browse files
thchrCopilotffreyer
authored
add coordinates for Rect1 (#277)
* add `coordinates` and `texturecoordinates` for `Rect1` * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * remove `texturecoordinates(::Rect{1})` --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: Frederic Freyer <frederic481994@hotmail.de>
1 parent 9575c94 commit fac7094

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/primitives/rectangles.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,14 @@ function Base.isapprox(r1::Rect, r2::Rect; kwargs...)
524524
return isapprox(origin(r1), origin(r2); kwargs...) && isapprox(widths(r1), widths(r2); kwargs...)
525525
end
526526

527+
##
528+
# Rect1 decomposition
529+
function coordinates(rect::Rect{1, T}) where {T}
530+
w = widths(rect)
531+
o = origin(rect)
532+
return [Point{1,T}(o[1]), Point{1,T}(o[1]+w[1])]
533+
end
534+
527535
##
528536
# Rect2 decomposition
529537

test/geometrytypes.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,14 @@ end
683683
r = Rect2i(2, 4, 2, 4)
684684
@test M[r] == [53 63 73 83; 54 64 74 84]
685685

686+
# Rect1 coordinates/texturecoordinates
687+
r = Rect{1,Float32}(0.2, 0.5)
688+
@test eltype(coordinates(r)) == Point{1,Float32}
689+
@test coordinates(r) == [Point{1,Float32}(0.2), Point{1,Float32}(0.7)]
690+
691+
r64 = Rect{1,Float64}(-0.2, 1.3)
692+
@test eltype(coordinates(r64)) == Point{1,Float64}
693+
@test coordinates(r64) == [Point{1,Float64}(-0.2), Point{1,Float64}(1.1)]
686694
end
687695

688696
@testset "LineStrings" begin

0 commit comments

Comments
 (0)