fix vector of shapes
This commit is contained in:
parent
827462dc21
commit
17bb23a30c
@ -43,7 +43,7 @@ function coords(shape::Shape)
|
|||||||
end
|
end
|
||||||
|
|
||||||
#coords(shapes::AVec{Shape}) = unzip(map(coords, shapes))
|
#coords(shapes::AVec{Shape}) = unzip(map(coords, shapes))
|
||||||
function coords(shapes::AVec{Shape})
|
function coords(shapes::AVec{<:Shape})
|
||||||
c = map(coords, shapes)
|
c = map(coords, shapes)
|
||||||
x = [q[1] for q in c]
|
x = [q[1] for q in c]
|
||||||
y = [q[2] for q in c]
|
y = [q[2] for q in c]
|
||||||
|
|||||||
@ -1428,9 +1428,9 @@ end
|
|||||||
coords(shape)
|
coords(shape)
|
||||||
end
|
end
|
||||||
|
|
||||||
@recipe function f(shapes::AVec{Shape})
|
@recipe function f(shapes::AVec{<:Shape})
|
||||||
seriestype --> :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
|
# interpreted as having one element per shape
|
||||||
for attr in union(_segmenting_array_attributes, _segmenting_vector_attributes)
|
for attr in union(_segmenting_array_attributes, _segmenting_vector_attributes)
|
||||||
v = get(plotattributes, attr, nothing)
|
v = get(plotattributes, attr, nothing)
|
||||||
@ -1443,7 +1443,7 @@ end
|
|||||||
coords(shapes)
|
coords(shapes)
|
||||||
end
|
end
|
||||||
|
|
||||||
@recipe function f(shapes::AMat{Shape})
|
@recipe function f(shapes::AMat{<:Shape})
|
||||||
seriestype --> :shape
|
seriestype --> :shape
|
||||||
for j in axes(shapes, 2)
|
for j in axes(shapes, 2)
|
||||||
@series coords(vec(shapes[:, j]))
|
@series coords(vec(shapes[:, j]))
|
||||||
|
|||||||
@ -4,6 +4,7 @@ using Plots, Test
|
|||||||
@testset "Type" begin
|
@testset "Type" begin
|
||||||
square = Shape([(0,0.0),(1,0.0),(1,1.0),(0,1.0)])
|
square = Shape([(0,0.0),(1,0.0),(1,1.0),(0,1.0)])
|
||||||
@test isa(square, Shape{Int64, Float64})
|
@test isa(square, Shape{Int64, Float64})
|
||||||
|
@test coords(square) isa Tuple{Vector{S}, Vector{T}} where {T,S}
|
||||||
end
|
end
|
||||||
|
|
||||||
@testset "Copy" begin
|
@testset "Copy" begin
|
||||||
@ -47,6 +48,16 @@ using Plots, Test
|
|||||||
@test square2.x ≈ coords[1,:]
|
@test square2.x ≈ coords[1,:]
|
||||||
@test square2.y ≈ coords[2,:]
|
@test square2.y ≈ coords[2,:]
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
@testset "Brush" begin
|
@testset "Brush" begin
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user