Skip to content

Instantly share code, notes, and snippets.

@videlais

videlais/script.rpy Secret

Created Jul 26, 2018
Embed
What would you like to do?
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