• Stars
    star
    177
  • Rank 215,985 (Top 5 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 13 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A python module to clear up SVG files, especially those created in Inkscape

Python program to clean up SVG files, particularly those created by Inkscape or Illustrator

--- Current Functionality ---

Remove attributes

Remove attributes with a given name, e.g. remove 'id' attributes, which often aren't used.

Remove comments

Removes all comments.

Remove elements

Remove elements by their tag name.

Remove namespaces

Remove all attributes associated with a given namespace, e.g. remove 'sodipodi' attributes created by Inkscape.

Remove redundant groups

Move child elements outdside of group with no attributes, then delete group.

Set decimal places

Rewrite attributes to a given number of decimal places.
Strip out unnecessary trailing zeros.
  • Attributes
    • x, y, x1, y2, x2, y2
    • cx, cy
    • r, rx, ry
    • width, height
    • points
    • d

Apply transformations

Applies transformations to elements so the attribute can be removed.
  • Translation

    • In the form

      • comma: (12,34)
      • space(s): (12 34)
      • comma and space(s): (12, 34), (12 ,34), (12 , 34)
      • decimal: (1.2, 3.4)
      • negative: (-1.2, -3.4)
    • Shapes

      • line
      • rect
      • circle, ellipse
      • polyline, polygon
      • path (not fully tested)
      • g (not fully tested)
  • Scale

    • Shapes
      • path
      • rect

CSS stlying

Convert individual style attributes to CSS styling.
Remove default styles.

--- To Do ---

Remove namespaces

Remove xml namespace if possible

Groups

Remove unnecessary groups
Remove unnecessary text groups
Add groups in make styling and transforms more efficient

Transformations

  • Translation

    • In the form

      • single: (12)
    • Shapes

      • text
      • tspan
  • Rotation

    • Shapes
      • path
      • polyline/polygon
      • line
      • circle
      • rect -> polygon/path?
  • Scale

    • Shapes
      • polyline/polygon
      • line
      • circle -> ellipse?
  • SkewX and SkewY

    • Shapes
      • line
      • path
      • polyline/polygon
      • rect -> polygon/path?
      • circle -> path arc?
  • Matrix

    • Shapes
      • line
      • path
      • polyline/polygon
      • rect -> polygon/path?

CSS styling

Need to check whether style element already exists and whether class names already exist.
Ideally find most efficient way to class elements for styling.

License

More Repositories

1

code-for-blog

Code for various tutorials and programs I've written about on my blog
Python
158
star
2

Pygame3D

Set of modules that use Pygame to display 3D graphics
Python
65
star
3

SVG-optimiser.js

An online SVG optimiser using Javascript and jQuery
JavaScript
50
star
4

Cell-Simulation

Python simulation of a single-celled organism
Python
46
star
5

DrawSVG

Python module to generate SVG files
Python
36
star
6

InteractiveSVG.js

Library for quickly generating interactive SVGs
JavaScript
35
star
7

SVG-Editor

JQuery based SVG editing and optimising tool
JavaScript
17
star
8

drawSVG.js

A Javascript library for easily generating SVG images.
JavaScript
6
star
9

Pinyinizer

Convert hanzi or pinyin with tone numbers to pinyin with tone marks. For an online version see the link below.
Python
4
star
10

blog2017

Attempting to use Wagtail to make myself a new site.
JavaScript
3
star
11

atomic.js

A Javascript library for building simple atomic simulations.
JavaScript
3
star
12

bloops

A simple ecosystem evolution simulation
JavaScript
2
star
13

SVueG

Building interactive SVG diagrams with Vue.js
JavaScript
2
star
14

vue-animation-studio

Vue app for building animations
JavaScript
1
star
15

unhinged-accordion-builder

Tool for building unhinged accordion books
JavaScript
1
star
16

SVGVG

SVG Vue Graphs
JavaScript
1
star
17

running-chart

Generate an SVG chart showing running times and distances
Python
1
star
18

xiab

Python
1
star
19

evolve-image

Using genetic algorithms to create stylised versions of images
Python
1
star
20

KA-Programs

The programs I've created using Khan Academy's computer science environment
JavaScript
1
star
21

Sentence-Generator

Generates English sentences and tests whether input is a valid Chinese translation
Python
1
star
22

darwin-drawing

Drawing animals with evolvable parameters
JavaScript
1
star
23

bloops-canvas

Ecology and evolution simulation using Javascript and canvas
JavaScript
1
star
24

canvas3D.js

Javascript library for making interactive 3D programs with the canvas
JavaScript
1
star
25

dungeon-crawler

HTML + JS dungeon crawler game
JavaScript
1
star