Skip to content

Commit

Permalink
lower default framerate for docs animations
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Jun 21, 2024
1 parent 264165e commit f425e87
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ using Multibody
using Documenter
using CairoMakie
ENV["JULIA_DEBUG"]=Documenter # Enable this for debugging
ENV["DOCS_BUILD"] = true # used to lower the default frame rate in animations for the docs

DocMeta.setdocmeta!(Multibody, :DocTestSetup, :(using Multibody); recursive = true)

Expand Down
2 changes: 1 addition & 1 deletion docs/src/examples/kinematic_loops.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Multibody.jl supports automatic 3D rendering of mechanisms, we use this feature

```@example kinloop
import CairoMakie
Multibody.render(fourbar, sol, 0:0.033:10; x=4, y=-1, z=4, lookat=[0, -1, 0], filename = "fourbar.gif") # Use "fourbar.mp4" for a video file
Multibody.render(fourbar, sol, 0:0.05:10; x=4, y=-1, z=4, lookat=[0, -1, 0], filename = "fourbar.gif") # Use "fourbar.mp4" for a video file
nothing # hide
```

Expand Down
13 changes: 11 additions & 2 deletions ext/Render.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,27 @@ function default_scene(x,y,z; lookat=Vec3f(0,0,0),up=Vec3f(0,1,0),show_axis=fals
scene, fig
end

function default_framerate(filename)
if parse(Bool, get(ENV, "DOCS_BUILD", "false"))
return 20
elseif lowercase(last(splitext(filename))) == ".gif"
return 25
else
return 30
end
end

function render(model, sol,
timevec::Union{AbstractVector, Nothing} = nothing;
framerate = 30,
filename = "multibody_$(model.name).mp4",
framerate = default_framerate(filename),
x = 2,
y = 0.5,
z = 2,
lookat = Vec3f(0,0,0),
up = Vec3f(0,1,0),
show_axis = false,
timescale = 1.0,
filename = "multibody_$(model.name).mp4",
kwargs...
)
scene, fig = default_scene(x,y,z; lookat,up,show_axis)
Expand Down

0 comments on commit f425e87

Please sign in to comment.