From c9c4cf74733ca2c0ab32ec5ca83a7b2d55ad4cbc Mon Sep 17 00:00:00 2001 From: deepmurk <axiao@protonmail.com> Date: Sun, 22 Apr 2018 06:51:49 -0400 Subject: [PATCH] Master Sync Sync --- artTools/normalize_svg.py | 76 ++++++++++++++++++++++ artTools/vector_source_ndmain.svg | 28 ++++---- devNotes/Deepmurk_Vector_Art_Changelog.txt | 13 ++-- 3 files changed, 102 insertions(+), 15 deletions(-) create mode 100644 artTools/normalize_svg.py diff --git a/artTools/normalize_svg.py b/artTools/normalize_svg.py new file mode 100644 index 00000000000..5767de7344b --- /dev/null +++ b/artTools/normalize_svg.py @@ -0,0 +1,76 @@ +#!/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) diff --git a/artTools/vector_source_ndmain.svg b/artTools/vector_source_ndmain.svg index fe859e11707..d8b3069997e 100644 --- a/artTools/vector_source_ndmain.svg +++ b/artTools/vector_source_ndmain.svg @@ -193,13 +193,13 @@ inkscape:snap-smooth-nodes="false" inkscape:object-paths="true" inkscape:object-nodes="true" - inkscape:current-layer="Belly" + inkscape:current-layer="Belly_" inkscape:window-maximized="1" inkscape:window-y="-8" inkscape:window-x="-8" - inkscape:cy="734.29606" - inkscape:cx="131.93769" - inkscape:zoom="0.99999996" + inkscape:cy="605.85187" + inkscape:cx="228.13239" + inkscape:zoom="3.9999998" showgrid="false" id="namedview4358" inkscape:window-height="1057" @@ -19596,29 +19596,35 @@ id="XMLID_543_" class="shadow" d="m 274.8,433.8 c 20.7,-1.5 47.7,-4.5 61.9,-42.4 13.1,-44.3 -27.8,-99.6 -59.9,-101.5 -40.1,6.2 -61.8,42.8 -63.9,96.9 2.2,31 33.1,49 61.9,47 z" - inkscape:connector-curvature="0" /><path + inkscape:connector-curvature="0" + style="fill:#010101" /><path id="XMLID_544_" class="skin" d="m 274.8,433.8 c 20.8,0.1 49.4,-13 61.9,-42.4 12.5,-29.4 -18.5,-83.4 -46,-101.7 -6.5,-4.3 -38.7,-8.2 -40.4,0 -2.6,11.6 -44.9,33.3 -41.4,96.8 1.8,34.8 45.1,47.2 65.9,47.3 z" - inkscape:connector-curvature="0" /><path + inkscape:connector-curvature="0" + style="fill:#f6e0e8" /><path inkscape:connector-curvature="0" id="XMLID_545_" - d="m 249.83484,395.7339 a 3.0999447,2.7999501 78.497917 0 1 -2.12558,3.59601 3.0999447,2.7999501 78.497917 0 1 -3.36186,-2.47937 3.0999447,2.7999501 78.497917 0 1 2.12558,-3.59601 3.0999447,2.7999501 78.497917 0 1 3.36186,2.47937 z" - class="areola" /></g></g><g + d="m 249.39747,396.08802 c 0.12486,1.70749 -0.62641,4.50894 -2.16866,4.62172 -1.54225,0.11277 -2.36338,-2.46164 -2.48824,-4.16913 -0.12486,-1.70749 0.67061,-4.35425 2.21286,-4.46703 1.54225,-0.11278 2.31918,2.30695 2.44404,4.01444 z" + class="areola" + style="fill:#1a1a1a" + sodipodi:nodetypes="scscs" /></g></g><g inkscape:groupmode="layer" id="Belly_Piercing" inkscape:label="Belly_Piercing" - style="display:none"><circle + style="display:inline"><circle id="XMLID_547_" class="steel_piercing" cx="246.89999" cy="390.89999" - r="1.2" /><circle + r="1.2" + style="fill:#787878" /><circle id="XMLID_548_" class="steel_piercing" cx="246.89999" cy="395" - r="1.2" /></g><g + r="1.2" + style="fill:#787878" /></g><g inkscape:groupmode="layer" id="Belly_Piercing_Heavy" inkscape:label="Belly_Piercing_Heavy" diff --git a/devNotes/Deepmurk_Vector_Art_Changelog.txt b/devNotes/Deepmurk_Vector_Art_Changelog.txt index 4a3acbae464..60dc70068d4 100644 --- a/devNotes/Deepmurk_Vector_Art_Changelog.txt +++ b/devNotes/Deepmurk_Vector_Art_Changelog.txt @@ -2,11 +2,11 @@ artist notes ------------- TO USE: SELECT VECTOR ART BY NOX/DEEPMURK +CREDITS ------------- -Be aware this is a re-edit, update, and expansion of the original vector art created by NoX. Credits to NoX as the original artist. -Had NoX's work not been present to build off of, I would have been far too lazy to do any of this at all. - -Credits to skinAnon for doing the color hexes on hundreds of skin/nipple tones. +Nov_X/NoX (Original Artist, whose work I built off of) +skinAnon (For doing the color hexes on hundreds of skin/nipple tones.) +@prndev (For dynamic belly scaling magic) FOR MANUAL USE ------------- @@ -26,6 +26,11 @@ known issues pending requests/suggestions ------------- +v0.9 (04-28-2018) +------------- + -added dynamic belly scaling (courtesy of @prndev) + + v0.8 (04-21-2018) ------------- -added wispy pubic hair art -- GitLab