::pix::imgTop, Main, Index
CommandsTop, Main, Index
applyOpacity [::pix::img]Top, Main, Index
Multiplies the alpha channel of the entire image by a given factor.
Parameters
image | img |
opacity | factor between 0.0 (transparent) and 1.0 (opaque). |
Return value
Nothing.
blur [::pix::img]Top, Main, Index
Applies a Gaussian blur to the image.
Parameters
image | img |
radius | blur intensity (double) |
color | optional background color for the blur effect Optional, default "". |
Return value
Nothing.
ceil [::pix::img]Top, Main, Index
A value of 0 stays 0. Anything else turns into 255.
Parameters
image | img |
Description
The pix::img::ceil proc takes an image and replaces all pixels that are not fully transparent (i.e. have an alpha of 0) with a pixel that is fully opaque (i.e. has an alpha of 255). This is useful for creating masks from images.
Return value
Nothing.
copy [::pix::img]Top, Main, Index
This procedure creates a new image by copying the contents of the given image object.
Parameters
image | img |
Return value
A new handle img object.
destroy [::pix::img]Top, Main, Index
Destroy the img or all images if special word all is specified.
Parameters
value | img object or string |
Return value
Nothing.
diff [::pix::img]Top, Main, Index
Compares two images and calculates their difference.
Parameters
masterimage | The reference img |
image | The img to compare against the reference |
Return value
A Tcl dictionary containing the following keys:
| score | A value between 0 (identical) and 1 (completely different). |
| img | A new img object visualizing the differences. |
draw [::pix::img]Top, Main, Index
Draws a source image onto a destination image using an optional transformation matrix and blend mode.
Parameters
image1 | destination img |
image2 | source img |
matrix3 | A list of 9 values Optional, default identityMatrix. |
blendMode | Enum value Optional, default NormalBlend. |
Return value
Nothing.
drawCopies [::pix::img]Top, Main, Index
Draws a path at many positions: filled, then stroked, like one shape drawn after the other.
Parameters
image | img |
path | path the shape, around {0 0} |
coordinates | A flat list {x1 y1 x2 y2 ...} |
fillColor | string color |
strokeColor | string color |
options | A Tcl dict, the options of img::strokePath . Optional, default "". |
Description
The options are those of img::strokePath: strokeWidth (in path units, 0 to fill only), transform (the matrix of the whole drawing: the shapes take its linear part, the positions the whole matrix), lineCap, lineJoin, miterLimit, dashes and blendMode (Enum, optional:NormalBlend): how each copy combines with the image, e.g. SubtractMaskBlend erases the image under the copies (their colors are then not used).
The shape is rendered once for each quarter-pixel offset, then copied at every position (the nearest quarter pixel), in the order of the list.
Return value
Nothing.
fill [::pix::img]Top, Main, Index
Fills the entire image with a solid color or a paint pattern.
Parameters
image | img |
color | A color string or paint object |
Description
If a paint object is provided, it must be created via pix::paint::new.
Return value
Nothing.
fillGradient [::pix::img]Top, Main, Index
Fills with the Paint gradient.
Parameters
image | img |
paint | paint |
Return value
Nothing.
fillPath [::pix::img]Top, Main, Index
Fills a path with a color or paint object.
Parameters
image | The destination img object. |
pathValue | A path object or a SVG path string (e.g., "M 0 0 L 100 0..."). |
paintValue | A color string or a paint object. |
matrix | An optional 3x3 transformation matrix . Optional, default identityMatrix. |
Return value
Nothing.
fillText [::pix::img]Top, Main, Index
Fills the image with the rendered text.
Parameters
image | img |
object | font::typeset or font::readFont object |
args | A Tcl dict (options described below) |
Description
There are two ways to use this proc:
- With an font::typeset object:
$img arrangement {?matrix3 value}
This will render the arrangement onto the image. If the matrix3 optional argument is provided, it will be used to transform the arrangement before rendering.
- With a font object and a
textstring:
$img font text options
This will render the text string onto the image using the font object. The options dict can be used to specify the following:transform A list transform to apply to the text. bounds A list bounds to use for the text. hAlign A Enum horizontal alignment of the text. vAlign A Enum vertical alignment of the text.
In either case, the img object is the first argument, and the font::typeset or font::readFont object is the second argument.
Return value
Nothing.
flipHorizontal [::pix::img]Top, Main, Index
This method modifies the image in place, flipping it around the Y-axis.
Parameters
image | img |
Description
As a result, the left and right sides of the image are swapped. This operation is useful for creating mirror images or for certain graphical effects.
Return value
Nothing.
flipVertical [::pix::img]Top, Main, Index
This method modifies the image in place, flipping it around the X-axis.
Parameters
image | img |
Description
As a result, the top and bottom sides of the image are swapped. This operation is useful for creating mirror images or for certain graphical effects.
Return value
Nothing.
get [::pix::img]Top, Main, Index
Gets image size.
Parameters
image | img |
Return value
A Tcl dictionary with keys containing the width and the height of the img.
getColor [::pix::img]Top, Main, Index
Gets a color at {x y} or returns transparent black if outside of bounds.
Parameters
image | img |
coordinates | A list {x y} |
Return value
A Tcl dictionary with keys {r g b a} representing the red, green, blue, and alpha (opacity) values of the pixel color in Color object format (red (0-1), green (0-1), blue (0-1), alpha (0-1)).
getPixel [::pix::img]Top, Main, Index
Gets a pixel at {x y} or returns transparent black if outside of bounds.
Parameters
image | img |
coordinates | A list {x y} (x column of the pixel, y row of the pixel) |
Return value
A Tcl dictionary with keys {r g b a} representing the red, green, blue, and alpha (opacity) values of the pixel color in ColorRGBX (premultiplied).
getSize [::pix::img]Top, Main, Index
See img::get procedure.
inside [::pix::img]Top, Main, Index
Returns true if {x y} is inside the image, false otherwise.
Parameters
image | img |
coordinates | A list {x y} |
Return value
Returns true if {x y} is inside the image, false otherwise.
invert [::pix::img]Top, Main, Index
Inverts all of the colors and alpha.
Parameters
image | img |
Description
This will flip the image by changing the color and alpha of every pixel. The result will be a new image where every pixel is the exact opposite of the corresponding pixel in the original image.
For example, if the original image is entirely white, the resulting image will be entirely black. If the original image is entirely black, the resulting image will be entirely white. This is useful for things like getting the negative of an image, or creating a reverse version of an image.
Return value
Nothing.
isOneColor [::pix::img]Top, Main, Index
Checks if the entire image is the same color.
Parameters
image | img |
Return value
A Tcl boolean value.
isOpaque [::pix::img]Top, Main, Index
Checks if the entire image is opaque (alpha values are all 255).
Parameters
image | img |
Return value
A Tcl boolean value.
isTransparent [::pix::img]Top, Main, Index
Checks if this image is fully transparent or not.
Parameters
image | img |
Return value
Returns true, false otherwise.
magnifyBy2 [::pix::img]Top, Main, Index
Scales image up by 2 ^ power.
Parameters
image | img |
power | Integer value Optional, default 1. |
Description
If only one argument is given (i.e. the image object), just magnify by 2. This is a convenience for the user.
Return value
A new handle img object.
minifyBy2 [::pix::img]Top, Main, Index
Scales the image down by an integer scale.
Parameters
image | img |
power | Integer value Optional, default 1. |
Description
We were given an integer power as an argument, so we call img.minifyBy2() with that power. This will scale the image down by 2^power.
Return value
A new handle img object.
new [::pix::img]Top, Main, Index
Creates and returns a new image object.
Parameters
size | A list {width height} |
Return value
A new handle img object.
opaqueBounds [::pix::img]Top, Main, Index
Checks the bounds of opaque pixels.
Parameters
image | img |
Description
Some images have transparency around them, use this to find just the visible part of the image and then use subImage to cut it out. Returns zero rect if whole image is transparent, or just the size of the image if no edge is transparent.
Return value
Returns A Tcl dictionary with keys {x y w h}.
readImage [::pix::img]Top, Main, Index
Reads an image file from the disk and creates a new image object.
Parameters
filePath | full path to the image file (.png, .jpg, *.svg, etc.) |
Return value
A handle to the new img object.
resize [::pix::img]Top, Main, Index
Resize an image to a given height and width.
Parameters
image | img |
size | A list {width height} |
Return value
A new img handle.
rotate90 [::pix::img]Top, Main, Index
Rotates the image 90 degrees clockwise.
Parameters
image | img |
Return value
Nothing.
setColor [::pix::img]Top, Main, Index
See img::setPixel procedure.
setPixel [::pix::img]Top, Main, Index
Sets a pixel at {x y} or does nothing if outside of bounds.
Parameters
image | img |
coordinates | A list {x y} |
color | string color |
Return value
Nothing.
shadow [::pix::img]Top, Main, Index
Create a shadow of the image with the offset, spread and blur.
Parameters
image | img |
options | dict (offset, spread, blur, color) |
Return value
Nothing.
strokePath [::pix::img]Top, Main, Index
Strokes a path with a color or a paint object and optional stroke and line join options.
Parameters
image | The img object to draw on. |
value | A string path or a path object created with the pix::path::new Tcl proc. |
color | A string color or a paint object created with the pix::paint::new Tcl proc. |
options | A Tcl dict, see attributes below. |
Description
- A dictionary of options to customize the stroke. The options are:
strokeWidth The width of the stroke. transform The transformation matrix to apply to the path. lineCap The line cap style (Enum). miterLimit The miter limit for the line join. lineJoin The line join style (Enum). dashes The dashes to apply to the stroke.
Return value
Nothing.
strokeText [::pix::img]Top, Main, Index
This procedure is responsible for rendering text onto an image with various styling options.
Parameters
image | img. |
object | This can either be a 'arrangement' or a font object. |
text | If the object is a font object, this parameter is the text string that needs to be rendered on the image. |
options | Check out the description below. |
Description
- arroptions : (Optional) A Tcl dictionary that contains various attributes for styling the text stroke. These attributes include:
transform A list representing a transformation matrix to apply. strokeWidth A double value specifying the width of the stroke. lineCap An enumeration value describing the shape of the stroke's end caps. lineJoin An enumeration value for the shape of the corners in joined lines. miterLimit A double value that limits the length of the miter when lineJoin is set to 'MiterJoin'. dashes A list indicating the pattern for dashed lines. - fontoptions : (Optional) A Tcl dictionary that provides additional styling options specific to the font rendering process:
transform A list for a transformation matrix to apply to the text. bounds A list defining the bounding box for the text rendering region. hAlign An enumeration for horizontal alignment of the text. vAlign An enumeration for vertical alignment of the text.
Return value
Nothing.
subImage [::pix::img]Top, Main, Index
Gets a sub image from this image.
Parameters
image | img |
coordinates | A list {x y} |
size | A list {width height} |
Description
The subImage function extracts a portion of the original image starting at {x y} and spanning the width and height specified.
Return value
A new handle img object.
superImage [::pix::img]Top, Main, Index
Either cuts a sub image or returns a super image with padded transparency.
Parameters
image | img |
coordinates | A list {x y} |
size | A list {width height} |
Description
If the coordinates and size of the superImage are within the bounds of the original image, a sub image is cut from the original image.
If the coordinates and size of the superImage are outside the bounds of the original image, a super image is created with the original image centered and padded with transparency. The resulting super image is always the size specified in the arguments.
If the resulting super image is different from the original image, a new image is created. If the resulting super image is the same as the original image, the original image is returned.
Return value
A new handle img object.
toGrayScale [::pix::img]Top, Main, Index
Converts an image to grayscale.
Parameters
img | |
handleAlpha | Boolean value that indicates whether to handle the alpha channel . Optional, default true. |
Return value
nothing.
writeFile [::pix::img]Top, Main, Index
Save image file.
Parameters
image | img |
filePath | string (*.png|*.bmp|*.qoi|*.ppm) |
Return value
Nothing.