replace. Replacing color in the area specified by coordinates table

^image.replace(old color;new color)[coordinates table]
^image.replace(old color;new color)
 [3.4.1]

The method is used to replace one color with another within the area restricted by coordinates table. If the table is not specified, the color will be replaced in the whole image.

Example
$paint_nodes[^table::create{x   y
10   20
90   20
90   80
10   80
}]

$square[^image::
create(100;100;0x000000)]
^square.
line(0;0;100;100;0xFFFFFF)
^square.line(100;0;0;100;0xFFFFFF)

^square.replace(0x000000;0xFF00FF)[$paint_nodes]
$
response:body[^square.gif[]]

Browser will display a black square, crossed diagonally with white lines, with a pink rectangle within it. Since method replace tells to replace with pink only black color, the lines will remain white.



Copyright © 1997–2017 Art. Lebedev Studio | http://www.artlebedev.com Last updated: 25.02.2011