Last modified: 2013-3-2
Class MaxCanvas
Canvas-Api for Max (can be found in MAX_PATH/Cycling '74/jsextensions/)
Copyright 2010 - Cycling '74
Silvio C. Haedrich ein.selbst@gmail.com
Defined in: CanvasExtension.js
| Constructor Attributes | Constructor Name and Description |
|---|---|
|
MaxCanvas(Jsui)
Creates an MGraphics context.
|
| Field Attributes | Field Name and Description |
|---|---|
| CanvasRenderingContext2D * |
rendering context
|
| Method Attributes | Method Name and Description |
|---|---|
| CanvasRenderingContext2D |
getContext(type)
Returns the rendering context.
|
Class Detail
MaxCanvas
(Jsui)
Creates an MGraphics context. Implements a jsui.onresize event handler
Defined in: CanvasExtension.js
function MaxCanvas(Jsui) {
if (!Jsui || !(Jsui instanceof js)) {
post("missing or wrong argument for MaxCanvas, call \"new MaxCanvas(this);\"\n");
return;
}
Jsui.mgraphics.init();
Jsui.mgraphics.relative_coords = 0;
Jsui.mgraphics.autofill = 0;
this.context = new CanvasRenderingContext2D(jsui);
var that = this;
Jsui.onresize = function(w, h){
that.context.aspect = w/h;
that.context.width = w;
that.context.height = h;
if (Jsui.onresizeCanvas)
Jsui.onresizeCanvas(w,h);
}
return this;
}
Defined in: CanvasExtension.js
- Example:
// see file canvas-examples.js in Max's examples folder var myCanvas = new MaxCanvas(this); var ctx = myCanvas.getContext('max-2d');
- Parameters:
- {jsui} Jsui
Field Detail
{CanvasRenderingContext2D *}
context
rendering context
- Example:
var ctx = new MaxCanvas(this).getContext("max-2d");
Method Detail
{CanvasRenderingContext2D}
getContext
(type)
Returns the rendering context.
MaxCanvas.prototype.getContext = function(type) {
if (type == 'max-2d')
return this.context;
post("context-type not supported, use 'max-2d'");
}
- Example:
var ctx = new MaxCanvas(this).getContext("max-2d");
- Parameters:
- {String} type
- only "max-2d"