1
#ifndef SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__
2
#define SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__
3
/* Change the 'PAINT' above to be your file name */
6
* Copyright (C) 2011 Authors:
7
* Ivan Louette (filters)
8
* Nicolas Dufour (UI) <nicoduf@yahoo.fr>
10
* Image paint and draw filters
20
* Released under GNU GPL, read the file 'COPYING' for more information
22
/* ^^^ Change the copyright to be you and your e-mail address ^^^ */
26
#include "extension/internal/clear-n_.h"
27
#include "extension/system.h"
28
#include "extension/extension.h"
36
\brief Custom predefined Chromolitho filter.
38
Chromo effect with customizable edge drawing and graininess
41
* Drawing (boolean, default checked) -> Checked = blend1 (in="convolve1"), unchecked = blend1 (in="composite1")
42
* Transparent (boolean, default unchecked) -> Checked = colormatrix5 (in="colormatrix4"), Unchecked = colormatrix5 (in="component1")
43
* Invert (boolean, default false) -> component1 (tableValues) [adds a trailing 0]
44
* Dented (boolean, default false) -> component1 (tableValues) [adds intermediate 0s]
45
* Lightness (0.->10., default 0.) -> composite1 (k1)
46
* Saturation (0.->1., default 1.) -> colormatrix3 (values)
47
* Noise reduction (1->1000, default 20) -> convolve (kernelMatrix, central value -1001->-2000, default -1020)
48
* Drawing blend (enum, default Normal) -> blend1 (mode)
49
* Smoothness (0.01->10, default 1) -> blur1 (stdDeviation)
50
* Grain (boolean, default unchecked) -> Checked = blend2 (in="colormatrix2"), Unchecked = blend2 (in="blur1")
51
* Grain x frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, first value)
52
* Grain y frequency (0.->1000, default 1000) -> turbulence1 (baseFrequency, second value)
53
* Grain complexity (1->5, default 1) -> turbulence1 (numOctaves)
54
* Grain variation (0->1000, default 0) -> turbulence1 (seed)
55
* Grain expansion (1.->50., default 1.) -> colormatrix1 (n-1 value)
56
* Grain erosion (0.->40., default 0.) -> colormatrix1 (nth value) [inverted]
57
* Grain color (boolean, default true) -> colormatrix2 (values)
58
* Grain blend (enum, default Normal) -> blend2 (mode)
60
class Chromolitho : public Inkscape::Extension::Internal::Filter::Filter {
62
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
65
Chromolitho ( ) : Filter() { };
66
virtual ~Chromolitho ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
68
static void init (void) {
69
Inkscape::Extension::build_from_mem(
70
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
71
"<name>" N_("Chromolitho") "</name>\n"
72
"<id>org.inkscape.effect.filter.Chromolitho</id>\n"
73
"<param name=\"tab\" type=\"notebook\">\n"
74
"<page name=\"optionstab\" _gui-text=\"Options\">\n"
75
"<param name=\"drawing\" gui-text=\"" N_("Drawing mode") "\" type=\"boolean\" >true</param>\n"
76
"<param name=\"dblend\" gui-text=\"" N_("Drawing blend:") "\" type=\"enum\">\n"
77
"<_item value=\"darken\">Darken</_item>\n"
78
"<_item value=\"normal\">Normal</_item>\n"
79
"<_item value=\"multiply\">Multiply</_item>\n"
80
"<_item value=\"screen\">Screen</_item>\n"
81
"<_item value=\"lighten\">Lighten</_item>\n"
83
"<param name=\"transparent\" gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n"
84
"<param name=\"dented\" gui-text=\"" N_("Dented") "\" type=\"boolean\" >false</param>\n"
85
"<param name=\"inverted\" gui-text=\"" N_("Inverted") "\" type=\"boolean\" >false</param>\n"
86
"<param name=\"light\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">0</param>\n"
87
"<param name=\"saturation\" gui-text=\"" N_("Saturation:") "\" type=\"float\" precision=\"2\" appearance=\"full\" min=\"0\" max=\"1\">1</param>\n"
88
"<param name=\"noise\" gui-text=\"" N_("Noise reduction:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"1000\">10</param>\n"
89
"<param name=\"smooth\" gui-text=\"" N_("Smoothness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"10.00\">1</param>\n"
91
"<page name=\"graintab\" _gui-text=\""N_("Grain") "\">\n"
92
"<param name=\"grain\" gui-text=\"" N_("Grain mode") "\" type=\"boolean\" >true</param>\n"
93
"<param name=\"grainxf\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n"
94
"<param name=\"grainyf\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1000\">1000</param>\n"
95
"<param name=\"grainc\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n"
96
"<param name=\"grainv\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"1000\">0</param>\n"
97
"<param name=\"grainexp\" gui-text=\"" N_("Expansion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"1\" max=\"50\">1</param>\n"
98
"<param name=\"grainero\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"40\">0</param>\n"
99
"<param name=\"graincol\" gui-text=\"" N_("Color") "\" type=\"boolean\" >true</param>\n"
100
"<param name=\"gblend\" gui-text=\"" N_("Grain blend:") "\" type=\"enum\">\n"
101
"<_item value=\"normal\">Normal</_item>\n"
102
"<_item value=\"multiply\">Multiply</_item>\n"
103
"<_item value=\"screen\">Screen</_item>\n"
104
"<_item value=\"lighten\">Lighten</_item>\n"
105
"<_item value=\"darken\">Darken</_item>\n"
110
"<object-type>all</object-type>\n"
112
"<submenu name=\"" N_("Filters") "\">\n"
113
"<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
116
"<menu-tip>" N_("Chromo effect with customizable edge drawing and graininess") "</menu-tip>\n"
118
"</inkscape-extension>\n", new Chromolitho());
123
Chromolitho::get_filter_text (Inkscape::Extension::Extension * ext)
125
if (_filter != NULL) g_free((void *)_filter);
127
std::ostringstream b1in;
128
std::ostringstream b2in;
129
std::ostringstream col3in;
130
std::ostringstream transf;
131
std::ostringstream light;
132
std::ostringstream saturation;
133
std::ostringstream noise;
134
std::ostringstream dblend;
135
std::ostringstream smooth;
136
std::ostringstream grain;
137
std::ostringstream grainxf;
138
std::ostringstream grainyf;
139
std::ostringstream grainc;
140
std::ostringstream grainv;
141
std::ostringstream gblend;
142
std::ostringstream grainexp;
143
std::ostringstream grainero;
144
std::ostringstream graincol;
146
if (ext->get_param_bool("drawing"))
149
b1in << "composite1";
151
if (ext->get_param_bool("transparent"))
152
col3in << "colormatrix4";
154
col3in << "component1";
155
light << ext->get_param_float("light");
156
saturation << ext->get_param_float("saturation");
157
noise << (-1000 - ext->get_param_int("noise"));
158
dblend << ext->get_param_enum("dblend");
159
smooth << ext->get_param_float("smooth");
161
if (ext->get_param_bool("dented")) {
166
if (ext->get_param_bool("inverted"))
169
if (ext->get_param_bool("grain"))
170
b2in << "colormatrix2";
173
grainxf << (ext->get_param_float("grainxf") / 1000);
174
grainyf << (ext->get_param_float("grainyf") / 1000);
175
grainc << ext->get_param_int("grainc");
176
grainv << ext->get_param_int("grainv");
177
gblend << ext->get_param_enum("gblend");
178
grainexp << ext->get_param_float("grainexp");
179
grainero << (-ext->get_param_float("grainero"));
180
if (ext->get_param_bool("graincol"))
185
_filter = g_strdup_printf(
186
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Chromolitho\">\n"
187
"<feComposite in=\"SourceGraphic\" in2=\"SourceGraphic\" operator=\"arithmetic\" k1=\"%s\" k2=\"1\" result=\"composite1\" />\n"
188
"<feConvolveMatrix in=\"composite1\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" order=\"3 3\" result=\"convolve1\" />\n"
189
"<feBlend in=\"%s\" in2=\"composite1\" mode=\"%s\" result=\"blend1\" />\n"
190
"<feGaussianBlur in=\"blend1\" stdDeviation=\"%s\" result=\"blur1\" />\n"
191
"<feTurbulence baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" type=\"fractalNoise\" result=\"turbulence1\" />\n"
192
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"colormatrix1\" />\n"
193
"<feColorMatrix type=\"saturate\" values=\"%s\" result=\"colormatrix2\" />\n"
194
"<feBlend in=\"%s\" in2=\"blur1\" mode=\"%s\" result=\"blend2\" />\n"
195
"<feColorMatrix in=\"blend2\" type=\"saturate\" values=\"%s\" result=\"colormatrix3\" />\n"
196
"<feComponentTransfer in=\"colormatrix3\" result=\"component1\">\n"
197
"<feFuncR type=\"discrete\" tableValues=\"%s\" />\n"
198
"<feFuncG type=\"discrete\" tableValues=\"%s\" />\n"
199
"<feFuncB type=\"discrete\" tableValues=\"%s\" />\n"
200
"</feComponentTransfer>\n"
201
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"colormatrix4\" />\n"
202
"<feColorMatrix in=\"%s\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 15 0 \" result=\"colormatrix5\" />\n"
203
"<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
204
"</filter>\n", light.str().c_str(), noise.str().c_str(), b1in.str().c_str(), dblend.str().c_str(), smooth.str().c_str(), grainxf.str().c_str(), grainyf.str().c_str(), grainc.str().c_str(), grainv.str().c_str(), grainexp.str().c_str(), grainero.str().c_str(), graincol.str().c_str(), b2in.str().c_str(), gblend.str().c_str(), saturation.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str(), col3in.str().c_str());
207
}; /* Chromolitho filter */
210
\brief Custom predefined Cross engraving filter.
212
Convert image to an engraving made of vertical and horizontal lines
215
* Clean-up (1->500, default 30) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1030)
216
* Dilatation (1.->50., default 1) -> color2 (n-1th value)
217
* Erosion (0.->50., default 0) -> color2 (nth value 0->-50)
218
* Strength (0.->10., default 0.5) -> composite2 (k2)
219
* Length (0.5->20, default 4) -> blur1 (stdDeviation x), blur2 (stdDeviation y)
220
* Transparent (boolean, default false) -> composite 4 (in, true->composite3, false->blend)
222
class CrossEngraving : public Inkscape::Extension::Internal::Filter::Filter {
224
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
227
CrossEngraving ( ) : Filter() { };
228
virtual ~CrossEngraving ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
230
static void init (void) {
231
Inkscape::Extension::build_from_mem(
232
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
233
"<name>" N_("Cross Engraving") "</name>\n"
234
"<id>org.inkscape.effect.filter.CrossEngraving</id>\n"
235
"<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"500\">30</param>\n"
236
"<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" appearance=\"full\" min=\"1\" max=\"50\">1</param>\n"
237
"<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" appearance=\"full\" min=\"0\" max=\"50\">0</param>\n"
238
"<param name=\"strength\" gui-text=\"" N_("Strength:") "\" type=\"float\" appearance=\"full\" min=\"0.1\" max=\"10\">0.5</param>\n"
239
"<param name=\"length\" gui-text=\"" N_("Length:") "\" type=\"float\" appearance=\"full\" min=\"0.5\" max=\"20\">4</param>\n"
240
"<param name=\"trans\" gui-text=\"" N_("Transparent") "\" type=\"boolean\" >false</param>\n"
242
"<object-type>all</object-type>\n"
244
"<submenu name=\"" N_("Filters") "\">\n"
245
"<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
248
"<menu-tip>" N_("Convert image to an engraving made of vertical and horizontal lines") "</menu-tip>\n"
250
"</inkscape-extension>\n", new CrossEngraving());
255
CrossEngraving::get_filter_text (Inkscape::Extension::Extension * ext)
257
if (_filter != NULL) g_free((void *)_filter);
259
std::ostringstream clean;
260
std::ostringstream dilat;
261
std::ostringstream erosion;
262
std::ostringstream strength;
263
std::ostringstream length;
264
std::ostringstream trans;
266
clean << (-1000 - ext->get_param_int("clean"));
267
dilat << ext->get_param_float("dilat");
268
erosion << (- ext->get_param_float("erosion"));
269
strength << ext->get_param_float("strength");
270
length << ext->get_param_float("length");
271
if (ext->get_param_bool("trans"))
272
trans << "composite3";
276
_filter = g_strdup_printf(
277
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Cross Engraving\">\n"
278
"<feConvolveMatrix in=\"SourceGraphic\" targetY=\"1\" targetX=\"1\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" order=\"3 3\" result=\"convolve\" />\n"
279
"<feComposite in=\"convolve\" in2=\"convolve\" k1=\"1\" k2=\"1\" operator=\"arithmetic\" result=\"composite1\" />\n"
280
"<feColorMatrix in=\"composite1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"color1\" />\n"
281
"<feColorMatrix in=\"color1\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color2\" />\n"
282
"<feComposite in=\"color2\" in2=\"color2\" operator=\"arithmetic\" k2=\"%s\" result=\"composite2\" />\n"
283
"<feGaussianBlur in=\"composite2\" stdDeviation=\"%s 0.01\" result=\"blur1\" />\n"
284
"<feGaussianBlur in=\"composite2\" stdDeviation=\"0.01 %s\" result=\"blur2\" />\n"
285
"<feComposite in=\"blur2\" in2=\"blur1\" k3=\"1\" k2=\"1\" operator=\"arithmetic\" result=\"composite3\" />\n"
286
"<feFlood flood-color=\"rgb(255,255,255)\" flood-opacity=\"1\" result=\"flood\" />\n"
287
"<feBlend in=\"flood\" in2=\"composite3\" mode=\"multiply\" result=\"blend\" />\n"
288
"<feComposite in=\"%s\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite4\" />\n"
289
"</filter>\n", clean.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), strength.str().c_str(), length.str().c_str(), length.str().c_str(), trans.str().c_str());
292
}; /* CrossEngraving filter */
295
\brief Custom predefined Drawing filter.
297
Convert images to duochrome drawings.
300
* Simplification strength (0.01->20, default 0.6) -> blur1 (stdDeviation)
301
* Clean-up (1->500, default 10) -> convolve1 (kernelMatrix, central value -1001->-1500, default -1010)
302
* Erase (0.->6., default 0) -> composite1 (k4)
303
* Smoothness strength (0.01->20, default 0.6) -> blur2 (stdDeviation)
304
* Dilatation (1.->50., default 6) -> color2 (n-1th value)
305
* Erosion (0.->50., default 2) -> color2 (nth value 0->-50)
306
* translucent (boolean, default false) -> composite 8 (in, true->merge1, false->color5)
308
* Blur strength (0.01->20., default 1.) -> blur3 (stdDeviation)
309
* Blur dilatation (1.->50., default 6) -> color4 (n-1th value)
310
* Blur erosion (0.->50., default 2) -> color4 (nth value 0->-50)
312
* Stroke color (guint, default 64,64,64,255) -> flood2 (flood-color), composite3 (k2)
313
* Image on stroke (boolean, default false) -> composite2 (in="flood2" true-> in="SourceGraphic")
314
* Offset (-100->100, default 0) -> offset (val)
316
* Fill color (guint, default 200,200,200,255) -> flood3 (flood-opacity), composite5 (k2)
317
* Image on fill (boolean, default false) -> composite4 (in="flood3" true-> in="SourceGraphic")
321
class Drawing : public Inkscape::Extension::Internal::Filter::Filter {
323
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
326
Drawing ( ) : Filter() { };
327
virtual ~Drawing ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
329
static void init (void) {
330
Inkscape::Extension::build_from_mem(
331
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
332
"<name>" N_("Drawing") "</name>\n"
333
"<id>org.inkscape.effect.filter.Drawing</id>\n"
334
"<param name=\"tab\" type=\"notebook\">\n"
335
"<page name=\"optionstab\" _gui-text=\"Options\">\n"
336
"<_param name=\"simplifyheader\" type=\"description\" appearance=\"header\">" N_("Simplify") "</_param>\n"
337
"<param name=\"simply\" gui-text=\"" N_("Strength:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n"
338
"<param name=\"clean\" gui-text=\"" N_("Clean-up:") "\" type=\"int\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"500\">10</param>\n"
339
"<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"60\">0</param>\n"
340
"<param name=\"translucent\" gui-text=\"" N_("Translucent") "\" indent=\"1\" type=\"boolean\" >false</param>\n"
341
"<_param name=\"smoothheader\" type=\"description\" appearance=\"header\">" N_("Smoothness") "</_param>\n"
342
"<param name=\"smooth\" gui-text=\"" N_("Strength:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">0.6</param>\n"
343
"<param name=\"dilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n"
344
"<param name=\"erosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n"
345
"<_param name=\"meltheader\" type=\"description\" appearance=\"header\">" N_("Melt") "</_param>\n"
346
"<param name=\"blur\" gui-text=\"" N_("Level:") "\" type=\"float\" indent=\"1\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1</param>\n"
347
"<param name=\"bdilat\" gui-text=\"" N_("Dilatation:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"1\" max=\"50\">6</param>\n"
348
"<param name=\"berosion\" gui-text=\"" N_("Erosion:") "\" type=\"float\" indent=\"1\" appearance=\"full\" min=\"0\" max=\"50\">2</param>\n"
350
"<page name=\"co11tab\" _gui-text=\"Fill color\">\n"
351
"<param name=\"fcolor\" gui-text=\"" N_("Fill color") "\" type=\"color\">-1515870721</param>\n"
352
"<param name=\"iof\" gui-text=\"" N_("Image on fill") "\" type=\"boolean\" >false</param>\n"
354
"<page name=\"co12tab\" _gui-text=\"Stroke color\">\n"
355
"<param name=\"scolor\" gui-text=\"" N_("Stroke color") "\" type=\"color\">589505535</param>\n"
356
"<param name=\"ios\" gui-text=\"" N_("Image on stroke") "\" type=\"boolean\" >false</param>\n"
357
"<param name=\"offset\" gui-text=\"" N_("Offset:") "\" type=\"int\" appearance=\"full\" min=\"-100\" max=\"100\">0</param>\n"
361
"<object-type>all</object-type>\n"
363
"<submenu name=\"" N_("Filters") "\">\n"
364
"<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
367
"<menu-tip>" N_("Convert images to duochrome drawings") "</menu-tip>\n"
369
"</inkscape-extension>\n", new Drawing());
374
Drawing::get_filter_text (Inkscape::Extension::Extension * ext)
376
if (_filter != NULL) g_free((void *)_filter);
378
std::ostringstream simply;
379
std::ostringstream clean;
380
std::ostringstream erase;
381
std::ostringstream smooth;
382
std::ostringstream dilat;
383
std::ostringstream erosion;
384
std::ostringstream translucent;
385
std::ostringstream offset;
386
std::ostringstream blur;
387
std::ostringstream bdilat;
388
std::ostringstream berosion;
389
std::ostringstream strokea;
390
std::ostringstream stroker;
391
std::ostringstream strokeg;
392
std::ostringstream strokeb;
393
std::ostringstream ios;
394
std::ostringstream filla;
395
std::ostringstream fillr;
396
std::ostringstream fillg;
397
std::ostringstream fillb;
398
std::ostringstream iof;
400
simply << ext->get_param_float("simply");
401
clean << (-1000 - ext->get_param_int("clean"));
402
erase << (ext->get_param_float("erase") / 10);
403
smooth << ext->get_param_float("smooth");
404
dilat << ext->get_param_float("dilat");
405
erosion << (- ext->get_param_float("erosion"));
406
if (ext->get_param_bool("translucent"))
407
translucent << "merge1";
409
translucent << "color5";
410
offset << ext->get_param_int("offset");
412
blur << ext->get_param_float("blur");
413
bdilat << ext->get_param_float("bdilat");
414
berosion << (- ext->get_param_float("berosion"));
416
guint32 fcolor = ext->get_param_color("fcolor");
417
fillr << ((fcolor >> 24) & 0xff);
418
fillg << ((fcolor >> 16) & 0xff);
419
fillb << ((fcolor >> 8) & 0xff);
420
filla << (fcolor & 0xff) / 255.0F;
421
if (ext->get_param_bool("iof"))
422
iof << "SourceGraphic";
426
guint32 scolor = ext->get_param_color("scolor");
427
stroker << ((scolor >> 24) & 0xff);
428
strokeg << ((scolor >> 16) & 0xff);
429
strokeb << ((scolor >> 8) & 0xff);
430
strokea << (scolor & 0xff) / 255.0F;
431
if (ext->get_param_bool("ios"))
432
ios << "SourceGraphic";
436
_filter = g_strdup_printf(
437
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Drawing\">\n"
438
"<feGaussianBlur in=\"SourceGraphic\" stdDeviation=\"%s\" result=\"blur1\" />\n"
439
"<feConvolveMatrix in=\"blur1\" targetX=\"1\" targetY=\"1\" order=\"3 3\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0 \" result=\"convolve1\" />\n"
440
"<feComposite in=\"convolve1\" in2=\"convolve1\" k1=\"1\" k2=\"1\" k4=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n"
441
"<feColorMatrix in=\"composite1\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"color1\" />\n"
442
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur2\" />\n"
443
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color2\" />\n"
444
"<feFlood flood-color=\"rgb(255,255,255)\" result=\"flood1\" />\n"
445
"<feBlend in2=\"color2\" mode=\"multiply\" result=\"blend1\" />\n"
446
"<feComponentTransfer in=\"blend1\" result=\"component1\">\n"
447
"<feFuncR type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
448
"<feFuncG type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
449
"<feFuncB type=\"discrete\" tableValues=\"0 1 1 1\" />\n"
450
"</feComponentTransfer>\n"
451
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur3\" />\n"
452
"<feColorMatrix in=\"blur3\" values=\"0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -0.2125 -0.7154 -0.0721 1 0 \" result=\"color3\" />\n"
453
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 %s %s \" result=\"color4\" />\n"
454
"<feFlood flood-color=\"rgb(%s,%s,%s)\" result=\"flood2\" />\n"
455
"<feComposite in=\"%s\" in2=\"color4\" operator=\"in\" result=\"composite2\" />\n"
456
"<feComposite in=\"composite2\" in2=\"composite2\" operator=\"arithmetic\" k2=\"%s\" result=\"composite3\" />\n"
457
"<feOffset dx=\"%s\" dy=\"%s\" result=\"offset1\" />\n"
458
"<feFlood in=\"color4\" flood-color=\"rgb(%s,%s,%s)\" result=\"flood3\" />\n"
459
"<feComposite in=\"%s\" in2=\"color4\" operator=\"out\" result=\"composite4\" />\n"
460
"<feComposite in=\"composite4\" in2=\"composite4\" operator=\"arithmetic\" k2=\"%s\" result=\"composite5\" />\n"
461
"<feMerge result=\"merge1\">\n"
462
"<feMergeNode in=\"composite5\" />\n"
463
"<feMergeNode in=\"offset1\" />\n"
465
"<feColorMatrix values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1.3 0 \" result=\"color5\" flood-opacity=\"0.56\" />\n"
466
"<feComposite in=\"%s\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite8\" />\n"
467
"</filter>\n", simply.str().c_str(), clean.str().c_str(), erase.str().c_str(), smooth.str().c_str(), dilat.str().c_str(), erosion.str().c_str(), blur.str().c_str(), bdilat.str().c_str(), berosion.str().c_str(), stroker.str().c_str(), strokeg.str().c_str(), strokeb.str().c_str(), ios.str().c_str(), strokea.str().c_str(), offset.str().c_str(), offset.str().c_str(), fillr.str().c_str(), fillg.str().c_str(), fillb.str().c_str(), iof.str().c_str(), filla.str().c_str(), translucent.str().c_str());
470
}; /* Drawing filter */
474
\brief Custom predefined Electrize filter.
476
Electro solarization effects.
479
* Simplify (0.01->10., default 2.) -> blur (stdDeviation)
480
* Effect type (enum: table or discrete, default "table") -> component (type)
481
* Level (0->10, default 3) -> component (tableValues)
482
* Inverted (boolean, default false) -> component (tableValues)
484
class Electrize : public Inkscape::Extension::Internal::Filter::Filter {
486
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
489
Electrize ( ) : Filter() { };
490
virtual ~Electrize ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
492
static void init (void) {
493
Inkscape::Extension::build_from_mem(
494
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
495
"<name>" N_("Electrize") "</name>\n"
496
"<id>org.inkscape.effect.filter.Electrize</id>\n"
497
"<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" min=\"0.01\" max=\"10.0\">2.0</param>\n"
498
"<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n"
499
"<_item value=\"table\">" N_("Table") "</_item>\n"
500
"<_item value=\"discrete\">" N_("Discrete") "</_item>\n"
502
"<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"10\">3</param>\n"
503
"<param name=\"invert\" gui-text=\"" N_("Inverted") "\" type=\"boolean\">false</param>\n"
505
"<object-type>all</object-type>\n"
507
"<submenu name=\"" N_("Filters") "\">\n"
508
"<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
511
"<menu-tip>" N_("Electro solarization effects") "</menu-tip>\n"
513
"</inkscape-extension>\n", new Electrize());
518
Electrize::get_filter_text (Inkscape::Extension::Extension * ext)
520
if (_filter != NULL) g_free((void *)_filter);
522
std::ostringstream blur;
523
std::ostringstream type;
524
std::ostringstream values;
526
blur << ext->get_param_float("blur");
527
type << ext->get_param_enum("type");
529
// TransfertComponent table values are calculated based on the effect level and inverted parameters.
531
int levels = ext->get_param_int("levels") + 1;
532
if (ext->get_param_bool("invert")) {
536
for ( int step = 1 ; step <= levels ; step++ ) {
543
values << " " << val;
546
_filter = g_strdup_printf(
547
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Electrize\">\n"
548
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
549
"<feComponentTransfer in=\"blur\" result=\"component\" >\n"
550
"<feFuncR type=\"%s\" tableValues=\"%s\" />\n"
551
"<feFuncG type=\"%s\" tableValues=\"%s\" />\n"
552
"<feFuncB type=\"%s\" tableValues=\"%s\" />\n"
553
"</feComponentTransfer>\n"
554
"</filter>\n", blur.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str(), type.str().c_str(), values.str().c_str());
557
}; /* Electrize filter */
560
\brief Custom predefined Neon draw filter.
562
Posterize and draw smooth lines around color shapes
565
* Lines type (enum, default smooth) ->
566
smooth = component1 (type="table"), component2 (type="table"), composite1 (in2="blur2")
567
hard = component1 (type="discrete"), component2 (type="discrete"), composite1 (in2="component1")
568
* Simplify (0.01->20., default 1.5) -> blur1 (stdDeviation)
569
* Line width (0.01->20., default 1.5) -> blur2 (stdDeviation)
570
* Lightness (0.->10., default 0.5) -> composite1 (k3)
571
* Blend (enum [normal, multiply, screen], default normal) -> blend (mode)
572
* Dark mode (boolean, default false) -> composite1 (true: in2="component2")
574
class NeonDraw : public Inkscape::Extension::Internal::Filter::Filter {
576
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
579
NeonDraw ( ) : Filter() { };
580
virtual ~NeonDraw ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
582
static void init (void) {
583
Inkscape::Extension::build_from_mem(
584
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
585
"<name>" N_("Neon Draw") "</name>\n"
586
"<id>org.inkscape.effect.filter.NeonDraw</id>\n"
587
"<param name=\"type\" gui-text=\"" N_("Line type:") "\" type=\"enum\">\n"
588
"<_item value=\"table\">" N_("Smoothed") "</_item>\n"
589
"<_item value=\"discrete\">" N_("Contrasted") "</_item>\n"
591
"<param name=\"simply\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
592
"<param name=\"width\" gui-text=\"" N_("Line width:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">1.5</param>\n"
593
"<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"10.00\">0.5</param>\n"
594
"<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
595
"<_item value=\"normal\">Normal</_item>\n"
596
"<_item value=\"multiply\">Multiply</_item>\n"
597
"<_item value=\"screen\">Screen</_item>\n"
599
"<param name=\"dark\" gui-text=\"" N_("Dark mode") "\" type=\"boolean\" >false</param>\n"
601
"<object-type>all</object-type>\n"
603
"<submenu name=\"" N_("Filters") "\">\n"
604
"<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
607
"<menu-tip>" N_("Posterize and draw smooth lines around color shapes") "</menu-tip>\n"
609
"</inkscape-extension>\n", new NeonDraw());
614
NeonDraw::get_filter_text (Inkscape::Extension::Extension * ext)
616
if (_filter != NULL) g_free((void *)_filter);
618
std::ostringstream blend;
619
std::ostringstream simply;
620
std::ostringstream width;
621
std::ostringstream lightness;
622
std::ostringstream type;
623
std::ostringstream dark;
625
type << ext->get_param_enum("type");
626
blend << ext->get_param_enum("blend");
627
simply << ext->get_param_float("simply");
628
width << ext->get_param_float("width");
629
lightness << ext->get_param_float("lightness");
631
const gchar *typestr = ext->get_param_enum("type");
632
if (ext->get_param_bool("dark")) {
633
dark << "component2";
634
} else if ((g_ascii_strcasecmp("table", typestr) == 0)) {
637
dark << "component1";
640
_filter = g_strdup_printf(
641
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Neon Draw\">\n"
642
"<feBlend mode=\"%s\" result=\"blend\" />\n"
643
"<feGaussianBlur in=\"blend\" stdDeviation=\"%s\" result=\"blur1\" />\n"
644
"<feComponentTransfer result=\"component1\">\n"
645
"<feFuncR type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
646
"<feFuncG type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
647
"<feFuncB type=\"discrete\" tableValues=\"0 0.3 0.6 1 1\" />\n"
648
"</feComponentTransfer>\n"
649
"<feGaussianBlur in=\"component1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
650
"<feComponentTransfer in=\"blur2\" result=\"component2\">\n"
651
"<feFuncR type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
652
"<feFuncG type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
653
"<feFuncB type=\"%s\" tableValues=\"0 1 0 1 0 1 0 1\" />\n"
654
"</feComponentTransfer>\n"
655
"<feComposite in=\"component2\" in2=\"%s\" k3=\"%s\" operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
656
"<feComposite in=\"composite1\" in2=\"SourceGraphic\" operator=\"in\" result=\"composite2\" />\n"
657
"</filter>\n", blend.str().c_str(), simply.str().c_str(), width.str().c_str(), type.str().c_str(), type.str().c_str(), type.str().c_str(), dark.str().c_str(), lightness.str().c_str());
660
}; /* NeonDraw filter */
663
\brief Custom predefined Point engraving filter.
665
Convert image to a transparent point engraving
669
* Turbulence type (enum, default fractalNoise else turbulence) -> turbulence (type)
670
* Horizontal frequency (0.001->1., default 1) -> turbulence (baseFrequency [/100])
671
* Vertical frequency (0.001->1., default 1) -> turbulence (baseFrequency [/100])
672
* Complexity (1->5, default 3) -> turbulence (numOctaves)
673
* Variation (0->1000, default 0) -> turbulence (seed)
674
* Noise reduction (-1000->-1500, default -1045) -> convolve (kernelMatrix, central value)
675
* Noise blend (enum, all blend options, default normal) -> blend (mode)
676
* Lightness (0.->10., default 2.5) -> composite1 (k1)
677
* Grain lightness (0.->10., default 1.3) -> composite1 (k2)
678
* Erase (0.00->1., default 0) -> composite1 (k4)
679
* Blur (0.01->2., default 0.5) -> blur (stdDeviation)
681
* Drawing color (guint32, default rgb(255,255,255)) -> flood1 (flood-color, flood-opacity)
683
* Background color (guint32, default rgb(99,89,46)) -> flood2 (flood-color, flood-opacity)
686
class PointEngraving : public Inkscape::Extension::Internal::Filter::Filter {
688
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
691
PointEngraving ( ) : Filter() { };
692
virtual ~PointEngraving ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
694
static void init (void) {
695
Inkscape::Extension::build_from_mem(
696
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
697
"<name>" N_("Point Engraving") "</name>\n"
698
"<id>org.inkscape.effect.filter.PointEngraving</id>\n"
699
"<param name=\"tab\" type=\"notebook\">\n"
700
"<page name=\"optionstab\" _gui-text=\"" N_("Options") "\">\n"
701
"<param name=\"type\" gui-text=\"" N_("Turbulence type:") "\" type=\"enum\">\n"
702
"<_item value=\"fractalNoise\">" N_("Fractal noise") "</_item>\n"
703
"<_item value=\"turbulence\">" N_("Turbulence") "</_item>\n"
705
"<param name=\"hfreq\" gui-text=\"" N_("Horizontal frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n"
706
"<param name=\"vfreq\" gui-text=\"" N_("Vertical frequency:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.1\" max=\"100.00\">100</param>\n"
707
"<param name=\"complexity\" gui-text=\"" N_("Complexity:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"5\">1</param>\n"
708
"<param name=\"variation\" gui-text=\"" N_("Variation:") "\" type=\"int\" appearance=\"full\" min=\"1\" max=\"100\">0</param>\n"
709
"<param name=\"reduction\" gui-text=\"" N_("Noise reduction:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"500\">45</param>\n"
710
"<param name=\"blend\" gui-text=\"" N_("Noise blend:") "\" type=\"enum\">\n"
711
"<_item value=\"multiply\">" N_("Multiply") "</_item>\n"
712
"<_item value=\"normal\">" N_("Normal") "</_item>\n"
713
"<_item value=\"screen\">" N_("Screen") "</_item>\n"
714
"<_item value=\"lighten\">" N_("Lighten") "</_item>\n"
715
"<_item value=\"darken\">" N_("Darken") "</_item>\n"
717
"<param name=\"lightness\" gui-text=\"" N_("Lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">2.5</param>\n"
718
"<param name=\"grain\" gui-text=\"" N_("Grain lightness:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"10\">1.3</param>\n"
719
"<param name=\"erase\" gui-text=\"" N_("Erase:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0\" max=\"1\">0</param>\n"
720
"<param name=\"blur\" gui-text=\"" N_("Blur:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"2\">0.5</param>\n"
722
"<page name=\"fcolortab\" _gui-text=\"" N_("Fill color") "\">\n"
723
"<param name=\"fcolor\" gui-text=\"" N_("Color") "\" type=\"color\">-1</param>\n"
724
"<param name=\"iof\" gui-text=\"" N_("Image on fill") "\" type=\"boolean\" >false</param>\n"
726
"<page name=\"pcolortab\" _gui-text=\"" N_("Points color") "\">\n"
727
"<param name=\"pcolor\" gui-text=\"" N_("Color") "\" type=\"color\">1666789119</param>\n"
728
"<param name=\"iop\" gui-text=\"" N_("Image on points") "\" type=\"boolean\" >false</param>\n"
732
"<object-type>all</object-type>\n"
734
"<submenu name=\"" N_("Filters") "\">\n"
735
"<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
738
"<menu-tip>" N_("Convert image to a transparent point engraving") "</menu-tip>\n"
740
"</inkscape-extension>\n", new PointEngraving());
746
PointEngraving::get_filter_text (Inkscape::Extension::Extension * ext)
748
if (_filter != NULL) g_free((void *)_filter);
750
std::ostringstream type;
751
std::ostringstream hfreq;
752
std::ostringstream vfreq;
753
std::ostringstream complexity;
754
std::ostringstream variation;
755
std::ostringstream reduction;
756
std::ostringstream blend;
757
std::ostringstream lightness;
758
std::ostringstream grain;
759
std::ostringstream erase;
760
std::ostringstream blur;
761
std::ostringstream r;
762
std::ostringstream g;
763
std::ostringstream b;
764
std::ostringstream a;
765
std::ostringstream br;
766
std::ostringstream bg;
767
std::ostringstream bb;
768
std::ostringstream ba;
769
std::ostringstream iof;
770
std::ostringstream iop;
772
type << ext->get_param_enum("type");
773
hfreq << ext->get_param_float("hfreq") / 100;
774
vfreq << ext->get_param_float("vfreq") / 100;
775
complexity << ext->get_param_int("complexity");
776
variation << ext->get_param_int("variation");
777
reduction << (-1000 - ext->get_param_int("reduction"));
778
blend << ext->get_param_enum("blend");
779
lightness << ext->get_param_float("lightness");
780
grain << ext->get_param_float("grain");
781
erase << ext->get_param_float("erase");
782
blur << ext->get_param_float("blur");
784
guint32 fcolor = ext->get_param_color("fcolor");
785
r << ((fcolor >> 24) & 0xff);
786
g << ((fcolor >> 16) & 0xff);
787
b << ((fcolor >> 8) & 0xff);
788
a << (fcolor & 0xff) / 255.0F;
790
guint32 pcolor = ext->get_param_color("pcolor");
791
br << ((pcolor >> 24) & 0xff);
792
bg << ((pcolor >> 16) & 0xff);
793
bb << ((pcolor >> 8) & 0xff);
794
ba << (pcolor & 0xff) / 255.0F;
796
if (ext->get_param_bool("iof"))
797
iof << "SourceGraphic";
801
if (ext->get_param_bool("iop"))
802
iop << "SourceGraphic";
806
_filter = g_strdup_printf(
807
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" inkscape:label=\"Point Engraving\" style=\"color-interpolation-filters:sRGB;\">\n"
808
"<feConvolveMatrix in=\"SourceGraphic\" kernelMatrix=\"0 250 0 250 %s 250 0 250 0\" order=\"3 3\" result=\"convolve\" />\n"
809
"<feBlend in=\"convolve\" in2=\"SourceGraphic\" mode=\"%s\" result=\"blend\" />\n"
810
"<feTurbulence type=\"%s\" baseFrequency=\"%s %s\" numOctaves=\"%s\" seed=\"%s\" result=\"turbulence\" />\n"
811
"<feColorMatrix in=\"blend\" type=\"luminanceToAlpha\" result=\"colormatrix1\" />\n"
812
"<feComposite in=\"turbulence\" in2=\"colormatrix1\" k1=\"%s\" k2=\"%s\" k4=\"%s\" operator=\"arithmetic\" result=\"composite1\" />\n"
813
"<feColorMatrix in=\"composite1\" values=\"1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 10 -9 \" result=\"colormatrix2\" />\n"
814
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur\" />\n"
815
"<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood1\" />\n"
816
"<feComposite in=\"%s\" in2=\"blur\" operator=\"out\" result=\"composite2\" />\n"
817
"<feFlood flood-color=\"rgb(%s,%s,%s)\" flood-opacity=\"%s\" result=\"flood2\" />\n"
818
"<feComposite in=\"%s\" in2=\"blur\" operator=\"in\" result=\"composite3\" />\n"
819
"<feComposite in=\"composite3\" in2=\"composite2\" k2=\"%s\" k3=\"%s\" operator=\"arithmetic\" result=\"composite4\" />\n"
820
"<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite5\" />\n"
821
"</filter>\n", reduction.str().c_str(), blend.str().c_str(),
822
type.str().c_str(), hfreq.str().c_str(), vfreq.str().c_str(), complexity.str().c_str(), variation.str().c_str(),
823
lightness.str().c_str(), grain.str().c_str(), erase.str().c_str(), blur.str().c_str(),
824
br.str().c_str(), bg.str().c_str(), bb.str().c_str(), ba.str().c_str(), iop.str().c_str(),
825
r.str().c_str(), g.str().c_str(), b.str().c_str(), a.str().c_str(), iof.str().c_str(),
826
a.str().c_str(), ba.str().c_str() );
829
}; /* Point engraving filter */
832
\brief Custom predefined Poster paint filter.
834
Poster and painting effects.
837
* Effect type (enum, default "Normal") ->
838
Normal = feComponentTransfer
839
Dented = Normal + intermediate values
840
* Transfer type (enum, default "descrete") -> component (type)
841
* Levels (0->15, default 5) -> component (tableValues)
842
* Blend mode (enum, default "Lighten") -> blend (mode)
843
* Primary simplify (0.01->100., default 4.) -> blur1 (stdDeviation)
844
* Secondary simplify (0.01->100., default 0.5) -> blur2 (stdDeviation)
845
* Pre-saturation (0.->1., default 1.) -> color1 (values)
846
* Post-saturation (0.->1., default 1.) -> color2 (values)
847
* Simulate antialiasing (boolean, default false) -> blur3 (true->stdDeviation=0.5, false->stdDeviation=0.01)
849
class Posterize : public Inkscape::Extension::Internal::Filter::Filter {
851
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
854
Posterize ( ) : Filter() { };
855
virtual ~Posterize ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
857
static void init (void) {
858
Inkscape::Extension::build_from_mem(
859
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
860
"<name>" N_("Poster Paint") "</name>\n"
861
"<id>org.inkscape.effect.filter.Posterize</id>\n"
862
"<param name=\"type\" gui-text=\"" N_("Effect type:") "\" type=\"enum\">\n"
863
"<_item value=\"normal\">Normal</_item>\n"
864
"<_item value=\"dented\">Dented</_item>\n"
866
"<param name=\"table\" gui-text=\"" N_("Transfer type:") "\" type=\"enum\">\n"
867
"<_item value=\"discrete\">" N_("Poster") "</_item>\n"
868
"<_item value=\"table\">" N_("Painting") "</_item>\n"
870
"<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"15\">5</param>\n"
871
"<param name=\"blend\" gui-text=\"" N_("Blend mode:") "\" type=\"enum\">\n"
872
"<_item value=\"lighten\">Lighten</_item>\n"
873
"<_item value=\"normal\">Normal</_item>\n"
874
"<_item value=\"darken\">Darken</_item>\n"
875
"<_item value=\"multiply\">Multiply</_item>\n"
876
"<_item value=\"screen\">Screen</_item>\n"
878
"<param name=\"blur1\" gui-text=\"" N_("Simplify (primary):") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">4.0</param>\n"
879
"<param name=\"blur2\" gui-text=\"" N_("Simplify (secondary):") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"100.00\">0.5</param>\n"
880
"<param name=\"presaturation\" gui-text=\"" N_("Pre-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n"
881
"<param name=\"postsaturation\" gui-text=\"" N_("Post-saturation:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.00\" max=\"1.00\">1.00</param>\n"
882
"<param name=\"antialiasing\" gui-text=\"" N_("Simulate antialiasing") "\" type=\"boolean\">false</param>\n"
884
"<object-type>all</object-type>\n"
886
"<submenu name=\"" N_("Filters") "\">\n"
887
"<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
890
"<menu-tip>" N_("Poster and painting effects") "</menu-tip>\n"
892
"</inkscape-extension>\n", new Posterize());
897
Posterize::get_filter_text (Inkscape::Extension::Extension * ext)
899
if (_filter != NULL) g_free((void *)_filter);
901
std::ostringstream table;
902
std::ostringstream blendmode;
903
std::ostringstream blur1;
904
std::ostringstream blur2;
905
std::ostringstream presat;
906
std::ostringstream postsat;
907
std::ostringstream transf;
908
std::ostringstream antialias;
910
table << ext->get_param_enum("table");
911
blendmode << ext->get_param_enum("blend");
912
blur1 << ext->get_param_float("blur1");
913
blur2 << ext->get_param_float("blur2");
914
presat << ext->get_param_float("presaturation");
915
postsat << ext->get_param_float("postsaturation");
917
// TransfertComponent table values are calculated based on the poster type.
919
int levels = ext->get_param_int("levels") + 1;
920
const gchar *effecttype = ext->get_param_enum("type");
923
if ((g_ascii_strcasecmp("dented", effecttype) == 0)) {
929
for ( int step = 1 ; step <= levels ; step++ ) {
930
val = (float) step / levels;
931
transf << " " << val;
932
if ((g_ascii_strcasecmp("dented", effecttype) == 0)) {
933
transf << " " << (val - ((float) 1 / (3 * levels))) << " " << (val + ((float) 1 / (2 * levels)));
939
if (ext->get_param_bool("antialiasing"))
944
_filter = g_strdup_printf(
945
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Poster Paint\">\n"
946
"<feComposite operator=\"arithmetic\" k2=\"1\" result=\"composite1\" />\n"
947
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur1\" />\n"
948
"<feGaussianBlur in=\"composite1\" stdDeviation=\"%s\" result=\"blur2\" />\n"
949
"<feBlend in2=\"blur1\" mode=\"%s\" result=\"blend\"/>\n"
950
"<feColorMatrix type=\"saturate\" values=\"%s\" result=\"color1\" />\n"
951
"<feComponentTransfer result=\"component\">\n"
952
"<feFuncR type=\"%s\" tableValues=\"%s\" />\n"
953
"<feFuncG type=\"%s\" tableValues=\"%s\" />\n"
954
"<feFuncB type=\"%s\" tableValues=\"%s\" />\n"
955
"</feComponentTransfer>\n"
956
"<feColorMatrix type=\"saturate\" values=\"%s\" result=\"color2\" />\n"
957
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur3\" />\n"
958
"<feComposite in2=\"SourceGraphic\" operator=\"in\" result=\"composite3\" />\n"
959
"</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());
962
}; /* Posterize filter */
965
\brief Custom predefined Posterize basic filter.
967
Simple posterizing effect
970
* Levels (0->20, default 5) -> component1 (tableValues)
971
* Blur (0.01->20., default 4.) -> blur1 (stdDeviation)
973
class PosterizeBasic : public Inkscape::Extension::Internal::Filter::Filter {
975
virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext);
978
PosterizeBasic ( ) : Filter() { };
979
virtual ~PosterizeBasic ( ) { if (_filter != NULL) g_free((void *)_filter); return; }
981
static void init (void) {
982
Inkscape::Extension::build_from_mem(
983
"<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n"
984
"<name>" N_("Posterize Basic") "</name>\n"
985
"<id>org.inkscape.effect.filter.PosterizeBasic</id>\n"
986
"<param name=\"levels\" gui-text=\"" N_("Levels:") "\" type=\"int\" appearance=\"full\" min=\"0\" max=\"20\">5</param>\n"
987
"<param name=\"blur\" gui-text=\"" N_("Simplify:") "\" type=\"float\" appearance=\"full\" precision=\"2\" min=\"0.01\" max=\"20.00\">4.0</param>\n"
989
"<object-type>all</object-type>\n"
991
"<submenu name=\"" N_("Filters") "\">\n"
992
"<submenu name=\"" N_("Image Paint and Draw") "\"/>\n"
995
"<menu-tip>" N_("Simple posterizing effect") "</menu-tip>\n"
997
"</inkscape-extension>\n", new PosterizeBasic());
1002
PosterizeBasic::get_filter_text (Inkscape::Extension::Extension * ext)
1004
if (_filter != NULL) g_free((void *)_filter);
1006
std::ostringstream blur;
1007
std::ostringstream transf;
1009
blur << ext->get_param_float("blur");
1012
int levels = ext->get_param_int("levels") + 1;
1014
for ( int step = 1 ; step <= levels ; step++ ) {
1015
val = (float) step / levels;
1016
transf << " " << val;
1020
_filter = g_strdup_printf(
1021
"<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" inkscape:label=\"Posterize Basic\">\n"
1022
"<feGaussianBlur stdDeviation=\"%s\" result=\"blur1\" />\n"
1023
"<feComponentTransfer in=\"blur1\" result=\"component1\">\n"
1024
"<feFuncR type=\"discrete\" tableValues=\"%s\" />\n"
1025
"<feFuncG type=\"discrete\" tableValues=\"%s\" />\n"
1026
"<feFuncB type=\"discrete\" tableValues=\"%s\" />\n"
1027
"</feComponentTransfer>\n"
1028
"<feComposite in=\"component1\" in2=\"SourceGraphic\" operator=\"in\" />\n"
1029
"</filter>\n", blur.str().c_str(), transf.str().c_str(), transf.str().c_str(), transf.str().c_str());
1032
}; /* PosterizeBasic filter */
1034
}; /* namespace Filter */
1035
}; /* namespace Internal */
1036
}; /* namespace Extension */
1037
}; /* namespace Inkscape */
1039
/* Change the 'PAINT' below to be your file name */
1040
#endif /* SEEN_INKSCAPE_EXTENSION_INTERNAL_FILTER_PAINT_H__ */