Skip to content

Commit

Permalink
add better image scatter support
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDanisch committed Jun 6, 2018
1 parent 7d500b5 commit 43ec07d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/atomics/scatter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ function expand_for_glvisualize(kw_args)

if k == :rotations
k = :rotation
v = Vec4f0(0, 0, 0, 1)
result[:billboard] = true
if to_value(v) == Billboard()
v = Vec4f0(0, 0, 0, 1)
result[:billboard] = true
else
v
end
end
if k == :markersize
k = :scale
Expand Down Expand Up @@ -77,7 +81,7 @@ function _scatter(scene, kw_args)
attributes = scatter_defaults(scene, kw_args)
gl_data = expand_for_glvisualize(attributes)
shape = to_signal(attributes[:marker])
main = (shape, to_signal(attributes[:positions]))
main = (value(shape), to_signal(attributes[:positions]))
viz = visualize(main, Style(:default), gl_data)
insert_scene!(scene, :scatter, viz, attributes)
end
Expand Down
6 changes: 3 additions & 3 deletions src/plotsbase/conversions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ to_spritemarker(b, marker::Matrix{<: AbstractFloat}) = Float32.(marker)
"""
Any AbstractMatrix{<: Colorant} or other image type
"""
to_spritemarker(b, marker::Image) = to_image(marker)
to_spritemarker(b, marker::Image) = to_image(b, marker)

"""
A `Symbol` - Available options can be printed with `available_marker_symbols()`
Expand All @@ -353,7 +353,6 @@ Vector of anything that is accepted as a single marker will give each point it's
Note that it needs to be a uniform vector with the same element type!
"""
function to_spritemarker(b, marker::AbstractVector)
println(typeof(marker))
marker = map(marker) do sym
to_spritemarker(b, sym)
end
Expand Down Expand Up @@ -412,7 +411,8 @@ to_rotations(b, x::Billboard) = x
"""
Any AbstractArray which elements can be converted to Vec4 (as a quaternion x, y, z, w)
"""
to_rotations(b, x::AbstractVector) = to_static_vec(b, x)
to_rotations(b, x::AbstractVector) = to_rotation.(b, x)
to_rotations(b, x::Union{StaticVector, Tuple}) = to_rotation(b, x)

"""
to_markersize2d(b, x)
Expand Down
3 changes: 2 additions & 1 deletion test/all_samples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ end


#cell
img = loadasset("doge.png")
img = GLVisualize.loadasset("doge.png")
scene = Scene(resolution = (500, 500))

display(scene)
Expand Down Expand Up @@ -154,6 +154,7 @@ contour(linspace(-0.99, 0.99, 23), y, rand(23, 23), levels = 10)
center!(scene)

#cell
using Makie, GeometryTypes
scene = Scene(resolution = (500, 500))
# define points/edges
perturbfactor = 4e1
Expand Down
14 changes: 13 additions & 1 deletion test/test.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
using Makie, GeometryTypes, Colors
scene = Scene()
doge = GLVisualize.loadasset("doge.png")
# For rectangles + rotation
scatter(
Point3f0[(1,0,0), (0,1,0), (0,0,1)],
marker = [:x, :circle, :cross]
marker = [doge, doge, doge],
# rotation around axis... can you Vec4f0(...) for a quaternion
rotations = [(Vec3f0(0, 1, 0), 0.5pi), (Vec3f0(1, 0, 0), -0.5pi), (Vec3f0(0, 0, 1), -1.2pi)]
)

# for more control:
scene = Scene(resolution = (500, 500))
mesh = GLNormalUVMesh(SimpleRectangle(0, 0, 1, 1))
# note, you can change the mesh.vertices to arbitrary values
Makie.mesh(mesh, color = doge, shading = false)
center!(scene)


GLVisualize.visualize(("helo", rand(Point3f0, length("helo"))))

scene[:theme][:scatter][:marker] = :cross
Expand Down

0 comments on commit 43ec07d

Please sign in to comment.