Compare commits
1 Commits
master
...
bbs/shapes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17bb23a30c |
@ -43,7 +43,7 @@ function coords(shape::Shape)
|
||||
end
|
||||
|
||||
#coords(shapes::AVec{Shape}) = unzip(map(coords, shapes))
|
||||
function coords(shapes::AVec{Shape})
|
||||
function coords(shapes::AVec{<:Shape})
|
||||
c = map(coords, shapes)
|
||||
x = [q[1] for q in c]
|
||||
y = [q[2] for q in c]
|
||||
|
||||
@ -1428,9 +1428,9 @@ end
|
||||
coords(shape)
|
||||
end
|
||||
|
||||
@recipe function f(shapes::AVec{Shape})
|
||||
@recipe function f(shapes::AVec{<:Shape})
|
||||
seriestype --> :shape
|
||||
# For backwards compatibility, column vectors of segmenting attributes are
|
||||
# For backwards compatibility, column vectors of segmenting attributes are
|
||||
# interpreted as having one element per shape
|
||||
for attr in union(_segmenting_array_attributes, _segmenting_vector_attributes)
|
||||
v = get(plotattributes, attr, nothing)
|
||||
@ -1443,7 +1443,7 @@ end
|
||||
coords(shapes)
|
||||
end
|
||||
|
||||
@recipe function f(shapes::AMat{Shape})
|
||||
@recipe function f(shapes::AMat{<:Shape})
|
||||
seriestype --> :shape
|
||||
for j in axes(shapes, 2)
|
||||
@series coords(vec(shapes[:, j]))
|
||||
|
||||
@ -4,6 +4,7 @@ using Plots, Test
|
||||
@testset "Type" begin
|
||||
square = Shape([(0,0.0),(1,0.0),(1,1.0),(0,1.0)])
|
||||
@test isa(square, Shape{Int64, Float64})
|
||||
@test coords(square) isa Tuple{Vector{S}, Vector{T}} where {T,S}
|
||||
end
|
||||
|
||||
@testset "Copy" begin
|
||||
@ -47,6 +48,16 @@ using Plots, Test
|
||||
@test square2.x ≈ coords[1,:]
|
||||
@test square2.y ≈ coords[2,:]
|
||||
end
|
||||
|
||||
@testset "Plot" begin
|
||||
ang = range(0, 2π, length = 60)
|
||||
ellipse(x, y, w, h) = Shape(w*sin.(ang).+x, h*cos.(ang).+y)
|
||||
myshapes = [ellipse(x,rand(),rand(),rand()) for x = 1:4]
|
||||
@test coords(myshapes) isa Tuple{Vector{Vector{S}}, Vector{Vector{T}}} where {T,S}
|
||||
local p
|
||||
@test_nowarn p = plot(myshapes)
|
||||
@test p[1][1][:seriestype] == :shape
|
||||
end
|
||||
end
|
||||
|
||||
@testset "Brush" begin
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user