diff --git a/doc/function/flip_horizontal.txt b/doc/function/flip_horizontal.txt index c3af2872..14bdc90c 100644 --- a/doc/function/flip_horizontal.txt +++ b/doc/function/flip_horizontal.txt @@ -1,5 +1,7 @@ Function: flip_horizontal +DOC_MSE_VERSION: since 0.3.9 + --Usage-- > flip_horizontal(input: image) diff --git a/doc/function/flip_vertical.txt b/doc/function/flip_vertical.txt index 19c7b3d1..913f624e 100644 --- a/doc/function/flip_vertical.txt +++ b/doc/function/flip_vertical.txt @@ -1,5 +1,7 @@ Function: flip_vertical +DOC_MSE_VERSION: since 0.3.9 + --Usage-- > flip_vertical(input: image) diff --git a/doc/function/invert_image.txt b/doc/function/invert_image.txt index 01bbeecf..06e298c6 100644 --- a/doc/function/invert_image.txt +++ b/doc/function/invert_image.txt @@ -1,5 +1,7 @@ Function: invert_image +DOC_MSE_VERSION: since 0.3.9 + --Usage-- > invert_image(input: image) diff --git a/doc/function/recolor_image.txt b/doc/function/recolor_image.txt index 601a317c..2efa35fa 100644 --- a/doc/function/recolor_image.txt +++ b/doc/function/recolor_image.txt @@ -1,7 +1,10 @@ Function: recolor_image +DOC_MSE_VERSION: since 0.3.9 + --Usage-- > recolor_image(input: image, color: color) +> recolor_image(input: image, red: color, green: color, blue: color, white: color) Re-color an image: * Red is replaced by the color @@ -13,14 +16,26 @@ Re-color an image: This function is mostly intended to make symbols in a symbol font wich can match the text color. - --Parameters-- ! Parameter Type Description | @input@ [[type:image]] Image to recolor. | @color@ [[type:color]] Color by which to replace red. +Or +! Parameter Type Description +| @input@ [[type:image]] Image to recolor. +| @red@ [[type:color]] Color by which to replace red. +| @green@ [[type:color]] Color by which to replace green. +| @blue@ [[type:color]] Color by which to replace blue. +| @white@ [[type:color]] Color by which to replace white. + + --Examples-- -> recolor_image("symbol1.png", color: rgb(180,0,0)) == [[Image]] +> recolor_image("symbol1.png", color: rgb(180,0,0)) == [[Image]] >>> recolor_image("symbol1.png", color: rgb(180,0,0)) == "symbol1_red.png" -> recolor_image("symbol1.png", color: rgb(100,255,0)) == [[Image]] +> recolor_image("symbol1.png", color: rgb(100,255,0)) == [[Image]] >>> recolor_image("symbol1.png", color: rgb(100,255,0)) == "symbol1_green.png" + +Custom choices for green, blue and white are also possible: +>>> recolor_image("symbol1.png", red:rgb(0,170,0), green:rgb(200,0,255), blue:rgb(128,0,0), white:rgb(220,255,0)) +>>> == "symbol1_recolor_custom.png" diff --git a/doc/function/rotate.txt b/doc/function/rotate.txt index 3519dce1..5c36edc9 100644 --- a/doc/function/rotate.txt +++ b/doc/function/rotate.txt @@ -1,4 +1,6 @@ -Function: flip_vertical +Function: rotate + +DOC_MSE_VERSION: since 0.3.9 --Usage-- > rotate(input: image, angle: some_number) diff --git a/doc/function/saturate.txt b/doc/function/saturate.txt index 44b0d904..1895bcc4 100644 --- a/doc/function/saturate.txt +++ b/doc/function/saturate.txt @@ -1,5 +1,7 @@ Function: saturate +DOC_MSE_VERSION: since 0.3.9 + --Usage-- > saturate(input: image, amount: saturation amount) diff --git a/doc/function/symbol1_recolor_custom.png b/doc/function/symbol1_recolor_custom.png new file mode 100644 index 00000000..ee81fb40 Binary files /dev/null and b/doc/function/symbol1_recolor_custom.png differ diff --git a/src/gfx/generated_image.cpp b/src/gfx/generated_image.cpp index 697cd8e0..622f54ae 100644 --- a/src/gfx/generated_image.cpp +++ b/src/gfx/generated_image.cpp @@ -221,6 +221,20 @@ bool RecolorImage::operator == (const GeneratedImage& that) const { && color == that2->color; } +Image RecolorImage2::generate(const Options& opt) const { + Image img = image->generate(opt); + recolor(img, red,green,blue,white); + return img; +} +bool RecolorImage2::operator == (const GeneratedImage& that) const { + const RecolorImage2* that2 = dynamic_cast(&that); + return that2 && *image == *that2->image + && red == that2->red + && green == that2->green + && blue == that2->blue + && white == that2->white; +} + // ----------------------------------------------------------------------------- : FlipImage Image FlipImageHorizontal::generate(const Options& opt) const { diff --git a/src/gfx/generated_image.hpp b/src/gfx/generated_image.hpp index d97a0343..7833cad3 100644 --- a/src/gfx/generated_image.hpp +++ b/src/gfx/generated_image.hpp @@ -227,6 +227,17 @@ class RecolorImage : public SimpleFilterImage { private: Color color; }; +/// Recolor an image, with custom colors +class RecolorImage2 : public SimpleFilterImage { + public: + inline RecolorImage2(const GeneratedImageP& image, Color red, Color green, Color blue, Color white) + : SimpleFilterImage(image), red(red), green(green), blue(blue), white(white) + {} + virtual Image generate(const Options& opt) const; + virtual bool operator == (const GeneratedImage& that) const; + private: + Color red,green,blue,white; +}; // ----------------------------------------------------------------------------- : FlipImage diff --git a/src/script/functions/image.cpp b/src/script/functions/image.cpp index d537fd84..07eb843f 100644 --- a/src/script/functions/image.cpp +++ b/src/script/functions/image.cpp @@ -93,8 +93,15 @@ SCRIPT_FUNCTION(invert_image) { SCRIPT_FUNCTION(recolor_image) { SCRIPT_PARAM_C(GeneratedImageP, input); - SCRIPT_PARAM(Color, color); - return intrusive(new RecolorImage(input,color)); + SCRIPT_OPTIONAL_PARAM(Color, red) { + SCRIPT_PARAM(Color, green); + SCRIPT_PARAM(Color, blue); + SCRIPT_PARAM_DEFAULT(Color, white, *wxWHITE); + return intrusive(new RecolorImage2(input,red,green,blue,white)); + } else { + SCRIPT_PARAM(Color, color); + return intrusive(new RecolorImage(input,color)); + } } SCRIPT_FUNCTION(enlarge) {