Commits

Mike Graham committed 3b52187

Try to test video making

  • Participants
  • Parent commits cb0eeab

Comments (0)

Files changed (2)

File nanocontact/post.py

 
 
 def movie(filename, t, r, h, h0=None, rlim=None, hlim=None, duration=10):
-    import ming # Optional dependency
+    from mech.fusion.swf import SwfData
 
     #XXX: reflection is done ugly. Improve it, maybe to use sprites.
 
         # later.
         h0s = hs
 
-    movie = ming.SWFMovie()
+    movie = SwfData()
 
-    h_equal_zero = ming.SWFShape()
-    h_equal_zero.setLine(25, 0, 0, 0)
-    h_equal_zero.movePenTo(0, ydim)
-    h_equal_zero.drawLineTo(xdim, ydim)
-    movie.add(h_equal_zero)
+    h_equal_zero = movie.new_shape()
+    h_equal_zero.graphics.lineStyle(3)
+    h_equal_zero.graphics.moveTo(0, ydim)
+    h_equal_zero.graphics.lineTo(xdim, ydim)
 
     rate = len(t) / duration
-    movie.setRate(rate)
-    movie.setDimension(xdim, ydim)
-
+    #movie.setRate(rate)
+    #movie.setDimension(xdim, ydim)
     for h_row, h0_row in izip(hs.T, h0s.T):
-        shape = ming.SWFShape()
-        shape.setLine(20, 0xff, 0, 0)
+        shape = movie.new_shape()
+        shape.graphics.lineStyle(3)
         _draw_all_reflected(shape, xs, h_row, xdim)
 
         if h0 is not None:
-            undeformed = ming.SWFShape()
-            undeformed.setLine(8, 0, 0xff, 0)
+            undeformed = movie.new_shape()
+            undeformed.graphics.lineStyle(3)
             _draw_all_reflected(undeformed, xs, h0_row, xdim)
 
-        to_remove = []
-        if h0 is not None:
-            to_remove.append(movie.add(undeformed))
-        to_remove.append(movie.add(shape))
+        movie.next_frame()
 
-        movie.nextFrame()
-
-        for shape in to_remove:
-            movie.remove(shape)
-
-    movie.save(filename)
+    with open(filename, 'wb') as f:
+        f.write(movie.serialize())
 
 def _draw_all_reflected(shape, xs, ys, xdim):
-    shape.movePenTo((-xs[-1] + xdim) * 0.5, ys[-1])
+    shape.graphics.moveTo(int((-xs[-1] + xdim) * 0.5), 
+                          int(ys[-1]))
 
     for x, y in chain(izip(reversed(-xs), reversed(ys)), izip(xs, ys)):
-        shape.drawLineTo((x + xdim) * 0.5, y)
+        shape.graphics.lineTo(int((x + xdim) * 0.5), 
+                              int(y))

File scripts/example.py

 TPa = 10e12 * Pa
 
 # Radial points
-meshnum = 512
+meshnum = 256
 max_radius = 700 * nm
 radius = numpy.linspace(0, max_radius, meshnum)
 radius += 0.5 * radius[1]
 profile = utils.rounded_cone(radius, 60, 5 * nm)
 
 # Time steps and rigid separation
-numsteps = 256
+numsteps = 32
 time = numpy.linspace(0, 1 * sec, numsteps)
 h0 = utils.constant_rate_h0(farthest=100 * nm,
                             closest=-50 * nm,
     print e
 
 print sim.dissipated_energy()
-sim.make_movie("video")
-sim.plot_F_delta("fdelta")
-sim.plot_F_indentation("findent")
 
+sim.make_movie('rabbit')
+#sim.plot_F_delta("fdelta")
+#sim.plot_F_indentation("findent")
+