Skip to content

Instantly share code, notes, and snippets.

View charlsagente's full-sized avatar

Carlos Perez charlsagente

View GitHub Profile
@charlsagente
charlsagente / svgsurf.py
Created March 1, 2019 04:36 — forked from zgoda/svgsurf.py
Load svg into Pygame image using pynanosvg (https://github.com/ethanhs/pynanosvg)
from svg import Parser, Rasterizer
def load_svg(filename, 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.
If size (w, h tuple) is provided, the image will be clipped to specified size.
If clip_from (x, y tuple) is provided, the image will be clipped from specified point.
If fit_to (w, h tuple) is provided, image will be scaled to fit in specified rect.