Skip to content
Snippets Groups Projects
Commit 6c1ee06a authored by deepmurk's avatar deepmurk
Browse files

Belly Scaling WIP

Scaling
parent 6a9a8d43
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
'''
Application for "fixing" SVGs edited with Inkscape
These problems are addressed:
* Inkscape notoriously copies class styles into the object definitions.
https://bugs.launchpad.net/inkscape/+bug/167937
* Inkscape uses labels on layers. Layers are basically named groups.
Inkscape does not sync the group id with the layer label.
Usage Example:
python3 inkscape_svg_fixup.py vector_source.svg
Note:
The output of lxml differs greatly from standard SVG indentation.
Please open and save the file in Inkscape before committing.
'''
import lxml.etree as etree
import sys
def fix(tree):
# know namespaces
ns = {
'svg' : 'http://www.w3.org/2000/svg',
'inkscape' : 'http://www.inkscape.org/namespaces/inkscape'
}
# find document global style definition
# mangle it and interpret as python dictionary
style_element = tree.find('./svg:style',namespaces=ns)
style_definitions = style_element.text
pythonic_style_definitions = '{'+style_definitions.\
replace('\t.','"').replace('{','":"').replace('}','",').\
replace('/*','#')+'}'
styles = eval(pythonic_style_definitions)
# go through all SVG elements
for elem in tree.iter():
if (elem.tag == etree.QName(ns['svg'], 'g')):
# compare inkscape label with group element ID
l = elem.get(etree.QName(ns['inkscape'], 'label'))
if l:
i = elem.get('id')
if (i != l):
print("Overwriting ID %s with Label %s..."%(i, l))
elem.set('id', l)
# remove all offending style attributes
s = elem.get('style')
c = elem.get('class')
if (c and s):
s = s.lower()
c = c.split(' ')[0] # regard main style only
cs = ''
if c in styles:
cs = styles[c].strip('; ').lower()
if (c not in styles):
print("Object id %s references unknown style class %s."%(i,c))
else:
if (cs != s.strip('; ')):
print("Style %s removed from object id %s differed from class %s style %s."%(s,i,c,cs))
del elem.attrib["style"]
if __name__ == "__main__":
input_file = sys.argv[1]
tree = etree.parse(input_file)
fix(tree)
# store SVG into file (input file is overwritten)
svg = etree.tostring(tree, pretty_print=True)
with open(input_file, 'wb') as f:
f.write('<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'.encode("utf-8"))
f.write(svg)
:: Art_Vector_Belly_ [nobr] :: Art_Vector_Belly_ [nobr]
<<set _showNavelPiercings = $showBodyMods == 1 && _artSlave.clothes != "restrictive latex" && _artSlave.clothes != "a latex catsuit">> <<set _art_have_belly = true>>
<<set _art_scale_factor = 0.300*Math.log(0.011*_artSlave.belly) >>
<<if _artSlave.belly > 0>> <<set _art_translation_x = -290.841*_art_scale_factor+293.349 >>
<<if _artSlave.belly >= 100000>> <<set _art_translation_y = -206.438*_art_scale_factor+206.274 >>
<<include Art_Vector_Belly_Massive>> <<set _art_belly_transform = "matrix(" + _art_scale_factor +",0,0," + _art_scale_factor + "," + _art_translation_x + "," + _art_translation_y + ")">>
<<elseif _artSlave.belly >= 75000>> <<set _art_transform = _art_belly_transform>>
<<include Art_Vector_Belly_Giant>> <<if _artSlave.belly >= 2000>>
<<elseif _artSlave.belly >= 50000>> <<include Art_Vector_Belly>>
<<include Art_Vector_Belly_Huge>>
<<elseif _artSlave.belly >= 30000>>
<<include Art_Vector_Belly_Big>>
<<elseif _artSlave.belly >= 10000>>
<<include Art_Vector_Belly>>
<<elseif _artSlave.belly >= 1500>>
<<include Art_Vector_Belly_Small>>
<</if>> <</if>>
/* SNIPPED UNTIL SCALING WORKS */
/* shiny clothings */ /*
<<if $seeVectorArtHighlights == 1>> <<set _showNavelPiercings = $showBodyMods == 1 && _artSlave.clothes != "restrictive latex" && _artSlave.clothes != "a latex catsuit">>
<<if _artSlave.fuckdoll != 0 || _artSlave.clothes == "restrictive latex" || _artSlave.clothes == "a latex catsuit" || _artSlave.clothes == "body oil">>
<<include Art_Vector_Belly_Outfit_Shine>> <<if _artSlave.belly > 0>>
<</if>> <<if _artSlave.belly >= 100000>>
<<include Art_Vector_Belly_Massive>>
<<elseif _artSlave.belly >= 75000>>
<<include Art_Vector_Belly_Giant>>
<<elseif _artSlave.belly >= 50000>>
<<include Art_Vector_Belly_Huge>>
<<elseif _artSlave.belly >= 30000>>
<<include Art_Vector_Belly_Big>>
<<elseif _artSlave.belly >= 10000>>
<<include Art_Vector_Belly>>
<<elseif _artSlave.belly >= 1500>>
<<include Art_Vector_Belly_Small>>
<</if>> <</if>>
/* belly piercings */ shiny clothings
<<if _showNavelPiercings >> <<if $seeVectorArtHighlights == 1>>
<<if _artSlave.navelPiercing >= 1>> <<if _artSlave.fuckdoll != 0 || _artSlave.clothes == "restrictive latex" || _artSlave.clothes == "a latex catsuit" || _artSlave.clothes == "body oil">>
<<include Art_Vector_Belly_Piercing>> <<include Art_Vector_Belly_Outfit_Shine>>
<</if>> <</if>>
<<if _artSlave.navelPiercing == 2>>
<<include Art_Vector_Belly_Piercing_Heavy>>
<</if>> <</if>>
<</if>>
<<else>> belly piercings
<<if _showNavelPiercings >>
/* flat midriff piercings */ <<if _artSlave.navelPiercing >= 1>>
<<if _showNavelPiercings >> <<include Art_Vector_Belly_Piercing>>
<<if _artSlave.navelPiercing >= 1>> <</if>>
<<include Art_Vector_Navel_Piercing>> <<if _artSlave.navelPiercing == 2>>
<<include Art_Vector_Belly_Piercing_Heavy>>
<</if>>
<</if>> <</if>>
<<if _artSlave.navelPiercing == 2>> <<else>>
<<include Art_Vector_Navel_Piercing_Heavy>> flat midriff piercings
<<if _showNavelPiercings >>
<<if _artSlave.navelPiercing >= 1>>
<<include Art_Vector_Navel_Piercing>>
<</if>>
<<if _artSlave.navelPiercing == 2>>
<<include Art_Vector_Navel_Piercing_Heavy>>
<</if>>
<</if>> <</if>>
<</if>> <</if>>
<</if>> */
/* Torso Accessories */ /* Torso Accessories */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment