commit dd52011a929bd3c3921c26b1545e4c9e07cb8942
parent 3f419be9f4a6594ff17751aa7a85fdc6ef070cd2
Author: Anders Damsgaard <andersd@riseup.net>
Date: Mon, 6 Nov 2017 19:37:46 -0500
add `trim` argument to render(), adjust initialization in shear example
Diffstat:
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/examples/shear.jl b/examples/shear.jl
@@ -6,9 +6,9 @@ import Granular
################################################################################
sim = Granular.createSimulation(id="shear-init")
-# Generate 10 grains along x and 100 grains along y, with radii between 0.2 and
+# Generate 10 grains along x and 50 grains along y, with radii between 0.2 and
# 1.0 m.
-Granular.regularPacking!(sim, [10, 100], 0.2, 1.0)
+Granular.regularPacking!(sim, [10, 50], 0.2, 1.0)
# Create a grid for contact searching spanning the extent of the grains
Granular.fitGridToGrains!(sim, sim.ocean)
@@ -38,14 +38,7 @@ Granular.plotGrainSizeDistribution(sim)
Granular.run!(sim)
# Try to render the simulation if `pvpython` is installed on the system
-Granular.render(sim)
-
-
-
-
-
-
-
+Granular.render(sim, trim=false)
diff --git a/src/io.jl b/src/io.jl
@@ -921,12 +921,14 @@ from the shell using the supplied `pvpython` argument.
script uses the pvpython in the system PATH.
* `images::Bool`: render images to disk (default: true)
* `animation::Bool`: render animation to disk (default: false)
+* `trim::Bool`: trim images in animated sequence (default: true)
* `reverse::Bool`: if `images=true` additionally render reverse-animated gif
(default: false)
"""
function render(simulation::Simulation; pvpython::String="pvpython",
images::Bool=true,
animation::Bool=false,
+ trim::Bool=true,
reverse::Bool=false)
writeParaviewPythonScript(simulation, save_animation=animation,
@@ -937,7 +939,12 @@ function render(simulation::Simulation; pvpython::String="pvpython",
# if available, use imagemagick to create gif from images
if images
try
- run(`convert -trim +repage -delay 10 -transparent-color white
+ trim_string = ""
+ if trim
+ trim_string = "-trim"
+ end
+ run(`convert $trim_string +repage -delay 10
+ -transparent-color white
-loop 0 $(simulation.id)/$(simulation.id).'*'.png
$(simulation.id)/$(simulation.id).gif`)
if reverse