Skip to content

Commit

Permalink
Merge pull request #223 from googlefonts/ungroup
Browse files Browse the repository at this point in the history
Restructure processing of clip, transform, and group
  • Loading branch information
rsheeter authored Jun 30, 2021
2 parents a9260f0 + 6684ac2 commit d21f5b3
Show file tree
Hide file tree
Showing 59 changed files with 847 additions and 590 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ Tool to simplify SVGs. Converts an input svg into a "pico" svg:

* Exactly 1 `<defs>` element, first child of root
* Only gradients defined under `<defs>`
* Only `<path>` elements without stroke or clipping after the initial `<defs>`
* After the initial `<defs>`, only `<g>` and `<path>`
* `<g>` is eliminated when possible, but may be retained for opacity
* Only absolute coordinates
* Only commands that specify full coordinates, no shorthand (H, S, etc)

Clip paths and strokes are rendered into equivalent paths using [Skia](https://skia.org/) via [skia-pathops](https:/fonttools/skia-pathops), `<use>` references are materialized, etc.

Expand Down
5 changes: 5 additions & 0 deletions src/picosvg/geometric_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,8 @@ def _overlap(start1, end1, start2, end2):
if x1 != x2 and y1 != y2:
return Rect(x1, y1, x2 - x1, y2 - y1)
return None

def normalized_diagonal(self):
# used for computing percentages of lengths relative to the SVG viewport:
# https://www.w3.org/TR/SVG2/coords.html#Units
return math.hypot(self.w, self.h) / math.sqrt(2)
Loading

0 comments on commit d21f5b3

Please sign in to comment.