
On Tuesday, July 10, 2007, 9:10:26 AM, Maarten wrote:
MvdV> Just another idea to drive those heroic programmers of Inkscape mad, but MvdV> I think it could be implemented by anyone knowing only slightly more MvdV> about programming as I do:
MvdV> If I had a drawing with 3 colors, I'd like a MvdV> function/widget/thingy/batch-msdos-bash-script that MvdV> 1. can substitute all ocurances of 1 color for 1 predifinded other MvdV> color. MvdV> (so, for example, I could tell it to substitue all MvdV> #000000 -> #FF0000, MvdV> #FF0000 -> #FFFFFF and MvdV> #FFFF00 -> #0000FF, MvdV> hence turning the German flag into the Dutch)
The trouble with search-and replace is that it can clobber values that accidentally clash, if the substitutions are performed sequentially. In your example you turn black to red; and then red to green (so everything that was black or red originally becomes green).
And you probably don't want to turn *all * values that happen to use a given color into a different one; just the ones that you specify.
MvdV> 2. can either systematiccally cycle/iterate through the specified MvdV> colors, or assing them randomly, creating a series of output SVG files, MvdV> all with different color-schemes.
MvdV> In this way, it would be easy to test quickly different color-scheme's MvdV> on a drawing. Make it first in 3 greys, and then test it with vibrant, MvdV> saturated colors or with dim, purple shades of green...
MvdV> I'm curious about your comments!
This is already possible and requires no scripting. Instead of setting colors directly, set classes and then use CSS to set the colors. Thus
<svg xmlns:svg="http://www.w3.org/2000/svg" viewBox -10 -10 170 120"> <rect class="left" x="0" y="0" width="50" height="100"/> <rect class="middle" x="50" y="0" width="50" height="100"/> <rect class="right" x="1000" y="0" width="50" height="100"/> </svg>
german-flag.css .left {fill: #000} .middle {fill: #f00} .right {fill: #ff0}
dutch-flag.css .left {fill: #f00} .middle {fill: #fff} .right {fill: #00f}
Bringing this back to Inkscape, which can already assign classes to elements; a UI to select a stylesheet and a UI to generate color schemes (== classes and fill colors) using things like complementary colors, triads, darker/lighter less/more saturated and so on might be useful. CSS can't do that sort of color computation, but a authoring tool can.