4D v16SVG_Filter_ColorMatrix |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v16
SVG_Filter_ColorMatrix
|
SVG_Filter_ColorMatrix ( svgObject {; in ; result} {; type {; values}} ) -> Function result | ||||||||
Parameter | Type | Description | ||||||
svgObject | SVG_Ref |
![]() |
SVG object reference | |||||
in | Text |
![]() |
Identifies input for the given filter primitive | |||||
result | Text |
![]() |
Provides a reference for the output result of a filter | |||||
type | Text |
![]() |
Indicates the type of matrix operation | |||||
values | Text |
![]() |
Numeric values for the transformation matrix | |||||
Function result | SVG_Ref |
![]() |
Reference for SVG object with new color values | |||||
The SVG_Filter_ColorMatrix command applies a color matrix transformation to each pixel in the source image passed in the svgObject parameter to produce a result with a new set of color values.
In the in parameter, you can either pass a string which matches a previous ‘result’ value or one of the six following keywords:
If no value is passed and this is the first filter primitive, then the SourceGraphic is used as its input. If no value is provided and this is a subsequent filter primitive, then this filter primitive will use the result from the previous filter primitive as its input.
In the result parameter, you pass a reference for the output result of a filter which can be referenced by the in parameter on a subsequent use of this command within the same ‘filter’ element. If no value is provided, the output is only available for re-use as the implicit input for the next filter primitive if that filter primitive provides no value for its in parameter.
In the type parameter, you can specify the type of matrix operation by passing one of the following keywords:
If you do not pass a type parameter, by default the effect is as if a value of matrix were specified.
In the values parameter, you pass numeric values based on the keyword passed in the type parameter:
If you do not pass a values parameter, the default behavior depends on the keyword passed in the type parameter:
Note: Under Windows, this command requires the prior disabling of Direct2D (see the Direct2D disabled constant in the description of the SET DATABASE PARAMETER command).
C_TEXT($Dom_filter;$Dom_node;$Dom_rect;$Dom_svg;$Txt_matrix)
SVG_SET_OPTIONS(SVG_Get_options?+5)
$Dom_svg:=SVG_New
$Dom_filter:=SVG_Define_filter($Dom_svg;"Matrix")
$Txt_matrix:=\
".33 .33 .33 0 0 "\
+".33 .33 .33 0 0 "\
+".33 .33 .33 0 0 "\
+".33 .33 .33 0 0"
$Dom_node:=SVG_Filter_ColorMatrix($Dom_filter;"SourceGraphic";"";"matrix";$Txt_matrix)
$Dom_filter:=SVG_Define_filter($Dom_svg;"Saturate")
$Dom_node:=SVG_Filter_ColorMatrix($Dom_filter;"SourceGraphic";"";"saturate";"1.5")
// another syntax for value
//$Dom_node:=SVG_Filter_ColorMatrix ($Dom_filter;"SourceGraphic";"";"saturate";String(1,5;"&xml"))
$Dom_filter:=SVG_Define_filter($Dom_svg;"HueRotate90")
$Dom_node:=SVG_Filter_ColorMatrix($Dom_filter;"SourceGraphic";"";"hueRotate";"90")
$Dom_filter:=SVG_Define_filter($Dom_svg;"LuminanceToAlpha")
$Dom_node:=SVG_Filter_ColorMatrix($Dom_filter;"SourceGraphic";"";"luminanceToAlpha")
$Dom_rect:=SVG_New_rect($Dom_svg;2;0;797;100;0;0;"none";"coral")
$Dom_rect:=SVG_New_rect($Dom_svg;2;100;797;100;0;0;"none";"coral")
SVG_SET_FILTER($Dom_rect;"Matrix")
$Dom_rect:=SVG_New_rect($Dom_svg;2;200;797;100;0;0;"none";"coral")
SVG_SET_FILTER($Dom_rect;"Saturate")
$Dom_rect:=SVG_New_rect($Dom_svg;2;300;797;100;0;0;"none";"coral")
SVG_SET_FILTER($Dom_rect;"HueRotate90")
$Dom_rect:=SVG_New_rect($Dom_svg;2;400;797;100;0;0;"none";"coral")
SVG_SET_FILTER($Dom_rect;"LuminanceToAlpha")
SVG_New_text($Dom_svg;"No filter";110;10;"Verdana";60;Bold;-1;"black")
SVG_New_text($Dom_svg;"Matrix";110;110;"Verdana";60;Bold;-1;"black")
SVG_New_text($Dom_svg;"Saturate";110;210;"Verdana";60;Bold;-1;"black")
SVG_New_text($Dom_svg;"HueRotate";110;310;"Verdana";60;Bold;-1;"black")
SVG_New_text($Dom_svg;"Luminance";110;410;"Verdana";60;Bold;-1;"black")
//View the result
SVGTool_SHOW_IN_VIEWER($Dom_svg)
//SVG_SAVE_AS_TEXT($Dom_svg;System folder(Desktop)+"export.svg")
//Don't forget to clear the memory
SVG_CLEAR($Dom_svg)
Product: 4D
Theme: Colors and Gradients
Created: 4D v14
4D SVG Component ( 4D v16)