Skip to content

Multi Action's ColorSeparation.py doesn't support colors from pallette #325

@devingfx

Description

@devingfx

We can't use inkscape"s color palette to set custom colors to strokes.

ColorSeparation.py assumes each element's stroke of fill are plain color convertible to RGB, what may not be the case especially when dealing with color palette which use gradients even for plain colors. Even worse: inkscape uses sub-gradient for each elements even if the same color swatch is used (for a matter of gradient positioning):

<svg:defs
     id="defs996">
    <svg:linearGradient
       id="black"
       gradientTransform="matrix(0.249958,0,0,0.249958,56.5965,53.6683)"
       inkscape:swatch="solid">
      <svg:stop
         offset="0"
         id="stop8279"
         style="stop-color:black;stop-opacity:1" />
    </svg:linearGradient>
    <svg:linearGradient
       inkscape:collect="always"
       xlink:href="#black"
       id="linearGradient8283"
       x1="1334.48"
       y1="60.9108"
       x2="1386.38"
       y2="60.9108"
       gradientUnits="userSpaceOnUse"
       gradientTransform="scale(0.264583)" />
    <svg:linearGradient
       inkscape:collect="always"
       xlink:href="#black"
       id="linearGradient8295"
       x1="352.187"
       y1="-8.61656"
       x2="363.218"
       y2="-8.61656"
       gradientUnits="userSpaceOnUse" />
  </svg:defs>
  ...
  <svg:path
         inkscape:connector-curvature="0"
         id="path1952"
         d="..."
         style="display:inline;fill:url(#linearGradient8283);fill-opacity:1;stroke-width:0.352778" />
  <svg:path
         sodipodi:nodetypes="cccscccccccccccac"
         inkscape:connector-curvature="0"
         id="path1954"
         d="..."
         style="display:inline;fill:url(#linearGradient8295);fill-opacity:1;stroke-width:0.352778" />
silhouette_multi.py was called via: ['silhouette_multi.py', '--dry_run=true', '--register_once=true', '--block=true', '--verbose=true', '/tmp/ink_ext_XXXXXX.svgPGC8Z2']
Traceback (most recent call last):
  File "silhouette_multi.py", line 316, in <module>
    e.run()
  File "/usr/share/inkscape/extensions/inkex/base.py", line 250, in run
    self.save_raw(self.effect())
  File "silhouette_multi.py", line 145, in effect
    self.split_objects_by_color()
  File "silhouette_multi.py", line 136, in split_objects_by_color
    color = self.get_color(obj)
  File "silhouette_multi.py", line 99, in get_color
    color = Color(color).to_rgb()
  File "/usr/share/inkscape/extensions/inkex/colors.py", line 248, in __init__
    space, color = self.parse_str(color.strip())
  File "/usr/share/inkscape/extensions/inkex/colors.py", line 325, in parse_str
    raise ColorIdError("Color references other element id, e.g. a gradient")
inkex.colors.ColorIdError: 'Color references other element id, e.g. a gradient'

Of course the color module can not convert to RGB the string url(#linearGradient8295).
The colors have to be identified by authored string instead, but this leads to a new issue: duplicate color items for each gradient url even the underlaying sub-gradient is the same color swatch... :(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions