Skip to content

Instantly share code, notes, and snippets.

@videlais
Created July 26, 2018 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save videlais/144d07068f62af7b78889943e23ede8b to your computer and use it in GitHub Desktop.
Save videlais/144d07068f62af7b78889943e23ede8b to your computer and use it in GitHub Desktop.
User-Defined Displayable
init python:
class DrawImage(renpy.Displayable):
def __init__(self, child, opaque_distance, transparent_distance, **kwargs):
# Pass additional properties on to the renpy.Displayable
# constructor.
super(DrawImage, self).__init__(**kwargs)
# The child.
self.child = renpy.displayable(child)
# The width and height of us, and our child.
self.width = 0
self.height = 0
def render(self, width, height, st, at):
# Create a transform
t = Transform(child=self.child)
# Create a render from the child.
child_render = renpy.render(t, width, height, st, at)
# Get the size of the child.
self.width, self.height = child_render.get_size()
# Create the render we will return.
render = renpy.Render(self.width, self.height)
# Blit (draw) the child's render to our render.
render.blit(child_render, (0, 0))
# Return the render.
return render
screen draw_image:
add DrawImage("logo.png", 100, 200):
xalign 0.5
yalign 0.5
label start:
show screen draw_image
"Let's draw an image!"
return
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment