def on_draw(self, index: int, widget: Gtk.DrawingArea, ctx: cairo.Context): w16 = self._surfaces[index] ctx.set_source_rgb(0, 0, 0) ctx.rectangle(0, 0, *widget.get_size_request()) ctx.fill() ctx.set_source_surface(w16) ctx.get_source().set_filter(cairo.Filter.NEAREST) ctx.paint()
def on_draw_example_placeholder_draw(self, widget: Gtk.DrawingArea, ctx: cairo.Context): sprite, x, y, w, h = self._sprite_provider.get_actor_placeholder( 9999, 0, lambda: GLib.idle_add(lambda: self.builder.get_object('draw_example_placeholder').queue_draw()) # type: ignore ) ctx.set_source_surface(sprite) ctx.get_source().set_filter(cairo.Filter.NEAREST) ctx.paint() if widget.get_size_request() != (w, h): widget.set_size_request(w, h)
def on_draw_sprite_draw(self, widget: Gtk.DrawingArea, ctx: cairo.Context): scale = 2 sprite, x, y, w, h = self._sprite_provider.get_for_item(self.item_p, lambda: GLib.idle_add(widget.queue_draw)) ctx.scale(scale, scale) ctx.set_source_surface(sprite) ctx.get_source().set_filter(cairo.Filter.NEAREST) ctx.paint() ctx.scale(1 / scale, 1 / scale) if widget.get_size_request() != (w, h): widget.set_size_request(w * scale, h * scale) return True
def on_draw_sprite_draw(self, widget: Gtk.DrawingArea, ctx: cairo.Context): if self.entry.entid > 0: sprite, x, y, w, h = self._sprite_provider.get_monster(self.entry.md_index, 0, lambda: GLib.idle_add(widget.queue_draw)) else: sprite, x, y, w, h = self._sprite_provider.get_error() ctx.set_source_surface(sprite) ctx.get_source().set_filter(cairo.Filter.NEAREST) ctx.paint() if widget.get_size_request() != (w, h): widget.set_size_request(w, h) return True
def on_draw_portrait_draw(self, widget: Gtk.DrawingArea, ctx: cairo.Context): scale = 2 portrait = self._portrait_provider.get(self.entry.md_index - 1, 0, lambda: GLib.idle_add(widget.queue_draw), True) ctx.scale(scale, scale) ctx.set_source_surface(portrait) ctx.get_source().set_filter(cairo.Filter.NEAREST) ctx.paint() ctx.scale(1 / scale, 1 / scale) if widget.get_size_request() != (IMG_DIM * scale, IMG_DIM * scale): widget.set_size_request(IMG_DIM * scale, IMG_DIM * scale) return True
def on_draw_sprite_draw(self, widget: Gtk.DrawingArea, ctx: cairo.Context): if not self._drawing_is_active: return True scale = 4 sprite, x, y, w, h = self._get_sprite_anim() ctx.scale(scale, scale) ctx.set_source_surface(sprite) ctx.get_source().set_filter(cairo.Filter.NEAREST) ctx.paint() ww, wh = widget.get_size_request() if ww < w or wh < h: widget.set_size_request(w * scale, h * scale) ctx.scale(1 / scale, 1 / scale) return True
def on_draw(self, subindex: int, widget: Gtk.DrawingArea, ctx: cairo.Context): scale = 2 portrait = self._portrait_provider.get( self.item_id, subindex, lambda: GLib.idle_add(widget.queue_draw), False) ctx.set_source_rgb(1, 1, 1) ctx.rectangle(0, 0, *widget.get_size_request()) ctx.fill() ctx.scale(scale, scale) ctx.set_source_surface(portrait) ctx.get_source().set_filter(cairo.Filter.NEAREST) ctx.paint() ctx.scale(1 / scale, 1 / scale) return True