Allow movement and resizing of images.
This commit is contained in:
parent
99f3b7ae99
commit
d4075a1ef5
@ -1215,7 +1215,7 @@ end
|
|||||||
|
|
||||||
function gl_image(img, kw_args)
|
function gl_image(img, kw_args)
|
||||||
rect = kw_args[:primitive]
|
rect = kw_args[:primitive]
|
||||||
kw_args[:primitive] = GeometryTypes.SimpleRectangle{Float32}(rect.x, rect.y, rect.h, rect.w) # seems to be flipped
|
kw_args[:primitive] = GeometryTypes.SimpleRectangle{Float32}(rect.x, rect.y, rect.w, rect.h)
|
||||||
visualize(img, Style(:default), kw_args)
|
visualize(img, Style(:default), kw_args)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -1199,6 +1199,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
elseif st == :image
|
elseif st == :image
|
||||||
z = transpose_z(series, series[:z].surf, true)'
|
z = transpose_z(series, series[:z].surf, true)'
|
||||||
w, h = size(z)
|
w, h = size(z)
|
||||||
|
xmin, xmax = ignorenan_extrema(series[:x]); ymin, ymax = ignorenan_extrema(series[:y])
|
||||||
if eltype(z) <: Colors.AbstractGray
|
if eltype(z) <: Colors.AbstractGray
|
||||||
grey = round.(UInt8, float(z) * 255)
|
grey = round.(UInt8, float(z) * 255)
|
||||||
rgba = map(c -> UInt32( 0xff000000 + Int(c)<<16 + Int(c)<<8 + Int(c) ), grey)
|
rgba = map(c -> UInt32( 0xff000000 + Int(c)<<16 + Int(c)<<8 + Int(c) ), grey)
|
||||||
@ -1208,7 +1209,7 @@ function gr_display(sp::Subplot{GRBackend}, w, h, viewport_canvas)
|
|||||||
round(Int, green(c) * 255) << 8 +
|
round(Int, green(c) * 255) << 8 +
|
||||||
round(Int, red(c) * 255) ), z)
|
round(Int, red(c) * 255) ), z)
|
||||||
end
|
end
|
||||||
GR.drawimage(0, w, h, 0, w, h, rgba)
|
GR.drawimage(xmin, xmax, ymax, ymin, w, h, rgba)
|
||||||
end
|
end
|
||||||
|
|
||||||
# this is all we need to add the series_annotations text
|
# this is all we need to add the series_annotations text
|
||||||
|
|||||||
@ -731,6 +731,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
|
|
||||||
if st == :image
|
if st == :image
|
||||||
# @show typeof(z)
|
# @show typeof(z)
|
||||||
|
xmin, xmax = ignorenan_extrema(series[:x]); ymin, ymax = ignorenan_extrema(series[:y])
|
||||||
img = Array(transpose_z(series, z.surf))
|
img = Array(transpose_z(series, z.surf))
|
||||||
z = if eltype(img) <: Colors.AbstractGray
|
z = if eltype(img) <: Colors.AbstractGray
|
||||||
float(img)
|
float(img)
|
||||||
@ -743,7 +744,8 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series)
|
|||||||
zorder = series[:series_plotindex],
|
zorder = series[:series_plotindex],
|
||||||
cmap = py_colormap([:black, :white]),
|
cmap = py_colormap([:black, :white]),
|
||||||
vmin = 0.0,
|
vmin = 0.0,
|
||||||
vmax = 1.0
|
vmax = 1.0,
|
||||||
|
extent = (xmin, xmax, ymax, ymin)
|
||||||
)
|
)
|
||||||
push!(handles, handle)
|
push!(handles, handle)
|
||||||
|
|
||||||
|
|||||||
@ -325,6 +325,7 @@ end
|
|||||||
else
|
else
|
||||||
seriestype := :heatmap
|
seriestype := :heatmap
|
||||||
yflip --> true
|
yflip --> true
|
||||||
|
cbar --> false
|
||||||
fillcolor --> ColorGradient([:black, :white])
|
fillcolor --> ColorGradient([:black, :white])
|
||||||
SliceIt, 1:m, 1:n, Surface(convert(Matrix{Float64}, mat))
|
SliceIt, 1:m, 1:n, Surface(convert(Matrix{Float64}, mat))
|
||||||
end
|
end
|
||||||
@ -341,6 +342,7 @@ end
|
|||||||
else
|
else
|
||||||
seriestype := :heatmap
|
seriestype := :heatmap
|
||||||
yflip --> true
|
yflip --> true
|
||||||
|
cbar --> false
|
||||||
z, plotattributes[:fillcolor] = replace_image_with_heatmap(mat)
|
z, plotattributes[:fillcolor] = replace_image_with_heatmap(mat)
|
||||||
SliceIt, 1:m, 1:n, Surface(z)
|
SliceIt, 1:m, 1:n, Surface(z)
|
||||||
end
|
end
|
||||||
@ -465,6 +467,36 @@ end
|
|||||||
SliceIt, x, y, Surface(z)
|
SliceIt, x, y, Surface(z)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# # images - grays
|
||||||
|
|
||||||
|
@recipe function f(x::AVec, y::AVec, mat::AMat{T}) where T<:Gray
|
||||||
|
if is_seriestype_supported(:image)
|
||||||
|
seriestype := :image
|
||||||
|
SliceIt, x, y, Surface(mat)
|
||||||
|
else
|
||||||
|
seriestype := :heatmap
|
||||||
|
yflip --> true
|
||||||
|
cbar --> false
|
||||||
|
fillcolor --> ColorGradient([:black, :white])
|
||||||
|
SliceIt, x, y, Surface(convert(Matrix{Float64}, mat))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# # images - colors
|
||||||
|
|
||||||
|
@recipe function f(x::AVec, y::AVec, mat::AMat{T}) where T<:Colorant
|
||||||
|
if is_seriestype_supported(:image)
|
||||||
|
seriestype := :image
|
||||||
|
SliceIt, x, y, Surface(mat)
|
||||||
|
else
|
||||||
|
seriestype := :heatmap
|
||||||
|
yflip --> true
|
||||||
|
cbar --> false
|
||||||
|
z, plotattributes[:fillcolor] = replace_image_with_heatmap(mat)
|
||||||
|
SliceIt, x, y, Surface(z)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# # --------------------------------------------------------------------
|
# # --------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user