fix cycle; fix GR fill

This commit is contained in:
Thomas Breloff 2016-07-25 15:25:50 -04:00
parent e9dca92c11
commit 3ae8dc9bd7
2 changed files with 12 additions and 18 deletions

View File

@ -675,14 +675,9 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
# recompute data # recompute data
if typeof(z) <: Surface if typeof(z) <: Surface
if st == :heatmap #&& size(z.surf) == (length(y), length(x)) if st == :heatmap
expand_extrema!(sp[:xaxis], (x[1]-0.5*(x[2]-x[1]), x[end]+0.5*(x[end]-x[end-1]))) expand_extrema!(sp[:xaxis], (x[1]-0.5*(x[2]-x[1]), x[end]+0.5*(x[end]-x[end-1])))
expand_extrema!(sp[:yaxis], (y[1]-0.5*(y[2]-y[1]), y[end]+0.5*(y[end]-y[end-1]))) expand_extrema!(sp[:yaxis], (y[1]-0.5*(y[2]-y[1]), y[end]+0.5*(y[end]-y[end-1])))
# # coords are centers... turn into edges
# xd = diff(x)
# x = vcat(x[1]-0.5xd[1], x[1]+xd, x[end]+0.5xd[end])
# yd = diff(y)
# y = vcat(y[1]-0.5yd[1], y[1]+yd, y[end]+0.5yd[end])
end end
z = vec(transpose_z(series, z.surf, false)) z = vec(transpose_z(series, z.surf, false))
elseif ispolar(sp) elseif ispolar(sp)
@ -694,21 +689,19 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
if st in (:path, :scatter) if st in (:path, :scatter)
if length(x) > 1 if length(x) > 1
# do area fill # do area fill
if frng != nothing if frng != nothing
gr_set_fillcolor(series[:fillcolor]) #, series[:fillalpha])
GR.setfillintstyle(GR.INTSTYLE_SOLID) GR.setfillintstyle(GR.INTSTYLE_SOLID)
frng = isa(frng, Number) ? Float64[frng] : frng fr_from, fr_to = (is_2tuple(frng) ? frng : (y, frng))
nx, ny, nf = length(x), length(y), length(frng) for (i,rng) in enumerate(iter_segments(series[:x], series[:y]))
n = max(nx, ny) if length(rng) > 1
fx, fy = zeros(2n), zeros(2n) gr_set_fillcolor(cycle(series[:fillcolor], i))
for i=1:n fx = cycle(x, vcat(rng, reverse(rng)))
fx[i] = fx[end-i+1] = cycle(x,i) fy = vcat(cycle(fr_from,rng), cycle(fr_to,reverse(rng)))
fy[i] = cycle(y,i) @show i rng fx fy
fy[end-i+1] = cycle(frng,i) GR.fillarea(fx, fy)
end
end end
GR.fillarea(fx, fy)
end end
# draw the line(s) # draw the line(s)

View File

@ -243,9 +243,10 @@ Base.cycle(v, idx::Int) = v
Base.cycle(v::AVec, indices::AVec{Int}) = map(i -> cycle(v,i), indices) Base.cycle(v::AVec, indices::AVec{Int}) = map(i -> cycle(v,i), indices)
Base.cycle(v::AMat, indices::AVec{Int}) = map(i -> cycle(v,i), indices) Base.cycle(v::AMat, indices::AVec{Int}) = map(i -> cycle(v,i), indices)
Base.cycle(v, idx::AVec{Int}) = v Base.cycle(v, indices::AVec{Int}) = fill(v, length(indices))
Base.cycle(grad::ColorGradient, idx::Int) = cycle(grad.colors, idx) Base.cycle(grad::ColorGradient, idx::Int) = cycle(grad.colors, idx)
Base.cycle(grad::ColorGradient, indices::AVec{Int}) = cycle(grad.colors, indices)
makevec(v::AVec) = v makevec(v::AVec) = v
makevec{T}(v::T) = T[v] makevec{T}(v::T) = T[v]