Created
June 12, 2021 21:07
-
-
Save Marlin-Na/06222f33cd8b356aabb8724a2b5d9684 to your computer and use it in GitHub Desktop.
Makie.jl recipe example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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