rotateTo()

Rotate the object to a specific angle.

Syntax rotateTo(angle)

Return Type displayObject

Description

Rotate the object to a specific angle.

Arguments

angle : Number
The angle in degrees the object will be rotated to. Positive value is clockwise. Negative value is counterclockwise.

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 rotates the rectangle when clicked.

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

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

canvas.addChild(rectangle);

rectangle.bind("click tap", function () {
	this.rotateTo(45);
	canvas.redraw();
});
Output