I've been making different experiments/demos with Nodezator and other Python libraries in order to identify programming tasks that have synergy with a node-based approach. This experiment shows what I've learned about Python and SVG images. What I learned is actually very useful regardless of whether you are using text-based or node-based Python.
Some people don't even know pygame/pygame-ce 2 has support for SVG. Although limited, SVG support in pygame can still be used to achieve a lot of advanced stuff. If you need more complete support, cairoSVG is a great alternative to render SVG graphics.
Because SVG is so versatile and is just really a text format, you can create complex smoothly antialiased shapes/paths with it by writing your own instructions. Like this, for instance, where SVG text is rendered as a still image (a pygame surface) with pygame-ce:
A ~10 min video showing my experiments:
Also a text post version (source code included).
Some people don't even know pygame/pygame-ce 2 has support for SVG. Although limited, SVG support in pygame can still be used to achieve a lot of advanced stuff. If you need more complete support, cairoSVG is a great alternative to render SVG graphics.
Because SVG is so versatile and is just really a text format, you can create complex smoothly antialiased shapes/paths with it by writing your own instructions. Like this, for instance, where SVG text is rendered as a still image (a pygame surface) with pygame-ce:
from io import BytesIO # standard lib import pygame svg_text = """ <svg width="300" height="200"> <rect x="0" y="0" width="300" height="200" fill="white" /> <circle cx="150" cy="100" r="60" fill="red" /> </svg> """.strip() svg_bytes = bytes(svg_text, encoding='utf-8') bytestream = BytesIO(svg_bytes) # or "with BytesIO(svg_bytes) as bytestream: ..." surface = pygame.image.load(bytestream)Here are relevant resources to know more about this:
A ~10 min video showing my experiments:
Also a text post version (source code included).