Skip to content

Instantly share code, notes, and snippets.

@zgoda
zgoda / svgsurf.py
Last active Dec 27, 2020
Load svg into Pygame image using pynanosvg (https://github.com/ethanhs/pynanosvg)
View svgsurf.py
from svg import Parser, Rasterizer
import pygame
import sys
def load_svg(filename, mode='RGBA', scale=None, size=None, clip_from=None, fit_to=None):
"""Returns Pygame Image object from rasterized SVG
If scale (float) is provided and is not None, image will be scaled.