You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-5Lines changed: 37 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,14 +3,32 @@
3
3
A simple set of python functions to help working with animated SVGs exported from Illustrator. More features coming soon!
4
4
We used it to create animations like this.
5
5
6
-

7
6
[Viva La Velo](https://parall.ax/viva-le-velo)
8
7
8
+

9
+
9
10
10
11
## Overview
11
12
12
13
Part of animating with SVGs is getting references to elements in code and passing them to animation functions. For complicated animations this becomes difficult and hand editing SVG code is slow and gets overwritten when your artwork updates. We decided to write a post-processer for SVGs produced by Illustrator to help speed this up. Layer names are used to create attributes, classes and ID's making selecting them in JS or CSS far easier.
13
14
15
+
This is the what the svg code looks like before and after the processing step.
@@ -25,7 +43,7 @@ Create an Illustrator file, add an element and change its layer name to say `#cl
25
43
26
44
Create a HTML file as below. The import statements inline the SVG inline into our HTML file so we don't have to do any copy and pasting. Not strictly neccessary but makes the workflow a little easier. Save it as `animation.html`.
27
45
28
-
```
46
+
```html
29
47
<!DOCTYPE html>
30
48
<html>
31
49
<head>
@@ -42,7 +60,7 @@ Create a HTML file as below. The import statements inline the SVG inline into ou
42
60
43
61
Open the file called `run.py`. Here you can edit how the SVGs will be processed. The default looks like this. The sections below describe what the various options do.
@@ -68,9 +86,11 @@ Processes a single SVG and places it in the supplied destination directory. The
68
86
Converts layer names as defined in Illustator into attributes. Begin the layer name with a '#' to indicate the layer should be parsed.
69
87
For example `#id=my-id, class=my-class my-other-class, role=my-role` ...etc.
70
88
This is useful for fetching elements with Javascript as well as marking up elements for accessibility - see this [CSS Tricks Accessible SVG ](https://css-tricks.com/accessible-svgs/) article.
71
-
You can also use `origin=100 100` to set origins for rotating/scaling with GSAP (expands to data-svg-origin).
72
89
NOTE: Requires using commas to separate the attributes as that makes the parsing code a lot simpler :)
73
90
91
+
+**expand_origin:**
92
+
Allows you to use `origin=100 100` to set origins for rotating/scaling with GSAP (expands to data-svg-origin).
93
+
74
94
+**namespace:**
75
95
Appends a namespace to classes and IDs if one is provided. Useful for avoiding conflicts with other SVG files for things like masks and clipPaths.
76
96
@@ -80,6 +100,18 @@ Removes unneeded whitespace. We don't do anything fancier than that so as to not
80
100
+**attributes:**
81
101
An object of key:value strings that will be applied as attributes to the root SVG element.
82
102
103
+
+**title:**
104
+
Sets the title or removes it completely when set to `false`
105
+
106
+
+**description:**
107
+
Sets the description or removes it completely when set to `false`
108
+
109
+
+**convert_svg_text_to_html:**
110
+
Converts SVG text in HTML text via the foriegn object tag reducing file bloat and allowing you to style it with CSS. Requires the text be grouped inside a rectangle with the layer name set to `#TEXT`.
111
+
112
+
+**spirit:**
113
+
Expands `#spirit=my-id` to `data-spirit-id` when set to `true` for use with the [Spirit animation app](<https://spiritapp.io/>)
114
+
83
115
84
116
### inline\_svg(src\_path, dst\_path)
85
-
In order to animate SVGs code needs to be placed in-line. This function will look at the source HTML and include any references defined by `//import` statements to SVGs that it finds.
117
+
In order to animate SVGs markup needs to be placed in-line with HTML. This function will look at the source HTML file and include any references defined by `//import` statements to SVGs that it finds.
0 commit comments