Skip to content

Lightweight library for arbitrary geometric SVG transformations

Notifications You must be signed in to change notification settings

josefondrej/svgecko

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🦎 SVGecko

Lightweight library for arbitrary geometric SVG transformations. Created because existing libraries had a hard time applying other than affine transformations to SVGs. So far only supports SVGs with absolute path commands.

Installation

In your terminal, run the following command:

pip install svgecko

Getting Started

The following code loads your svg file, shifts it by one unit in both the x and y directions, and plots the result.

import matplotlib.pyplot as plt

from svgecko.svg import SVG

# Load the SVG
svg_path = '/path/to/your/svg/file.svg'
svg = SVG.from_file(svg_path)

# Define the transformation and apply it to the SVG
transformation = lambda point: (point[0] + 1, point[1] + 1)
svg.transform(transformation=transformation, inplace=True)

# Plot the transformed SVG
image = svg.to_pil_image()
plt.imshow(image)
plt.show()

Roadmap

  • Support for angular rotation path commands
  • Support for relative path commands (for now as a workaround the relative paths can be converted to absolute using for example this tool)
  • Support for style positioning commands (e.g. translate)

About

Lightweight library for arbitrary geometric SVG transformations

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages