From: JazzyNico Date: Thu, 23 Dec 2010 18:46:43 +0000 (+0100) Subject: Extensions. Color Markers extension improvements (Bug #692582, Color markers to match... X-Git-Url: https://git.tokkee.org/?p=inkscape.git;a=commitdiff_plain;h=935223f1795ae0522a4e4c26b89ee9b7a1d2d5a8 Extensions. Color Markers extension improvements (Bug #692582, Color markers to match stroke extension does not copy the fill mode). Extensions. FXG export extension improvements and clean-up (Bug #625140, Support export to FXG). --- diff --git a/share/extensions/markers_strokepaint.inx b/share/extensions/markers_strokepaint.inx index d67430c60..2422482a7 100644 --- a/share/extensions/markers_strokepaint.inx +++ b/share/extensions/markers_strokepaint.inx @@ -1,23 +1,40 @@ - <_name>Color Markers to Match Stroke - org.ekips.filter.markers.strokepaint - markers_strokepaint.py - inkex.py - - <_item value="stroke">stroke color - <_item value="fill">fill color - <_item value="white">opaque white - <_item value="transparency">transparency - - true - - all - - - - - + <_name>Color Markers + org.ekips.filter.markers.strokepaint + markers_strokepaint.py + inkex.py + + + + + <_item value="solid">solid + <_item value="filled">filled + + false + true + + + + + true + -1 + + + true + 255 + + + + + + + all + + + + + diff --git a/share/extensions/markers_strokepaint.py b/share/extensions/markers_strokepaint.py index bf5b53035..e37c81656 100644 --- a/share/extensions/markers_strokepaint.py +++ b/share/extensions/markers_strokepaint.py @@ -1,6 +1,7 @@ #!/usr/bin/env python ''' Copyright (C) 2006 Aaron Spike, aaron@ekips.org +Copyright (C) 2010 Nicolas Dufour, nicoduf@yahoo.fr (color options) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -30,11 +31,39 @@ class MyEffect(inkex.Effect): self.OptionParser.add_option("-t", "--type", action="store", type="string", dest="fill_type", default="stroke", - help="Replace the marker fill with the object stroke or fill color") + help="Replace the markers' fill with the object stroke or fill color") self.OptionParser.add_option("-a", "--alpha", action="store", type="inkbool", dest="assign_alpha", default=True, - help="Assign the object fill and stroke alpha to the marker") + help="Assign the object fill and stroke alpha to the markers") + self.OptionParser.add_option("-i", "--invert", + action="store", type="inkbool", + dest="invert", default=False, + help="Invert fill and stroke colors") + self.OptionParser.add_option("--assign_fill", + action="store", type="inkbool", + dest="assign_fill", default=True, + help="Assign a fill color to the markers") + self.OptionParser.add_option("-f", "--fill_color", + action="store", type="int", + dest="fill_color", default=1364325887, + help="Choose a custom fill color") + self.OptionParser.add_option("--assign_stroke", + action="store", type="inkbool", + dest="assign_stroke", default=True, + help="Assign a stroke color to the markers") + self.OptionParser.add_option("-s", "--stroke_color", + action="store", type="int", + dest="stroke_color", default=1364325887, + help="Choose a custom fill color") + self.OptionParser.add_option("--tab", + action="store", type="string", + dest="tab", + help="The selected UI-tab when OK was pressed") + self.OptionParser.add_option("--colortab", + action="store", type="string", + dest="colortab", + help="The selected cutom color tab when OK was pressed") def effect(self): defs = self.xpathSingle('/svg:svg//svg:defs') @@ -48,15 +77,46 @@ class MyEffect(inkex.Effect): except: inkex.errormsg(_("No style attribute found for id: %s") % id) continue - - stroke = style.get('stroke', '#000000') - stroke_opacity = style.get('stroke-opacity', '1') - if (self.options.fill_type == "white"): - fill = "#FFFFFF" - fill_opacity = "1" - else: - fill = style.get('fill', '#000000') - fill_opacity = style.get('fill-opacity', '1') + + # Use object colors + if self.options.tab == '"object"': + temp_stroke = style.get('stroke', '#000000') + temp_fill = style.get('fill', '#000000') + if (self.options.invert): + fill = temp_stroke + stroke = temp_fill + else: + fill = temp_fill + stroke = temp_stroke + if (self.options.assign_alpha): + temp_stroke_opacity = style.get('stroke-opacity', '1') + temp_fill_opacity = style.get('fill-opacity', '1') + if (self.options.invert): + fill_opacity = temp_stroke_opacity + stroke_opacity = temp_fill_opacity + else: + fill_opacity = temp_fill_opacity + stroke_opacity = temp_stroke_opacity + if (self.options.fill_type == "solid"): + fill = stroke + if (self.options.assign_alpha): + fill_opacity = stroke_opacity + # Choose custom colors + elif self.options.tab == '"custom"': + fill_red = ((self.options.fill_color >> 24) & 255) + fill_green = ((self.options.fill_color >> 16) & 255) + fill_blue = ((self.options.fill_color >> 8) & 255) + fill = "rgb(%s,%s,%s)" % (fill_red, fill_green, fill_blue) + fill_opacity = (((self.options.fill_color) & 255) / 255.) + stroke_red = ((self.options.stroke_color >> 24) & 255) + stroke_green = ((self.options.stroke_color >> 16) & 255) + stroke_blue = ((self.options.stroke_color >> 8) & 255) + stroke = "rgb(%s,%s,%s)" % (stroke_red, stroke_green, stroke_blue) + stroke_opacity = (((self.options.stroke_color) & 255) / 255.) + if (not(self.options.assign_fill)): + fill = "none"; + if (not(self.options.assign_stroke)): + stroke = "none"; for mprop in mprops: if style.has_key(mprop) and style[mprop] != 'none'and style[mprop][:5] == 'url(#': @@ -82,22 +142,14 @@ class MyEffect(inkex.Effect): children = mnode.xpath('.//*[@style]', namespaces=inkex.NSS) for child in children: cstyle = simplestyle.parseStyle(child.get('style')) - if ('stroke' in cstyle and cstyle['stroke'] != 'none') or 'stroke' not in cstyle: + if (not(self.options.tab == '"object"' and cstyle['stroke'] == 'none' and self.options.fill_type == "filled")): cstyle['stroke'] = stroke - if (self.options.assign_alpha): + if 'stroke_opacity' in locals(): cstyle['stroke-opacity'] = stroke_opacity - if ('fill' in cstyle and cstyle['fill'] != 'none') or 'fill' not in cstyle: - if (self.options.fill_type == "fill" or self.options.fill_type == "white" ): - cstyle['fill'] = fill - if (self.options.assign_alpha): - cstyle['fill-opacity'] = fill_opacity - elif (self.options.fill_type == "stroke"): - cstyle['fill'] = stroke - if (self.options.assign_alpha): - cstyle['fill-opacity'] = stroke_opacity - else: - cstyle['fill'] = "none"; - cstyle['fill-opacity'] = "0" + if (not(self.options.tab == '"object"' and cstyle['fill'] == 'none' and self.options.fill_type == "solid")): + cstyle['fill'] = fill + if 'fill_opacity' in locals(): + cstyle['fill-opacity'] = fill_opacity child.set('style',simplestyle.formatStyle(cstyle)) node.set('style',simplestyle.formatStyle(style)) diff --git a/share/extensions/svg2fxg.xsl b/share/extensions/svg2fxg.xsl index 7f809655b..7569d0db7 100755 --- a/share/extensions/svg2fxg.xsl +++ b/share/extensions/svg2fxg.xsl @@ -1738,12 +1738,19 @@ extension-element-prefixes="math"> * Text flowPara * Text flowRegion (text frame) * Font size + * Font weight + * Font family + * Font style * Baseline shift + * Line height * Writing mode * Text decoration + * Text fill * Text direction * Text size * Text position + * Text object + * FlowRoot object --> + + preserve + @@ -1774,8 +1784,13 @@ extension-element-prefixes="math"> - + + + + + + @@ -1792,6 +1807,9 @@ extension-element-prefixes="math"> -->

+ + preserve + @@ -1811,8 +1829,13 @@ extension-element-prefixes="math"> - + + + + + + @@ -1871,6 +1894,102 @@ extension-element-prefixes="math"> + + + + + + + + + + + + + + + + + + + + + + + + + normal + bold + normal + + + + + + + + + + + + + + + + + + + + + + + + + + + Arial + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ascent - - preserve - - + + + + + + + - + + preserve + + - @@ -2254,99 +2339,21 @@ extension-element-prefixes="math"> - - - - - - - - - - - - - - - - - - - normal - bold - normal - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ascent - - preserve - - + + + + + + + @@ -2399,6 +2406,19 @@ extension-element-prefixes="math"> + +