Hans Petter Langtangen 11 yıl önce
ebeveyn
işleme
3839f1950d

+ 32 - 40
doc/src/tut/basics.do.txt

@@ -291,7 +291,6 @@ Terminal> dot -Tpng -o fig.png fig.dot
 
 FIGURE: [fig-tut/vehicle0_hier1, width=500 frac=0.8] Hierarchical relation between figure objects. label{sketcher:fig:vehicle0:hier1}
 
-
 The call `fig.graphviz_dot('fig', classname=True)` makes a `fig.dot` file
 where the class type of each object is also visible, see
 Figure ref{sketcher:fig:vehicle0:hier2}. The ability to write out the
@@ -326,7 +325,7 @@ fig['vehicle']['body']['over'].set_linewidth(14)
 fig['vehicle']['body']['over']['rectangle'].linewidth = 4
 !ec
 The last line accesses the `Curve` object directly, while the line above,
-accesses the `Rectangle` object which will then set the linewidth of
+accesses the `Rectangle` object, which will then set the linewidth of
 its `Curve` object, and other objects if it had any.
 The result of the actions above is shown in Figure ref{sketcher:fig:vehicle0:v2}.
 
@@ -405,55 +404,48 @@ We can also ask `animate` to store each frame in a file:
 files = animate(fig, tp, move_vehicle, moviefiles=True,
                 pause_per_frame=0.2)
 !ec
-The `files` variable, here `'tmp_frame*.png'`,
-is a string expressing the family of frame files.
-This string can be used directly in commands for making a movie
-out of the files.
-A simple approach is to generate an animated GIF file with help of
-the `convert` program from the ImageMagick software suite:
+The `files` variable, here `'tmp_frame_%04d.png'`,
+is the printf-specification used to generate the individual
+plot files. We can use this specification to make a video
+file via `ffmpeg` (or `avconv` on Debian-based Linux systems such
+as Ubuntu). Videos in the Flash and WebM formats can be created
+by
+
+!bc sys
+Terminal> ffmpeg -r 12 -i tmp_frame_%04d.png -c:v flv anim.flv
+Terminal> ffmpeg -r 12 -i tmp_frame_%04d.png -c:v libvpx anim.webm
+!ec
+An animated GIF movie can also be made using the `convert` program
+from the ImageMagick software suite:
+
 !bc sys
 Terminal> convert -delay 20 tmp_frame*.png anim.gif
 Terminal> animate anim.gif  # play movie
 !ec
-The delay between frames governs the speed of the movie.
-The `anim.gif` file can be embedded in a web page and shown as
-a movie when the page is loaded into a web browser (just insert
-`<img src="anim.gif">` in the HTML code).
+The delay between frames, in units of 1/100 s,
+governs the speed of the movie.
+To play the animated GIF file in a web page, simply insert
+`<img src="anim.gif">` in the HTML code.
+
+The individual PNG frames can be directly played in a web
+browser by running
 
-The tool `ffmpeg` can alternatively be used to create an MPEG movie, e.g.,
 !bc sys
-Terminal> ffmpeg -i "tmp_frame_%04d.png" -b 800k -r 25 \
-          -vcodec mpeg4 -y -qmin 2 -qmax 31 anim.mpeg
+Terminal> scitools movie output_file=anim.html fps=5 tmp_frame*
 !ec
-An easy-to-use Python interface to movie-making tools is provided by the
-SciTools package:
+or calling
+
 !bc pycod
 from scitools.std import movie
-
-# HTML page showing individual frames
 movie(files, encoder='html', output_file='anim.html')
+!ec
+in Python. Load the resulting file `anim.html` into a web browser
+to play the movie.
 
-# Standard GIF file
-movie(files, encoder='convert', output_file='anim.gif')
-
-# AVI format
-movie('tmp_*.png', encoder='ffmpeg', fps=4,
-      output_file='anim.avi') # requires ffmpeg package
-
-# MPEG format
-movie('tmp_*.png', encoder='ffmpeg', fps=4,
-      output_file='anim2.mpeg', vodec='mpeg2video')
-# or
-movie(files, encoder='ppmtompeg', fps=24,
-      output_file='anim.mpeg')  # requires the netpbm package
-!ec
-When difficulties with encoders and players arise, the simple
-web page for showing a movie, here `anim.html` (generated by the
-first `movie` command above), is a safe method that you always
-can rely on.
-You can try loading `anim.html` into a web browser, after first
-having run the present example in the file
-"`vehicle0.py`": "${src_path_pysketcher}/vehicle0.py". Alternatively, you can view a ready-made "movie": "${src_path_tut}/mov-tut/anim.html_vehicle0/anim.html".
+Try to run "`vehicle0.py`": "${src_path_pysketcher}/vehicle0.py" and
+then load `anim.html` into a browser, or play one of the `anim.*`
+video files.  Alternatively, you can view a ready-made "movie":
+"${src_path_tut}/mov-tut/anim.html_vehicle0/anim.html".
 
 === Animation: Rolling the Wheels ===
 label{sketcher:vehicle1:anim}

BIN
doc/src/tut/fig-tut/Vehicle0_hier1.png


BIN
doc/src/tut/fig-tut/Vehicle0_hier2.pdf


BIN
doc/src/tut/fig-tut/vehicle0.pdf


BIN
doc/src/tut/fig-tut/vehicle0_dim.pdf


BIN
doc/src/tut/fig-tut/vehicle0_hier1.pdf


Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 13027
doc/src/tut/fig-tut/vehicle0_hier2.eps


BIN
doc/src/tut/fig-tut/vehicle0_hier2.png


BIN
doc/src/tut/fig-tut/vehicle1.pdf


BIN
doc/src/tut/fig-tut/wheel_on_inclined_plane.pdf


+ 6 - 2
doc/src/tut/implementation.do.txt

@@ -50,7 +50,7 @@ class Rectangle(Shape):
         self.shapes = {'rectangle': Curve(x,y)}
 !ec
 
-Any subclass of `Shape` will have a constructor which takes geometric
+Any subclass of `Shape` will have a constructor that takes geometric
 information about the shape of the object and creates a dictionary
 `self.shapes` with the shape built of simpler shapes. The most
 fundamental shape is `Curve`, which is just a collection of $(x,y)$
@@ -388,7 +388,7 @@ behavior with respect to drawing. Only the `Curve` object has a different
 
 Understanding recursion is usually a challenge. To get a better idea of
 how recursion works, we have equipped class `Shape` with a method `recurse`
-which just visits all the objects in the `shapes` dictionary and prints
+that just visits all the objects in the `shapes` dictionary and prints
 out a message for each object.
 This feature allows us to trace the execution and see exactly where
 we are in the hierarchy and which objects that are visited.
@@ -468,7 +468,11 @@ that `vehicle` is the parent of `body` and that `body` is a child of
 `vehicle`. The term *node* is also often used to describe an element
 in a tree. A node may have several other nodes as *descendants*.
 
+<<<<<<< HEAD
 FIGURE: [fig-tut/Vehicle0_hier2, width=600 frac=0.8] Hierarchy of figure elements in an instance of class `Vehicle0`. label{sketcher:fig:Vehicle0:hier2}
+=======
+FIGURE: [fig-tut/Vehicle0_hier2, width=600] Hierarchy of figure elements in an instance of class `Vehicle0`. label{sketcher:fig:Vehicle0:hier2}
+>>>>>>> de4bcb4860ba1b305e7896fea87a27f83ff8390b
 
 Recursion is the principal programming technique to traverse tree structures.
 Any object in the tree can be viewed as a root of a subtree. For

+ 0 - 10
doc/src/tut/make.sh

@@ -10,16 +10,6 @@ fi
 main=main_sketcher
 doconce format html $main
 
-cp .ptex2tex.cfg-primer .ptex2tex.cfg
-doconce format latex $main -DPRIMER_BOOK
-ptex2tex $main
-latex $main
-makeindex $main
-latex $main
-latex $main
-dvipdf $main
-mv $main.pdf ${main}_primer.pdf
-
 cp .ptex2tex.cfg-minted .ptex2tex.cfg
 doconce format pdflatex $main
 ptex2tex -DMINTED $main

+ 6 - 18
doc/src/tut/src-tut/vehicle0.py

@@ -67,8 +67,11 @@ def move(t, fig):
 files = animate(fig, tp, move, moviefiles=True,
                 pause_per_frame=0)
 
-os.system('convert -delay 20 %s anim.gif' % files)
-os.system('ffmpeg -i "tmp_frame_%04d.png" -b 800k -r 25 -vcodec mpeg4 -y -qmin 2 -qmax 31 anim.mpeg')
+files_wildcard = files.split('%')[0]) + '*.png'
+os.system('convert -delay 20 %s* anim.gif' % (files_wildcard)
+os.system('ffmpeg -r 12 -i %s -c:v flv anim.flv' % files)
+os.system('ffmpeg -r 12 -i %s -c:v libvpx anim.webm' % files)
+os.system('ffmpeg -r 12 -i %s -c:v libtheora anim.ogg' % files)
 
 try:
     from scitools.std import movie
@@ -78,22 +81,7 @@ except ImportError:
         'scitools is installed by sudo apt-get install python-scitools\n'
         'on Ubuntu or by sudo python setup.py install if the code is\n'
         'downloaded from http://code.google.com/p/scitools.')
-
 # HTML page showing individual frames
-movie(files, encoder='html', fps=4, output_file='anim.html')
-
-# Standard GIF file
-movie(files, encoder='convert', fps=4, output_file='anim2.gif')
-
-# AVI format
-movie('tmp_*.png', encoder='ffmpeg', fps=4,
-      output_file='anim.avi') # requires ffmpeg package
-
-# MPEG format
-movie('tmp_*.png', encoder='ffmpeg', fps=4,
-      output_file='anim3.mpeg', vodec='mpeg2video')
-# or
-movie(files, encoder='ppmtompeg', fps=24,
-      output_file='anim2.mpeg')  # requires the netpbm package
+movie(files_wildcard, encoder='html', fps=4, output_file='anim.html')
 
 raw_input()

+ 7 - 1
doc/src/tut/src-tut/vehicle1.py

@@ -68,7 +68,13 @@ def move(t, fig):
 files = animate(fig, tp, move, moviefiles=True,
                 pause_per_frame=0)
 
+files_wildcard = files.split('%')[0]) + '*.png'
+os.system('convert -delay 20 %s* anim.gif' % (files_wildcard)
+os.system('ffmpeg -r 12 -i %s -c:v flv anim.flv' % files)
+os.system('ffmpeg -r 12 -i %s -c:v libvpx anim.webm' % files)
+os.system('ffmpeg -r 12 -i %s -c:v libtheora anim.ogg' % files)
+os.system('ffmpeg -r 12 -i %s -c:v flv anim.flv' % files)
 from scitools.std import movie
-movie(files, encoder='html', output_file='anim')
+movie(files_wildcard, encoder='html', output_file='anim')
 
 raw_input()

BIN
doc/tutorial/html/_images/vehicle0_hier2.png


BIN
doc/tutorial/html/html/_images/vehicle0_hier2.png


+ 1 - 1
pysketcher/shapes.py

@@ -125,7 +125,7 @@ def animate(fig, time_points, action, moviefiles=False,
             drawing_tool.savefig('%s%04d.png' % (framefilestem, n))
 
     if moviefiles:
-        return '%s*.png' % framefilestem
+        return '%s%%04d.png' % framefilestem
 
 
 class Shape: