Commit 49fc5e30 authored by Jehan's avatar Jehan

tools: invert-svg build tool no longer necessary.

This tool has been outdated for some time now as we don't generate an
"inverted icons" theme anymore. This is all done through CSS from a
single symbolic icon theme.
parent 96dc7da0
......@@ -7,7 +7,5 @@
/gimptool-2.00.exe
/gimp-test-clipboard-2.99
/gimp-test-clipboard-2.99.exe
/invert-svg
/invert-svg.exe
/compute-svg-viewbox
/compute-svg-viewbox.exe
......@@ -45,10 +45,6 @@ kernelgen_SOURCES = kernelgen.c
if ENABLE_VECTOR_ICONS
invert-svg$(BUILD_EXEEXT): invert-svg.c
$(CC_FOR_BUILD) -fPIC -o $@ $< $(NATIVE_GLIB_LIBS) $(CPPFLAGS_FOR_BUILD) $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) $(NATIVE_GLIB_CFLAGS)
# compute_svg_viewbox is not built or used because librsvg is just too buggy
# right now. But we keep the code around. The goal of this build tool will be
# to be able to extract SVG icons from a single SVG file at build time, rather
......@@ -60,9 +56,9 @@ invert-svg$(BUILD_EXEEXT): invert-svg.c
#compute_svg_viewbox_LDADD = $(SVG_LIBS)
# Build tools which must be built for the host platform.
all-local: invert-svg$(BUILD_EXEEXT)
#all-local: compute-svg-viewbox$(BUILD_EXEEXT)
DISTCLEANFILES = invert-svg$(BUILD_EXEEXT)
#DISTCLEANFILES = compute-svg-viewbox$(BUILD_EXEEXT)
endif
AM_CPPFLAGS = \
......@@ -102,5 +98,4 @@ AM_LDFLAGS = \
EXTRA_DIST = \
defcheck.py \
gimp-mkenums \
gimppath2svg.py \
invert-svg.c
gimppath2svg.py
/* invert-svg-grey.c
* Copyright (C) 2016 Jehan
*
* 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
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <gio/gio.h>
#include <glib/gprintf.h>
#include <stdlib.h>
#include <string.h>
/* This tool inverts grey colors in a SVG image.
* Non-grey colors are not touched, since they are considered
* exceptions that we would want to keep the same (for instance
* Red, Blue or Green channel representations).
*
* It is not based off XML knowledge since colors could appear in
* various fields. Instead we just assume that a color has the XML
* format "#RRGGBB" and we use regular expression to update these.
*/
static gboolean
invert_rgb_color (const GMatchInfo *info,
GString *res,
gpointer data)
{
gchar *match;
gchar *inverted;
gint value;
/* We only invert grey colors, so we just need the first channel. */
match = g_match_info_fetch (info, 1);
value = strtol (match, NULL, 16);
value = 255 - value;
inverted = g_strdup_printf ("#%02x%02x%02x",
value, value, value);
g_string_append (res, inverted);
g_free (inverted);
g_free (match);
return FALSE;
}
int main (int argc, char **argv)
{
gchar *input;
gchar *output;
GFile *file;
gchar *contents;
gchar *replaced;
GRegex *regex;
gint retval = 0;
if (argc != 3)
{
g_fprintf (stderr, "Usage: invert-svg svg-image inverted-svg-output\n");
return 1;
}
input = argv[1];
output = argv[2];
file = g_file_new_for_path (input);
if (! g_file_load_contents (file, NULL, &contents, NULL, NULL, NULL))
{
g_fprintf (stderr,
"Error: invert-svg could not load contents of file %s.\n",
input);
g_object_unref (file);
return 1;
}
g_object_unref (file);
/* Replace grey colors only. */
regex = g_regex_new ("#([0-9a-fA-F]{2}){3}\\b", 0, 0, NULL);
replaced = g_regex_replace_eval (regex, contents, -1, 0, 0,
invert_rgb_color, NULL, NULL);
file = g_file_new_for_path (output);
if (! g_file_replace_contents (file, replaced, strlen (replaced),
NULL, FALSE,
G_FILE_CREATE_REPLACE_DESTINATION,
NULL, NULL, NULL))
{
g_fprintf (stderr,
"Error: invert-svg could not save file %s.\n",
output);
retval = 1;
}
g_object_unref (file);
g_free (contents);
g_free (replaced);
g_regex_unref (regex);
return retval;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment