beetlebug▾
/

image put

A command of a photo: puts colors or image data into the photo.

IMAGENAME put COLORS ?-to X Y?
IMAGENAME put COLOR -to X1 Y1 ?X2 Y2?
IMAGENAME put DATA ?-format FORMAT? ?-to X Y?

Description

COLORS is a list of rows, and each row is a list of colors. The first color goes at X Y, 0 0 by default. One COLOR with -to X1 Y1 X2 Y2 fills the rectangle from X1 Y1 to X2 Y2. The column X2 and the row Y2 are outside the rectangle. With only X1 Y1, the color fills one pixel.

A value that is not a list of colors is image data, as for -data, and it goes at X Y. A photo with no -width or -height grows to hold the new pixels.

Returns

An empty string.

Examples

% image create photo p -width 3 -height 2
> p put {{red green blue} {white black yellow}}
> p get 2 0
0 0 255

% image create photo p2
> p2 put #ff00ff -to 0 0 4 2
> list [image width p2] [image height p2] [p2 get 3 1]
4 2 {255 0 255}

Errors

% image create photo p3; p3 put red -at 0 0
bad option "-at": must be -format or -to
-errorcode NONE

% image create photo p4; p4 put {{red nocolor}}
can't parse color "nocolor"
-errorcode NONE

% image create photo p5; p5 put
wrong # args: should be "p5 put data ?-option value ...?"
-errorcode NONE

Facts

Capability
None.
Tcl release
Tcl 9.1 and 8.6.
Since
ztk 1.0.0-beta.1

See also