class Image
Bitmap image object handle
You can use MGraphics.image_surface_draw() and MGraphics.set_source_surface() to draw using a bitmap Image. Create an Image either using a file in Max's search path, or from an existing MGraphics context.
Example
function paint() {
// Render a simple image
var im = new Image("icon.png");
mgraphics.image_surface_draw(im);
// Render from an offscreen mgraphics
var offscreen_ctx = new MGraphics(200, 200);
offscreen_ctx.rectangle(10, 10, 50, 50);
offscreen_ctx.set_source_rgba(1, 0, 0, 1);
offscreen_ctx.fill();
var im2 = new Image(offscreen_ctx);
mgraphics.image_surface_draw(im2);
}
Constructors
new Image(source: MGraphics | string);
Create a new bitmap image
Parameter | Type | Description |
---|---|---|
source | MGraphics | string | Filename in Max's search path, or an MGraphics context |
Properties
size [number, number] read-only
Get a the width and height of the image
Methods
flip
Flip the image
flip(horizontal: 0 | 1, vertical: 0 | 1);
Name | Type | Description |
---|---|---|
horizontal | 0 | 1 | |
vertical | 0 | 1 |