Skip to content

Commit

Permalink
lazily load Makie (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
findmyway authored Oct 13, 2020
1 parent 910a0cf commit f46e78c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 1 addition & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@ version = "0.0.1"
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
Crayons = "a8cc5b0e-0ffa-5ad4-8c14-923d3ee1735f"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"

[compat]
Colors = "0.12"
MacroTools = "0.5"
Crayons = "4.0"
MacroTools = "0.5"
Requires = "1.1"
Makie = "0.11"
julia = "1"

[extras]
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ w(TURN_LEFT)
w(TURN_RIGHT)

# play interactively with Makie.
# you need to manually install Makie with the following command first
# ] add Makie
# first time plot may be slow
using Makie
play(w;file_name="example.gif",frame_rate=5)
```

Expand Down
7 changes: 3 additions & 4 deletions src/GridWorlds.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ include("abstract_grid_world.jl")
include("envs/envs.jl")
include("render_in_terminal.jl")

# function __init__()
# @require Makie="ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" include("render_with_Makie.jl")
# end
include("render_with_Makie.jl")
function __init__()
@require Makie="ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a" include("render_with_Makie.jl")
end

end
2 changes: 1 addition & 1 deletion src/render_with_Makie.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ using Colors
# coordinate transform for Makie.jl
transform(x::Int) = p -> CartesianIndex(p[2], x-p[1]+1)

using Makie
using .Makie

function init_screen(w::Observable{<:AbstractGridWorld}; resolution=(1000,1000))
scene = Scene(resolution = resolution, raw = true, camera = campixel!)
Expand Down

0 comments on commit f46e78c

Please sign in to comment.