I'd like to draw some simple shapes in my game using code instead of a bunch of pngs, to not increase the filesize too much. Is there a convenient way to do this? I remember doing this with a package called tkinter or something similar in pure python, but I'm still a bit confused with Ren'py.
By shapes I mean mainly circles and lines.
Drawing shapes using code
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Drawing shapes using code
My avatar art is a freebie by SilverHyena. Thanks a lot!
Re: Drawing shapes using code
I guess it depends on your definition of the word "convenient," but yes, it's certainly possible to draw shapes. You're probably looking for canvas(), which can be used from an instance of the Displayable class within render. It somewhat matches the calls from pygame.
So you can use it a bit like this:
This would potentially create a canvas on which a filled blue polygon and two lines appear (except the pointlist method is undefined here, so it wouldn't quite work).
So you can use it a bit like this:
Code: Select all
class myDisplay(renpy.Displayable):
def __init__(self, **kwargs):
renpy.Displayable.__init__(self, **kwargs)
def render(self, width, height, st, at):
render = renpy.Render(160, 160)
canvas = render.canvas()
pointlist = self.get_pointlist()
canvas.polygon("#003366", pointlist, width=0)
canvas.line("#000", (80, 10), (80, 80))
canvas.line("#000", (150, 45), (80, 80))
return renderRe: Drawing shapes using code
Ah, ok.
Yes, it's what I was looking for. Thanks a lot!
Yes, it's what I was looking for. Thanks a lot!
My avatar art is a freebie by SilverHyena. Thanks a lot!