Difference between revisions of "CanvasDrawPixel"
(Created page with "''New to Analytica 5 .1'' == CanvasDrawPixel( canvas, x, y, color'', blend'' ) == Draws a single pixel on «canvas» as «x», «y» in «color». When «color» has par...") |
(Var-->Local) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | [[Category:Image and canvas functions]] | ||
+ | {{ReleaseBar}} | ||
''New to [[Analytica 5 .1]]'' | ''New to [[Analytica 5 .1]]'' | ||
− | == CanvasDrawPixel( canvas, x, y, color'', blend'' ) == | + | == CanvasDrawPixel( canvas, x, y, color'', blend{{Release|5.2||, swapXY}}'' ) == |
Draws a single pixel on «canvas» as «x», «y» in «color». When «color» has partial transparency, the optional Boolean «blend» determines whether the transparency is mixed with the existing pixel at that location (<code>blend:true</code>) or whether the pixel is set directly to the partially transparent «color» directly (<code>blend:false</code>). «Blend» is false by default. | Draws a single pixel on «canvas» as «x», «y» in «color». When «color» has partial transparency, the optional Boolean «blend» determines whether the transparency is mixed with the existing pixel at that location (<code>blend:true</code>) or whether the pixel is set directly to the partially transparent «color» directly (<code>blend:false</code>). «Blend» is false by default. | ||
You can set all the pixels of an image at once (and those images might be computed) by supplying arrays to «x», «y» and «color» with common indexes. | You can set all the pixels of an image at once (and those images might be computed) by supplying arrays to «x», «y» and «color» with common indexes. | ||
+ | |||
+ | {{Release|5.2||The optional «swapXY» parameter swaps the «x» and «y» parameters.}} | ||
== Examples == | == Examples == | ||
The following expression creates a gray-scale version of an image, the result of variable <code>Img</code>. | The following expression creates a gray-scale version of an image, the result of variable <code>Img</code>. | ||
− | [[ | + | [[Local]] width := [[ImageInfo]](Img,'Width'); |
− | [[ | + | [[Local]] height := [[ImageInfo]](Img,'Height'); |
− | [[ | + | [[LocalIndex]] x := 1..width; |
− | [[ | + | [[LocalIndex]] y := 1..height; |
− | [[ | + | [[Local]] grayedColor := ColorToGrayScale( [[ImageInfo]](Img,'Color',x,y) ); |
| | ||
− | [[ | + | [[Local]] c := [[Canvas]]( width, height ); |
− | [[CanvasDrawPixel]]( c, x,y, | + | [[CanvasDrawPixel]]( c, x,y, grayedColor ); |
[[CanvasImage]](c) | [[CanvasImage]](c) | ||
Latest revision as of 00:14, 9 October 2021
Release: |
4.6 • 5.0 • 5.1 • 5.2 • 5.3 • 5.4 • 6.0 • 6.1 • 6.2 • 6.3 • 6.4 • 6.5 • 6.6 |
---|
New to Analytica 5 .1
CanvasDrawPixel( canvas, x, y, color, blend, swapXY )
Draws a single pixel on «canvas» as «x», «y» in «color». When «color» has partial transparency, the optional Boolean «blend» determines whether the transparency is mixed with the existing pixel at that location (blend:true
) or whether the pixel is set directly to the partially transparent «color» directly (blend:false
). «Blend» is false by default.
You can set all the pixels of an image at once (and those images might be computed) by supplying arrays to «x», «y» and «color» with common indexes.
The optional «swapXY» parameter swaps the «x» and «y» parameters.
Examples
The following expression creates a gray-scale version of an image, the result of variable Img
.
Local width := ImageInfo(Img,'Width'); Local height := ImageInfo(Img,'Height'); LocalIndex x := 1..width; LocalIndex y := 1..height; Local grayedColor := ColorToGrayScale( ImageInfo(Img,'Color',x,y) ); Local c := Canvas( width, height ); CanvasDrawPixel( c, x,y, grayedColor ); CanvasImage(c)
where ColorToGrayScale
is a User-Defined Function that converts a color integer to its gray scale equivalent (not shown here).
Enable comment auto-refresher