Permalink
Browse files

Add frame rate option to player. WARNING: At the moment this is a pla…

…yback-only feature, so it is not saved to the file!

This commit is progress on issue #1.

Future todos:
* Support higher-resolution frame rates to allow for PAL etc.
* Submillisecond timing for playback, right now it can have an error of up to 0.5ms per frame, which adds up
  • Loading branch information...
1 parent 406483f commit 7511913a9fb05d9627c59dd1e826077de949b7a6 @davissorenson davissorenson committed May 8, 2013
Showing with 18 additions and 8 deletions.
  1. +1 −6 README.animation
  2. +16 −2 gui/animationwindow.py
  3. +1 −0 lib/animation.py
View
7 README.animation
@@ -16,12 +16,7 @@ sheet that animation studios used in the old days. You can access it
from the Animation menu.
Animation is usually played at 24 frames per second, but animators can
-choose to draw less, using the same drawing for subsecuent frames. An
-animation drawing is called a cel. If the animator uses the same cel
-in two subsecuent frames, we say that the animation is on twos. The
-"exposure" term comes from the old days, when a camera operator had to
-expose the same cel two or more times, reading this information from
-the sheet.
+choose a different frame rate. Warining: This is not saved to the file yet!
In MyPaint X-Sheet, use the Add Cel button found in the controls of
the Animation window. You can also use the Animation menu, or press
View
18 gui/animationwindow.py
@@ -190,6 +190,13 @@ def opacity_checkbox(attr, label, tooltip=None):
opacity_checkbox('other keys', _('Other keys'), _("Show the other keys cels."))
opacity_checkbox('other', _('Other'), _("Show the rest of the cels."))
+ framerate_adjustment = gtk.Adjustment(value=24, lower=1, upper=120, step_incr=1.0)
+ self.framerate_entry = gtk.SpinButton(adjustment=framerate_adjustment)
+ framerate_lbl = gtk.Label(_('Frame rate:'))
+ framerate_hbox = gtk.HBox()
+ framerate_hbox.pack_start(framerate_lbl, expand=False)
+ framerate_hbox.pack_start(self.framerate_entry, expand=False)
+
icons_cb = gtk.CheckButton(_("Small icons"))
icons_cb.set_active(self.app.preferences.get("xsheet.small_icons", False))
icons_cb.connect('toggled', self.on_smallicons_toggled)
@@ -216,6 +223,7 @@ def opacity_checkbox(attr, label, tooltip=None):
controls_vbox.pack_start(editbuttons_hbox, expand=False)
preferences_vbox = gtk.VBox()
+ preferences_vbox.pack_start(framerate_hbox, expand=False)
preferences_vbox.pack_start(icons_cb, expand=False)
preferences_vbox.pack_start(play_lightbox_cb, expand=False)
preferences_vbox.pack_start(showprev_cb, expand=False)
@@ -457,8 +465,14 @@ def _play_animation(self, from_first_frame=True, use_lightbox=False):
self.ani.frames.select(0)
self._change_player_buttons()
self.ani.hide_all_frames()
- # add a 24fps (almost 42ms) animation timer:
- gobject.timeout_add(42, self._call_player, use_lightbox)
+ # animation timer
+ ms_per_frame = int(round(1000.0/self.framerate_entry.get_value()))
+
+ # show first frame immediately, otherwise there's a single frame delay
+ # @TODO: it seems to wait one frame before stopping too
+ self._call_player(use_lightbox)
+
+ gobject.timeout_add(ms_per_frame, self._call_player, use_lightbox)
def on_animation_play(self, button):
self.ani.play_animation()
View
1 lib/animation.py
@@ -32,6 +32,7 @@ class Animation(object):
def __init__(self, doc):
self.doc = doc
self.frames = None
+ self.framerate = 24.0
self.cleared = False
# For reproduction, "play", "pause", "stop":

0 comments on commit 7511913

Please sign in to comment.