::pix::imgTop, Main, Index
CommandsTop, Main, Index
applyOpacity [::pix::img]Top, Main, Index
Multiplies alpha of the image by opacity.
Parameters
image | img::new |
opacity | double value |
Description
Image pix::img::applyOpacity multiplies the opacity of the image by the opacity parameter. The opacity parameter is a double between 0 and 1. 0 is fully transparent. 1 is fully opaque.
Any value inbetween is a mix of the two.
Return value
Nothing.
blur [::pix::img]Top, Main, Index
Applies Gaussian blur to the image given a radius.
Parameters
image | img::new |
radius | double value |
color | string color Optional, default transparent. |
Return value
Nothing.
ceil [::pix::img]Top, Main, Index
A value of 0 stays 0. Anything else turns into 255.
Parameters
image | img::new |
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::new |
Return value
A new img object.
destroy [::pix::img]Top, Main, Index
Destroy current image or all images if special word all is specified.
Parameters
value | img::new object or string |
Return value
Nothing.
diff [::pix::img]Top, Main, Index
Call this proc on the master image, passing the image to compare to the master image. The pix::img::diff method returns a dict with two elements.
Parameters
masterimage | img::new |
image | img::new |
Description
1. A cdouble representing the difference score between the two images. This score is 0 if the images are identical, and 1 if the images are completely different. The score is a measure of how different the two images are.
2. A new pix image representing the difference between the two images. The difference image is an image that has the same size as the two input images, and the pixels in this image represent the difference between the corresponding pixels in the two images. The difference image will have the same format as the input images.
Return value
A Tcl dictionary with keys (score, imgdiff).
draw [::pix::img]Top, Main, Index
Draws one image onto another using a matrix transform and color blending.
Parameters
image | img::new |
image2 | img::new |
matrix3 | list Optional, default mat3. |
blendMode | Enum value Optional, default NormalBlend. |
Return value
Nothing.
fill [::pix::img]Top, Main, Index
Fills the image with the color.
Parameters
image | img::new |
value | string color or paint object |
Description
This proc takes an image object and a color or paint object as arguments. It will fill the image with the specified color or paint object. The color or paint object can be specified as a string or as an object. If a string is specified, it should be a valid color string. If a paint object is specified, it should be a valid paint object. The paint object can be created using the pix::paint::new proc.
Return value
Nothing.
fillGradient [::pix::img]Top, Main, Index
Fills with the Paint gradient.
Parameters
image | img::new |
paint | paint::new |
Return value
Nothing.
fillPath [::pix::img]Top, Main, Index
Fills a path with a color or paint object.
Parameters
image | The img::new object to draw on. |
pathValue | A string containing a path or a path object. The path can be specified as a string like this: M 0 0 L 100 0 L 100 100 Z or as a path object created with the pix::path::new proc. |
paintValue | A string containing a color or a paint object. The color can be specified as a string like this: #FF0000 or as a paint object created with the pix::paint::new proc. |
matrix | A matrix to transform the path with. The matrix should be a 3x3 matrix specified as a list of 9 numbers. Optional, default mat3idendity. |
Return value
Nothing.
fillText [::pix::img]Top, Main, Index
Fills the image with the rendered text.
Parameters
image | img::new |
object | font::typeset or font::readFont object |
args | A Tcl dict (options described below) |
Description
There are two ways to use this proc:
1. 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.
2. With a font object and a text string:
$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. 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.
Parameters
image | img::new |
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::new |
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::new |
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::new |
coordinates | 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.
getPixel [::pix::img]Top, Main, Index
Gets a pixel at (x, y) or returns transparent black if outside of bounds.
Parameters
image | img::new |
coordinates | 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.
inside [::pix::img]Top, Main, Index
Returns true if (x, y) is inside the image, false otherwise.
Parameters
image | img::new |
coordinates | 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::new |
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::new |
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::new |
Return value
A Tcl boolean value.
isTransparent [::pix::img]Top, Main, Index
Checks if this image is fully transparent or not.
Parameters
image | img::new |
Return value
Returns true, false otherwise.
magnifyBy2 [::pix::img]Top, Main, Index
Scales image up by 2 ^ power.
Parameters
image | img::new |
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 img object.
minifyBy2 [::pix::img]Top, Main, Index
Scales the image down by an integer scale.
Parameters
image | img::new |
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 img object.
new [::pix::img]Top, Main, Index
Sets a new image.
Parameters
size | list width,height |
Return value
A new img object.
opaqueBounds [::pix::img]Top, Main, Index
Checks the bounds of opaque pixels.
Parameters
image | img::new |
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
Read image file.
Parameters
filePath | path file |
Description
This proc will attempt to read the image file and create a new image object from it.
Return value
A new img object.
resize [::pix::img]Top, Main, Index
Resize an image to a given height and width
Parameters
image | img::new |
size | list width,height |
Return value
Nothing.
rotate90 [::pix::img]Top, Main, Index
Rotates the image 90 degrees clockwise.
Parameters
image | img::new |
Return value
Nothing.
setPixel [::pix::img]Top, Main, Index
Sets a pixel at (x, y) or does nothing if outside of bounds.
Parameters
image | img::new |
coordinates | 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::new |
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::new 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::new |
coordinates | list x,y |
size | 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 img object.
superImage [::pix::img]Top, Main, Index
Either cuts a sub image or returns a super image with padded transparency.
Parameters
image | img::new |
coordinates | list x,y |
size | 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 img object.
writeFile [::pix::img]Top, Main, Index
Save image file.
Parameters
image | img::new |
filePath | string (*.png|*.bmp|*.qoi|*.ppm) |
Return value
Nothing.