Skip to content

Instantly share code, notes, and snippets.

@Marlin-Na
Created June 12, 2021 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Marlin-Na/06222f33cd8b356aabb8724a2b5d9684 to your computer and use it in GitHub Desktop.
Save Marlin-Na/06222f33cd8b356aabb8724a2b5d9684 to your computer and use it in GitHub Desktop.
Makie.jl recipe example
### Makie: define recipes
using Makie
@recipe(CircleShape, x, y, r) do scene
Attributes(
color = :red
)
end
function Makie.plot!(chart::CircleShape{<:Tuple{<:Real,<:Real,<:Real}})
x = chart[1]
y = chart[2]
r = chart[3]
function get_points(x, y, r)
N = 500
θ = LinRange(0, 2*π, N)
return (x .+ r .* cos.(θ), y .+ r .* sin.(θ))
end
XY = lift(get_points, x, y, r)
pX = lift(x -> x[1], XY)
pY = lift(x -> x[2], XY)
lines!(chart, pX, pY, color=chart.color)
chart
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment