Classes


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

Class Summary
Constructor Attributes Constructor Name and Description
 
MaxCanvas(Jsui)
Creates an MGraphics context.
Field Summary
Field Attributes Field Name and Description
CanvasRenderingContext2D
rendering context
Method Summary
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
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"
 

©2012-2013
Max MSP Documentation copied to JsDoc by Tim Schenk SEO Frelancer Berlin. Some examples are by him. Some descriptions of classes, interfaces, properties, methods or events are by him. Until now, most of it is a copy. Published with permission of Cycling '74. This document might be wrong or incomplete. All informations without any warranty. All trademarks are the property of their respective owners. Documentation generated by JsDoc Toolkit on 2013-3-2