scale()

Scale the object with the specified percentages.

Syntax scale(x, y)

Return Type displayObject

Description

Scale the object with the specified percentages. This does not affect the actual width/height properties of the display object, it only affects how it is drawn. So calling this method multiple times with the same values will give the same results.

Note: oCanvas does not currently handle events correctly on objects that have been scaled.

Arguments

x : Number
The x percentage, from 0 to 1. The value is 1 for normal size, and can not be 0.
y : Number
The y percentage, from 0 to 1. The value is 1 for normal size, and can not be 0.

Return Value

displayObject. Returns the display object itself.

Examples

Example 1

We create a new core instance and a rectangle that we add to the canvas. Then we add an event handler that scales the rectangle when clicked.

View Example
Code
var canvas = oCanvas.create({
	canvas: "#canvas",
	background: "#ccc"
});

var rectangle = canvas.display.rectangle({
	x: 177,
	y: 170,
	origin: { x: "center", y: "center" },
	width: 200,
	height: 100,
	fill: "#000"
});

canvas.addChild(rectangle);

rectangle.bind("click tap", function () {
	this.scale(1.5, 0.5);
	canvas.redraw();
});
Output