static bool Animate() { if (walking) { current_frame_num += FRAME_STEP; if (current_frame_num > WALK_CYCLE_END) { num_walks++; if (num_walks > 10) { num_walks = 0; walking = false; current_frame_num = DEATH_CYCLE_START; } else { current_frame_num = WALK_CYCLE_START; } } } else /* dying */ { if (current_frame_num == DEATH_CYCLE_END) { death_timer++; if (death_timer == 30) { death_timer = 0; walking = true; current_frame_num = WALK_CYCLE_START; } } else { current_frame_num++; } } byte[] pixbuf_data = CreatePixbufData(grp.GetFrame(current_frame_num), grp.Width, grp.Height, Palette.default_palette); Gdk.Pixbuf temp = new Gdk.Pixbuf(pixbuf_data, Colorspace.Rgb, false, 8, grp.Width, grp.Height, grp.Width * 3, null); current_frame = temp.ScaleSimple(grp.Width * 2, grp.Height * 2, InterpType.Nearest); temp.Dispose(); drawing_area.QueueDraw(); return(true); }
public bool OnEvent (Widget w) { if (begin_buffer == null) { begin_buffer = new ImageInfo (begin, w); //.Allocation); } if (end_buffer == null) { end_buffer = new ImageInfo (end, w); //.Allocation); } w.QueueDraw (); w.GdkWindow.ProcessUpdates (false); TimeSpan elapsed = DateTime.UtcNow - start; double fraction = elapsed.Ticks / (double) duration.Ticks; return fraction < 1.0; }
public bool OnEvent(Widget w) { if (begin_buffer == null) { begin_buffer = new ImageInfo (begin, w); //.Allocation); } if (end_buffer == null) { end_buffer = new ImageInfo (end, w); //.Allocation); start = DateTime.UtcNow; } w.QueueDraw (); TimeSpan elapsed = DateTime.UtcNow - start; fraction = elapsed.Ticks / (double) duration.Ticks; frames++; return fraction < 1.0; }
public bool OnEvent(Widget w) { Gdk.Rectangle viewport = w.Allocation; if (buffer == null) { double scale = Math.Max (viewport.Width / (double) info.Bounds.Width, viewport.Height / (double) info.Bounds.Height); scale *= 1.2; buffer = new ImageInfo (info, w, new Gdk.Rectangle (0, 0, (int) (info.Bounds.Width * scale), (int) (info.Bounds.Height * scale))); start = DateTime.UtcNow; //w.QueueDraw (); zoom = 1.0; } double percent = Math.Min ((DateTime.UtcNow - start).Ticks / (double) duration.Ticks, 1.0); int n_x = (int) Math.Floor ((buffer.Bounds.Width - viewport.Width) * percent); int n_y = (int) Math.Floor ((buffer.Bounds.Height - viewport.Height) * percent); if (n_x != pan_x || n_y != pan_y) { //w.GdkWindow.Scroll (- (n_x - pan_x), - (n_y - pan_y)); w.QueueDraw (); w.GdkWindow.ProcessUpdates (false); Console.WriteLine ("{0} {1} elapsed", DateTime.UtcNow, DateTime.UtcNow - start); } pan_x = n_x; pan_y = n_y; return percent < 1.0; }
public bool OnEvent(Widget w) { if (frames == 0) { start = DateTime.UtcNow; Gdk.Rectangle viewport = w.Allocation; zoom = Math.Max (viewport.Width / (double) info.Bounds.Width, viewport.Height / (double) info.Bounds.Height); zoom *= 1.2; x_offset = (viewport.Width - info.Bounds.Width * zoom); y_offset = (viewport.Height - info.Bounds.Height * zoom); pan_x = 0; pan_y = 0; w.QueueDraw (); } frames ++; double percent = Math.Min ((DateTime.UtcNow - start).Ticks / (double) duration.Ticks, 1.0); double x = x_offset * percent; double y = y_offset * percent; if (w.IsRealized){ w.GdkWindow.Scroll ((int)(x - pan_x), (int)(y - pan_y)); pan_x = x; pan_y = y; //w.GdkWindow.ProcessUpdates (false); } return percent < 1.0; }
public static void VidgetBackendInvalidate(this Widget widget) { widget.QueueDraw(); }