summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2db3001)
raw | patch | inline | side by side (parent: 2db3001)
author | JazzyNico <nicoduf@yahoo.fr> | |
Fri, 17 Sep 2010 13:02:18 +0000 (15:02 +0200) | ||
committer | JazzyNico <nicoduf@yahoo.fr> | |
Fri, 17 Sep 2010 13:02:18 +0000 (15:02 +0200) |
src/extension/internal/filter/color.h | patch | blob | history | |
src/extension/internal/filter/experimental.h | patch | blob | history |
index 08ba4b475dc81e110505d619142089b42e6b0232..82a37a6aa787c250e20fba20522d9fb5097a9961 100644 (file)
// "<param name=\"tab\" type=\"notebook\">\n"
// "<page name=\"Color1\" _gui-text=\"Color 1\">\n"
"<param name=\"fluo\" gui-text=\"" N_("Fluorescence") "\" type=\"boolean\">false</param>\n"
+ "<param name=\"swapcolors\" gui-text=\"" N_("Swap colors") "\" type=\"boolean\">false</param>\n"
"<_param name=\"header1\" type=\"groupheader\">Color 1</_param>\n"
"<param name=\"color1\" gui-text=\"" N_("Color 1") "\" type=\"color\">1364325887</param>\n"
// "</page>\n"
std::ostringstream g2;
std::ostringstream b2;
std::ostringstream fluo;
+ std::ostringstream swapc;
guint32 color1 = ext->get_param_color("color1");
guint32 color2 = ext->get_param_color("color2");
bool fluorescence = ext->get_param_bool("fluo");
+ bool swapcolors = ext->get_param_bool("swapcolors");
+
a1 << (color1 & 0xff) / 255.0F;
r1 << ((color1 >> 24) & 0xff);
g1 << ((color1 >> 16) & 0xff);
r2 << ((color2 >> 24) & 0xff);
g2 << ((color2 >> 16) & 0xff);
b2 << ((color2 >> 8) & 0xff);
- if (fluorescence) fluo << "";
- else fluo << " in=\"result6\"";
+ if (fluorescence)
+ fluo << "";
+ else
+ fluo << " in=\"blend\"";
+ if (swapcolors)
+ swapc << "in";
+ else
+ swapc << "out";
_filter = g_strdup_printf(
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Duochrome, custom -EXP-\">\n"
"<feColorMatrix type=\"luminanceToAlpha\" result=\"fbSourceGraphic\" />\n"
- "<feFlood in=\"fbSourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"result1\" />\n"
- "<feComposite in=\"result1\" in2=\"fbSourceGraphic\" operator=\"out\" result=\"result2\" />\n"
+ "<feFlood in=\"fbSourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"composite1\" />\n"
+ "<feComposite in=\"composite1\" in2=\"fbSourceGraphic\" operator=\"%s\" result=\"result2\" />\n"
"<feComposite in2=\"SourceGraphic\" k2=\"1\" result=\"fbSourceGraphic\" operator=\"arithmetic\" />\n"
"<feFlood in=\"fbSourceGraphic\" flood-opacity=\"%s\" flood-color=\"rgb(%s,%s,%s)\" result=\"result2\" />\n"
- "<feMerge result=\"result5\">\n"
+ "<feMerge>\n"
"<feMergeNode in=\"result2\" />\n"
"<feMergeNode in=\"fbSourceGraphic\" />\n"
"</feMerge>\n"
- "<feBlend in2=\"fbSourceGraphic\" mode=\"normal\" blend=\"normal\" result=\"result6\" />\n"
- "<feColorMatrix type=\"matrix\" values=\"2 -1 0 0 0 0 2 -1 0 0 -1 0 2 0 0 0 0 0 1 0 \" result=\"result10\" />\n"
+ "<feBlend in2=\"fbSourceGraphic\" mode=\"normal\" blend=\"normal\" result=\"blend\" />\n"
+ "<feColorMatrix type=\"matrix\" values=\"2 -1 0 0 0 0 2 -1 0 0 -1 0 2 0 0 0 0 0 1 0 \" />\n"
"<feComposite %s in2=\"SourceGraphic\" operator=\"in\" result=\"fbSourceGraphic\" />\n"
- "</filter>\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), fluo.str().c_str());
+ "</filter>\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swapc.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), fluo.str().c_str());
return _filter;
};
diff --git a/src/extension/internal/filter/experimental.h b/src/extension/internal/filter/experimental.h
index af5a37b4516525ae206d4b618d14ef08f9ccf2c5..15c97202e9911783022bcf8ff8d4a4535ca483c3 100644 (file)
static void init (void) {
Inkscape::Extension::build_from_mem(
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
- "<name>" N_("Posterize, custom -EXP-") "</name>\n"
+ "<name>" N_("Poster and painting, custom -EXP-") "</name>\n"
"<id>org.inkscape.effect.filter.Posterize</id>\n"
- "<param name=\"type\" gui-text=\"" N_("Type:") "\" type=\"enum\">\n"
+ "<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n"
"<_item value=\"normal\">Normal</_item>\n"
- "<_item value=\"contrasted\">Contrasted</_item>\n"
+ "<_item value=\"dented\">Dented</_item>\n"
"</param>\n"
- "<param name=\"level\" gui-text=\"" N_("Level:") "\" type=\"int\" min=\"1\" max=\"10\">3</param>\n"
+ "<param name=\"table\" gui-text=\"" N_("Transfer type:") "\" type=\"enum\">\n"
+ "<_item value=\"discrete\">Poster</_item>\n"
+ "<_item value=\"table\">Painting</_item>\n"
+ "</param>\n"
+ "<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" min=\"1\" max=\"15\">5</param>\n"
+ "<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
+ "<_item value=\"lighten\">Ligthen</_item>\n"
+ "<_item value=\"normal\">Normal</_item>\n"
+ "<_item value=\"darken\">Darken</_item>\n"
+ "</param>\n"
+ "<param name=\"blur1\" gui-text=\"" N_("Primary blur:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">4.0</param>\n"
+ "<param name=\"blur2\" gui-text=\"" N_("Secondary blur:") "\" type=\"float\" min=\"0.0\" max=\"100.0\">0.5</param>\n"
+ "<param name=\"presaturation\" gui-text=\"" N_("Pre-saturation:") "\" type=\"float\" min=\"0.00\" max=\"1.00\">1.00</param>\n"
+ "<param name=\"postsaturation\" gui-text=\"" N_("Post-saturation:") "\" type=\"float\" min=\"0.00\" max=\"1.00\">1.00</param>\n"
+ "<param name=\"antialiasing\" gui-text=\"" N_("Simulate antialiasing") "\" type=\"boolean\">false</param>\n"
"<effect>\n"
"<object-type>all</object-type>\n"
"<effects-menu>\n"
"<submenu name=\"" N_("Experimental") "\"/>\n"
"</submenu>\n"
"</effects-menu>\n"
- "<menu-tip>" N_("Change colors to a two colors palette") "</menu-tip>\n"
+ "<menu-tip>" N_("Poster and painting effects") "</menu-tip>\n"
"</effect>\n"
"</inkscape-extension>\n", new Posterize());
};
{
if (_filter != NULL) g_free((void *)_filter);
+ std::ostringstream table;
+ std::ostringstream blendmode;
+ std::ostringstream blur1;
+ std::ostringstream blur2;
+ std::ostringstream presat;
+ std::ostringstream postsat;
std::ostringstream transf;
+ std::ostringstream antialias;
+
+ table << ext->get_param_enum("table");
+ blendmode << ext->get_param_enum("blend");
+ blur1 << ext->get_param_float("blur1") + 0.01;
+ blur2 << ext->get_param_float("blur2") + 0.01;
+ presat << ext->get_param_float("presaturation");
+ postsat << ext->get_param_float("postsaturation");
- int level = ext->get_param_int("level") + 1;
- const gchar *type = ext->get_param_enum("type");
- float val = 0.0;
+
+ // TransfertComponenet table values are calculated based on the poster type.
transf << "0";
- for ( int step = 1 ; step <= level ; step++ ) {
- val = (float) step / level;
+ int levels = ext->get_param_int("levels") + 1;
+ const gchar *effecttype = ext->get_param_enum("type");
+ float val = 0.0;
+ for ( int step = 1 ; step <= levels ; step++ ) {
+ val = (float) step / levels;
transf << " " << val;
- if((g_ascii_strcasecmp("contrasted", type) == 0)) {
- transf << " " << (val - ((float) 1 / (3 * level))) << " " << (val + ((float) 1 / (2 * level)));
+ if((g_ascii_strcasecmp("dented", effecttype) == 0)) {
+ transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels)));
}
}
transf << " 1";
+
+ if (ext->get_param_bool("antialiasing"))
+ antialias << "0.5";
+ else
+ antialias << "0.01";
+
+
+ _filter = g_strdup_printf(
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Poster and painting, custom -EXP-\">\n"
+ "<feComposite result=\"Composite1\" operator=\"arithmetic\" k2=\"1\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" result=\"Gaussian1\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" in=\"Composite1\" />\n"
+ "<feBlend in2=\"Gaussian1\" mode=\"%s\" />\n"
+ "<feColorMatrix type=\"saturate\" values=\"%s\" />\n"
+ "<feComponentTransfer>\n"
+ "<feFuncR type=\"%s\" tableValues=\"%s\" />\n"
+ "<feFuncG type=\"%s\" tableValues=\"%s\" />\n"
+ "<feFuncB type=\"%s\" tableValues=\"%s\" />\n"
+ "</feComponentTransfer>\n"
+ "<feColorMatrix type=\"saturate\" values=\"%s\" />\n"
+ "<feGaussianBlur stdDeviation=\"%s\" />\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"atop\" />\n"
+ "</filter>\n", blur1.str().c_str(), blur2.str().c_str(), blendmode.str().c_str(), presat.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), table.str().c_str(), transf.str().c_str(), postsat.str().c_str(), antialias.str().c_str());
+
+ return _filter;
+};
+
+class TestFilter : public Inkscape::Extension::Internal::Filter::Filter {
+protected:
+ virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
+
+public:
+ TestFilter ( ) : Filter() { };
+ virtual ~TestFilter ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
+
+ static void init (void) {
+ Inkscape::Extension::build_from_mem(
+ "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
+ "<name>" N_("Test Filter -EXP-") "</name>\n"
+ "<id>org.inkscape.effect.filter.TestFilter</id>\n"
+ "<_param name=\"header1\" type=\"groupheader\">Test filter</_param>\n"
+ "<effect>\n"
+ "<object-type>all</object-type>\n"
+ "<effects-menu>\n"
+ "<submenu name=\"" N_("Filters") "\">\n"
+ "<submenu name=\"" N_("Experimental") "\"/>\n"
+ "</submenu>\n"
+ "</effects-menu>\n"
+ "<menu-tip>" N_("Change colors to a two colors palette") "</menu-tip>\n"
+ "</effect>\n"
+ "</inkscape-extension>\n", new TestFilter());
+ };
+
+};
+gchar const *
+TestFilter::get_filter_text (Inkscape::Extension::Extension * ext)
+{
+ if (_filter != NULL) g_free((void *)_filter);
+
_filter = g_strdup_printf(
- "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Posterize, custom -EXP-\">\n"
- "<feGaussianBlur stdDeviation=\"1.5\" result=\"result3\" />\n"
- "<feGaussianBlur stdDeviation=\"1.5\" in=\"SourceGraphic\" result=\"result4\" />\n"
- "<feBlend in2=\"result3\" blend=\"normal\" mode=\"lighten\" />\n"
- "<feComponentTransfer result=\"result1\">\n"
- "<feFuncR type=\"discrete\" tableValues=\"%s\" />\n"
- "<feFuncG type=\"discrete\" tableValues=\"%s\" />\n"
- "<feFuncB type=\"discrete\" tableValues=\"%s\" />\n"
+ "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" color-interpolation-filters=\"sRGB\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Test Filter -EXP-\">\n"
+ "<feComposite result=\"Composite1\" operator=\"arithmetic\" k2=\"1\" />\n"
+ "<feGaussianBlur stdDeviation=\"4\" result=\"Gaussian1\" />\n"
+ "<feGaussianBlur stdDeviation=\"0.5\" in=\"Composite1\" />\n"
+ "<feBlend in2=\"Gaussian1\" mode=\"normal\" />\n"
+ "<feColorMatrix type=\"saturate\" values=\"1\" />\n"
+ "<feComponentTransfer>\n"
+ "<feFuncR type=\"discrete\" tableValues=\"0 0.25 0.5 0.75 1 1\" />\n"
+ "<feFuncG type=\"discrete\" tableValues=\"0 0.25 0.5 0.75 1 1\" />\n"
+ "<feFuncB type=\"discrete\" tableValues=\"0 0.25 0.5 0.75 1 1\" />\n"
"</feComponentTransfer>\n"
"<feColorMatrix type=\"saturate\" values=\"1\" />\n"
- "<feGaussianBlur stdDeviation=\"0.01\" />\n"
- "<feComposite in2=\"SourceGraphic\" operator=\"atop\" result=\"result2\" />\n"
- "</filter>\n", transf.str().c_str(), transf.str().c_str(), transf.str().c_str());
+ "<feGaussianBlur stdDeviation=\"0.05\" />\n"
+ "<feComposite in2=\"SourceGraphic\" operator=\"atop\" />\n"
+ "</filter>\n");
return _filter;
};