From 3ae8dc9bd762fdf3cb7c115ed8a57f8eaed95eee Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Mon, 25 Jul 2016 15:25:50 -0400 Subject: [PATCH] fix cycle; fix GR fill --- src/backends/gr.jl | 27 ++++++++++----------------- src/utils.jl | 3 ++- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index ba75d2e8..0a3e73d6 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -675,14 +675,9 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) # recompute data 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[: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 z = vec(transpose_z(series, z.surf, false)) elseif ispolar(sp) @@ -694,21 +689,19 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas) if st in (:path, :scatter) if length(x) > 1 - # do area fill if frng != nothing - gr_set_fillcolor(series[:fillcolor]) #, series[:fillalpha]) GR.setfillintstyle(GR.INTSTYLE_SOLID) - frng = isa(frng, Number) ? Float64[frng] : frng - nx, ny, nf = length(x), length(y), length(frng) - n = max(nx, ny) - fx, fy = zeros(2n), zeros(2n) - for i=1:n - fx[i] = fx[end-i+1] = cycle(x,i) - fy[i] = cycle(y,i) - fy[end-i+1] = cycle(frng,i) + fr_from, fr_to = (is_2tuple(frng) ? frng : (y, frng)) + for (i,rng) in enumerate(iter_segments(series[:x], series[:y])) + if length(rng) > 1 + gr_set_fillcolor(cycle(series[:fillcolor], i)) + fx = cycle(x, vcat(rng, reverse(rng))) + fy = vcat(cycle(fr_from,rng), cycle(fr_to,reverse(rng))) + @show i rng fx fy + GR.fillarea(fx, fy) + end end - GR.fillarea(fx, fy) end # draw the line(s) diff --git a/src/utils.jl b/src/utils.jl index a5f5b588..5bf8b37b 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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::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, indices::AVec{Int}) = cycle(grad.colors, indices) makevec(v::AVec) = v makevec{T}(v::T) = T[v]