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.
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. |
element |
A String refering to an element of the SVG. If this argument is provided, image will only include this element of the SVG. |
// NOT IMPLEMENTED YET 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. |
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.
close 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. |
sets the receiver as the current graphic context. So you can use Pen to draw inside of it.
restore the graphic context state. the receiver is not anymore the current graphic context.
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
.
see ImageFilter for more info
apply an array of ImageFilter to the image. this should be considered as an in place operation, meaning the Image is altered after it.
filters |
a ImageFilter or an array of ImageFilter to be applied |
crop |
the crop region to finally use. This may be required for extending bounds since some ImageFilter / CoreImageFilters require to set a wider region (to be applied correctly) or may create a huge image. Setting crop to nil sets no crop region. In case the current maximum size of a filtered Image is 4096 / 4096. Any larger size will be clipped. by default crop is constrained to the receiver bounds. |
region |
NOTE: supported only in macOS 10.5 and later.
option to constrain the filter to a specific region IN the Image. |
returns a new Image, copy of the receiver filtered with an array of ImageFilter. arguments are the same as -applyFilters (except for region).
filters is the instance variable that holds the array of ImageFilter attached to the receiver. This is a convenient for applying filters out place and changing the ImageFilter's attributes. see -addFilter, -removeFilter
see ImageFilter for an example on how to use the filters array.
you can also attach filters to the receiver for real-time changing operations. In this case the receiver will create a cache before each rendering to maintain his previous state, and allowing you to use filters without applying them in place. The cache is managed directly by the receiver. you can add several filters to the receiver, the first filter in the array is the first applied in the rendering chain.
see ImageFilter for an example on how to use addFilter.
filter |
a ImageFilter to apply before rendering of the image |
see ImageFilter for an example on how to use removeFilter.
filter |
the ImageFilter to remove from the rendering chain. |
if -filters is not zero sized, this method will apply all those filters in place. if the image is accelerated this method force a bitmap representation of the receiver.
invert the receiver
crop the receiver
aRect |
the cropping region |
see ImageKernel for examples and more info.
you can now use a Image as a valid view background. 16 drawing modes are defined to behave differently.
1 | fixed to left, fixed to top |
2 | horizontally tile, fixed to top |
3 | fixed to right, fixed to top |
4 | fixed to left, vertically tile |
5 | horizontally tile, vertically tile |
6 | fixed to right, vertically tile |
7 | fixed to left, fixed to bottom |
8 | horizontally tile, fixed to bottom |
9 | fixed to right, fixed to bottom |
10 | fit |
11 | center, center (scale) |
12 | center , fixed to top |
13 | center , fixed to bottom |
14 | fixed to left, center |
15 | fixed to right, center |
16 | center, center (no scale) |
tileMode - the mode to use. by default fixed to left, fixed to top
alpha - opacity 0 < x < 1
fromRect - the portion of the image to use. by default use the full image.