Get the object's origin in pixels.

Syntax getOrigin()

Return Type Object


Get the object's origin in pixels. This interprets the set values and calculate the pixel values if the set values were one of the keywords. The origin point acts as a center point for rotation. It is also the coordinates where the x and y properties are drawn to. If origin.x is 10, the object's left edge will be drawn 10 px to the left of the x property.

Return Value

Object. Returns an object with properties x and y, which contain the pixel offset from the top left corner.


Example 1

We create a new core instance and a rectangle that we add to the canvas. Then we add an event handler that sets the origin of the object when clicked, which will make the rectangle adjust the position to reflect the changed origin. Then we get the pixel values of the new origin and output them. Note: The function output() used in this example is a custom function only for this example and is not part of oCanvas.

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

var rectangle = canvas.display.rectangle({
	x: 77,
	y: 270,
	width: 200,
	height: 100,
	fill: "#000"


rectangle.bind("click tap", function () {
	this.setOrigin("left", "center");

	var origin = this.getOrigin();
	output("origin: ", origin);