-
Notifications
You must be signed in to change notification settings - Fork 0
3b. Canvas configuration
Functions for changing the orientation of the canvas being rendered upon, as well as the underlying coordinate system.
Note: Functions which change the coordinate system do not change the orientation of the <canvas>
element.
Resizes the renderer canvas, including its CSS size, to a certain size, in pixels.
var renderer = BETA.getRenderer("myCanvas");
renderer.resize(1920, 1080);
Resizes the renderer canvas, including its CSS size, to a certain size, in pixels.
var renderer = BETA.getRenderer("myCanvas");
renderer.resizeByVector({x: 1920, y: 1080});
Resizes the renderer canvas, including its CSS size, to the size of the browser window.
var renderer = BETA.getRenderer("myCanvas");
renderer.resizeToMax();
Moves the origin of the coordinate system by a certain number of pixels.
var renderer = BETA.getRenderer("myCanvas");
renderer.translate(-200, 100);
Moves the origin of the coordinate system by a certain number of pixels.
var renderer = BETA.getRenderer("myCanvas");
renderer.translateByVector({x: -200, y: 100});
Scales the coordinate system axes by a factor each.
var renderer = BETA.getRenderer("myCanvas");
renderer.scale(2, 1.5);
Scales the coordinate system axes by a factor each.
var renderer = BETA.getRenderer("myCanvas");
renderer.scaleByVector({x: 2, y: 1.5});
Rotates the coordinate system around the origin by an angle in degrees.
var renderer = BETA.getRenderer("myCanvas");
renderer.rotate(90);
Rotates the coordinate system around the origin by an angle in radians.
var renderer = BETA.getRenderer("myCanvas");
renderer.rotateRad(Math.PI/2);
Saves the orientation of the current coordinate system, and pushes it onto a stack.
var renderer = BETA.getRenderer("myCanvas");
renderer.save(); //default state saved
renderer.rotate(90);
renderer.scale(2, 2);
Reverts the coordinate system to the previously saved orientation, and removes it from the stack.
var renderer = BETA.getRenderer("myCanvas");
renderer.save(); //default state saved
renderer.rotate(90);
renderer.scale(2, 2);
renderer.restore(); //reverted to default state