From 2ca82b637a393de26dbf6cc819d2aadce4764a45 Mon Sep 17 00:00:00 2001 From: klorpa <30924131+klorpa@users.noreply.github.com> Date: Wed, 27 Feb 2019 23:20:21 -0600 Subject: [PATCH] PYSpace --- artTools/vector_clothing_replicator.py | 8 --- artTools/vector_layer_split.py | 30 --------- artTools/vector_revamp_layer_split.py | 67 ------------------- .../sugarcube stuff/building sugarcube.txt | 6 -- 4 files changed, 111 deletions(-) diff --git a/artTools/vector_clothing_replicator.py b/artTools/vector_clothing_replicator.py index f4bd3ba53ef..6d3f0549be6 100644 --- a/artTools/vector_clothing_replicator.py +++ b/artTools/vector_clothing_replicator.py @@ -67,19 +67,11 @@ def get_points(xpath_shape): points = [] path_length = None for path_data in paths_data: -<<<<<<< HEAD p = parse_path(path_data) points += [ p.point(1.0/float(REFERENCE_PATH_SAMPLES)*i) for i in range(REFERENCE_PATH_SAMPLES) ] -======= - p = parse_path(path_data) - points += [ - p.point(1.0/float(REFERENCE_PATH_SAMPLES)*i) - for i in range(REFERENCE_PATH_SAMPLES) - ] ->>>>>>> 14b240a283262b8791485ed8f234dfbe31a62dc7 if (not points): raise RuntimeError( 'No paths for reference points found by selector "%s".'%(xpath_shape) diff --git a/artTools/vector_layer_split.py b/artTools/vector_layer_split.py index e6022ad7d34..abff29fc4a7 100644 --- a/artTools/vector_layer_split.py +++ b/artTools/vector_layer_split.py @@ -69,15 +69,9 @@ layers = tree.xpath('//svg:g',namespaces=ns) for layer in layers: i = layer.get('id') if ( # disregard non-content groups -<<<<<<< HEAD i.endswith("_") or # manually suppressed with underscore i.startswith("XMLID") or # Illustrator generated group i.startswith("g") # Inkscape generated group -======= - i.endswith("_") or # manually suppressed with underscore - i.startswith("XMLID") or # Illustrator generated group - i.startswith("g") # Inkscape generated group ->>>>>>> 14b240a283262b8791485ed8f234dfbe31a62dc7 ): continue # create new canvas @@ -92,7 +86,6 @@ for layer in layers: # TODO: extract only referenced defs (filters, gradients, ...) # TODO: detect necessity by traversing the elements. do not stupidly search in the string representation if ("filter:" in svg.decode('utf-8')): -<<<<<<< HEAD # it seems there is a filter referenced in the generated SVG, re-insert defs from main document canvas.insert(0,defs) # re-generate output @@ -114,29 +107,6 @@ for layer in layers: else: svg = svg.replace('<g ','<g transform="\'+_art_transform+\'"') # otherwise use default scaling svg = svg.encode('utf-8') -======= - # it seems there is a filter referenced in the generated SVG, re-insert defs from main document - canvas.insert(0,defs) - # re-generate output - svg = etree.tostring(output, pretty_print=False) - - if (output_format == 'tw'): - # remove unnecessary attributes - # TODO: never generate unnecessary attributes in the first place - svg = svg.decode('utf-8') - svg = regex_xmlns.sub('',svg) - svg = svg.replace(' inkscape:connector-curvature="0"','') # this just saves space - svg = svg.replace('\n','').replace('\r','') # print cannot be multi-line - svg = regex_space.sub('><',svg) # remove indentation - svg = svg.replace('svg:','') # svg namespace was removed - if ("Boob" in i): # internal groups are used for scaling - svg = svg.replace('<g ','<g transform="\'+_artTransformBoob+\'"') # boob art uses the boob scaling - elif ("Belly" in i): - svg = svg.replace('<g ','<g transform="\'+_artTransformBelly+\'"') # belly art uses the belly scaling - else: - svg = svg.replace('<g ','<g transform="\'+_art_transform+\'"') # otherwise use default scaling - svg = svg.encode('utf-8') ->>>>>>> 14b240a283262b8791485ed8f234dfbe31a62dc7 # save SVG string to file i = layer.get('id') diff --git a/artTools/vector_revamp_layer_split.py b/artTools/vector_revamp_layer_split.py index 6e66922a3c0..eee6817c4f8 100644 --- a/artTools/vector_revamp_layer_split.py +++ b/artTools/vector_revamp_layer_split.py @@ -74,7 +74,6 @@ regex_transformAttr = re.compile('transform="[^"]*"', ) # find all groups layers = tree.xpath('//svg:g', namespaces=ns) for layer in layers: -<<<<<<< HEAD i = layer.get('id') if ( # disregard non-content groups i.endswith("_") or # manually suppressed with underscore @@ -139,69 +138,3 @@ for layer in layers: f.write("<<print '<html>".encode("utf-8")) f.write(svg) f.write("</html>' >>".encode("utf-8")) -======= - i = layer.get('id') - if ( # disregard non-content groups - i.endswith("_") or # manually suppressed with underscore - i.startswith("XMLID") or # Illustrator generated group - i.startswith("g") # Inkscape generated group - ): - continue - # create new canvas - output = copy.deepcopy(template) - # copy all shapes into template - canvas = output.getroot() - for e in layer: - canvas.append(e) - # represent template as SVG (binary string) - svg = etree.tostring(output, pretty_print=False) - # poor man's conditional defs insertion - # TODO: extract only referenced defs (filters, gradients, ...) - # TODO: detect necessity by traversing the elements. do not stupidly search in the string representation - if ("filter:" in svg.decode('utf-8')): - # it seems there is a filter referenced in the generated SVG, re-insert defs from main document - canvas.insert(0, defs) - # re-generate output - svg = etree.tostring(output, pretty_print=False) - elif ("clip-path=" in svg.decode('utf-8')): - # it seems there is a clip path referenced in the generated SVG, re-insert defs from main document - canvas.insert(0, defs) - # re-generate output - svg = etree.tostring(output, pretty_print=False) - - if (output_format == 'tw'): - # remove unnecessary attributes - # TODO: never generate unnecessary attributes in the first place - svg = svg.decode('utf-8') - svg = regex_xmlns.sub('', svg) - svg = svg.replace(' inkscape:connector-curvature="0"', '') # this just saves space - svg = svg.replace('\n', '').replace('\r', '') # print cannot be multi-line - svg = regex_space.sub('><', svg) # remove indentation - svg = svg.replace('svg:', '') # svg namespace was removed - - transformGroups = regex_transformVar.findall(svg) - - if (len(transformGroups) > 0): - svg = regex_transformAttr.sub('', svg) - for transformGroup in transformGroups: - transformValue = regex_transformValue.search(transformGroup) - if (transformValue is not None): - svg = svg.replace(transformGroup, ' transform="\'+' + transformValue.group() + '+\'" ') # internal groups are used for scaling - - svg = svg.encode('utf-8') - - # save SVG string to file - i = layer.get('id') - output_path = os.path.join(output_directory, i + '.' + output_format) - with open(output_path, 'wb') as f: - if (output_format == 'svg'): - # Header for normal SVG (XML) - f.write('<?xml version="1.0" encoding="UTF-8" standalone="no"?>\n'.encode("utf-8")) - f.write(svg) - elif (output_format == 'tw'): - # Header for SVG in Twine file (SugarCube print statement) - f.write((':: Art_Vector_Revamp_%s [nobr]\n\n' % (i)).encode("utf-8")) - f.write("<<print '<html>".encode("utf-8")) - f.write(svg) - f.write("</html>' >>".encode("utf-8")) ->>>>>>> 14b240a283262b8791485ed8f234dfbe31a62dc7 diff --git a/devNotes/sugarcube stuff/building sugarcube.txt b/devNotes/sugarcube stuff/building sugarcube.txt index 1d7f4d6f728..e0ae54e0f31 100644 --- a/devNotes/sugarcube stuff/building sugarcube.txt +++ b/devNotes/sugarcube stuff/building sugarcube.txt @@ -36,13 +36,7 @@ Run the node package manager (npm) in the repository: npm install CAUTION: dependencies list (located in the package.json file in the repository root) may change from -<<<<<<< HEAD -commit to commit and it differs between branches! Make sure to install correct dependencies after -switching working branch. -======= commit to commit and it differs between branches! Make sure to install correct dependencies after switching working branch. ->>>>>>> 14b240a283262b8791485ed8f234dfbe31a62dc7 - Patching and building SugarCube. -- GitLab