Image enables the drawing of images in the SuperCollider GUI.
Creates a new Image instance. "multiple" here stands for multiple arguments.
multiple |
Any of the following: |
height |
If multiple is a number, then this argument indicates the height of the new image. |
Creates a new Image instance filled with the specified color.
... args |
Multiple arguments. the last argument should be a valid Color |
Creates a new Image instance from the local file at path.
Creates a new Image instance from the local SVG file at path.
path |
A String containing the SVG file's path. |
size |
A Size. SVG contents will be drawn into an image of this size. If not provided, suggested size provided by SVG will be used. |
Creates a new Image instance from a valid image at the specified URL path.
Creates a new Image instance from another Image.
Creates a new Image from a portion of a Window. this can be used to capture either a window or a specific View.
window |
the Window object. |
rect |
optional. the constrained rect to capture inside the Window. By default, it is the window size. |
Close all the Image plot windows currently opened.
Convert a Color into a pixel datatype suitable for setting pixel data in the Image class.
A 32bit packed Integer in the RGBA format.
returns all the valid image formats as an Array
returns all the valid compositing operations you can use when drawing an Image as an Array
returns an Array of the different levels of interpolation you can specify when drawing an Image.
returns an Array of the different resize modes you can specify when changing the size of an Image.
Returns an array of all the Image plot windows currently opened.
returns or set the width of the receiver
returns or set the height of the receiver
set the size of the receiver
returns the bounds of the receiver.
deallocate the receiver. this method is useful if you want to manage and reclaim yourself resources. otherwise you do not need to call this method since each object is automatically garbage collected.
flag to tell or set if the receiver should update its bitmap representation to scale when a resize operation if performed
returns or set the url of the receiver. Returning only if any where supplied at creation, otherwise returns nil. Setting may be used for different purpose but try to supply a valid one since it is used for archiving the image as an object.
get or set the level of interpolation used when rendering the image - it has not effect when the Image is accelerated. see *interpolations for a valid range of values.
write the Image to a file.
path |
the location where to save it |
format |
(optional) format to use. see Image.formats for supported formats. If nil, it will get the format depending on the path extension. |
quality |
The quality factor must be in the range 0 to 100 or -1. Specify 0 to obtain small compressed files, 100 for large uncompressed files, and -1 (the default) to use the default settings. |
plots the image in a Window.
name |
the title of the Window. may be nil. |
bounds |
the bounds of the Window. may be nil. |
freeOnClose |
flag to tell if the Window should free the Image when closed. |
background |
additional background to apply to the Window. may be useful for artifacts due to alpha / compositing... |
showInfo |
shows pixel coordinates while the mouse is over the image's plot window. |
shortcut for drawing inside an image. equivalent to :
renders *correctly* a String inside an Image :) // to fix to have a compliant interface
render the image or a portion of it in the current graphic context.
point |
the Point where to draw it |
fromRect |
the portion of the Image to use |
operation |
the compositing operation to use. |
fraction |
the opacity to use, ranging from 0.0 (fully transparent) to 1.0 (fully opaque) |
render the image or a portion of it in a specified rectangle of the current graphic context. This may stretch the image depending on the destination rect.
rect |
the Rect where to draw it |
fromRect |
the portion of the Image to use |
operation |
the compositing operation to use. |
fraction |
the opacity to use, ranging from 0.0 (fully transparent) to 1.0 (fully opaque) |
tile the image or a portion of it in a specified rectangle of the current graphic context. This may stretch the image depending on the destination rect.
rect |
the Rect where to draw it |
fromRect |
the portion of the Image to use |
operation |
the compositing operation to use. NOTE: Compositing operations are currently disabled for tileInRect |
opacity |
the opacity to use, ranging from 0.0 (fully transparent) to 1.0 (fully opaque) |
fill a pixel located at x @ y.
rgbaInteger |
an 32 bit Integer containing color information packed as 8bit RGBA |
x |
the x position of the pixel in the image |
y |
the y position of the pixel in the image |
retrieve the pixel value at x @ y as a RGBA integer
fill the pixel located at x @ y with the specified color.
retrieve the pixel value at x @ y as a Color.
retrieve or set all the pixels of the receiver.
array |
an Int32Array of size receiver.width * receiver.height containing all pixel values as 32bit Integer |
load all the pixels of the receiver in an array. it is better and faster to call this function instead of -pixels if you plan to retrieve frequently the pixel data (since it won't allocate a new array everytime !)
array |
the array that will be filled. Should be an Int32Array of size receiver.width * receiver.height. |
region |
the targeted rectangular region. (nil by default, meaning full size) |
start |
the start index of the array. |
set the pixels in a specific portion of the receiver.
array |
an Int32Array of size rect.width * rect.height containing all pixel values as 32bit Integer |
region |
a rectangle defining the portion to update in the receiver. By default rect is nil, meaning full image size. |
start |
the array start index. |
Get/set pixel ratio of the image.
This does NOT affect the content of the image, only how it is interpreted when it is drawn onto a View or another Image. For example, in a high DPI context, the pixel ratio of a View might be 2. When drawing an image with a pixelRatio of 1, each pixel of the image will fill a 2x2 area of the View. If both the Image and the View had a pixel ratio of 2, each pixel would be 1:1 with pixels in the View.
By default, the pixelRatio of all Images is 1 - this ensures that an image will look the same when drawn on a normal or a high DPI view. Setting a custom (!= 1) pixelRatio should generally only be done to draw specially rendered high DPI images to a View that is known to be high DPI.
Note that when drawing to an Image using Pen, pixelRatio is accounted for - so, a line of width 1 will have a true width of 1px for an image where image.pixelRatio==1
, and a true width of 2px where image.pixelRatio==2
.