public function getXY($canvasWidth, $canvasHeight, $imageWidth, $imageHeight){
        if ( self::TOP_LEFT === $this->position) {
            $x = 0;
            $y = 0;
        } else if ( self::TOP_CENTER === $this->position) {
            $x = (int)round(($canvasWidth / 2) - ($imageWidth / 2));
            $y = 0;
        } else if ( self::TOP_RIGHT === $this->position) {
            $x = $canvasWidth - $imageWidth;
            $y = 0;
        } else if ( self::CENTER_LEFT === $this->position) {
            $x = 0;
            $y = (int)round(($canvasHeight / 2) - ($imageHeight / 2));
        } else if ( self::CENTER_RIGHT === $this->position) {
            $x = $canvasWidth - $imageWidth;
            $y = (int)round(($canvasHeight / 2) - ($imageHeight / 2));
        } else if ( self::BOTTOM_LEFT === $this->position) {
            $x = 0;
            $y = $canvasHeight - $imageHeight;
        } else if ( self::BOTTOM_CENTER === $this->position) {
            $x = (int)round(($canvasWidth / 2) - ($imageWidth / 2));
            $y = $canvasHeight - $imageHeight;
        } else if ( self::BOTTOM_RIGHT === $this->position) {
            $x = $canvasWidth - $imageWidth;
            $y = $canvasHeight - $imageHeight;
        } else if ( self::CENTER === $this->position) {
            $x = (int)round(($canvasWidth / 2) - ($imageWidth / 2));
            $y = (int)round(($canvasHeight / 2) - ($imageHeight / 2));
        } else {
            throw new \Exception( sprintf( 'Invalid position "%s".', $this->position ) );
        }

        return array(
            $x + $this->offsetX,
            $y + $this->offsetY
        );
    }
public function getXY($canvasWidth, $canvasHeight, $imageWidth, $imageHeight){
        if ( self::TOP_LEFT === $this->position) {
            $x = 0;
            $y = 0;
        } else if ( self::TOP_CENTER === $this->position) {
            $x = (int)round(($canvasWidth / 2) - ($imageWidth / 2));
            $y = 0;
        } else if ( self::TOP_RIGHT === $this->position) {
            $x = $canvasWidth - $imageWidth;
            $y = 0;
        } else if ( self::CENTER_LEFT === $this->position) {
            $x = 0;
            $y = (int)round(($canvasHeight / 2) - ($imageHeight / 2));
        } else if ( self::CENTER_RIGHT === $this->position) {
            $x = $canvasWidth - $imageWidth;
            $y = (int)round(($canvasHeight / 2) - ($imageHeight / 2));
        } else if ( self::BOTTOM_LEFT === $this->position) {
            $x = 0;
            $y = $canvasHeight - $imageHeight;
        } else if ( self::BOTTOM_CENTER === $this->position) {
            $x = (int)round(($canvasWidth / 2) - ($imageWidth / 2));
            $y = $canvasHeight - $imageHeight;
        } else if ( self::BOTTOM_RIGHT === $this->position) {
            $x = $canvasWidth - $imageWidth;
            $y = $canvasHeight - $imageHeight;
        } else if ( self::CENTER === $this->position) {
            $x = (int)round(($canvasWidth / 2) - ($imageWidth / 2));
            $y = (int)round(($canvasHeight / 2) - ($imageHeight / 2));
        } else {
            throw new \Exception( sprintf( 'Invalid position "%s".', $this->position ) );
        }

        return array(
            $x + $this->offsetX,
            $y + $this->offsetY
        );
    }
public function getXY ( $ canvasWidth , $ canvasHeight , $ imageWidth , $ imageHeight ) { if ( self :: TOP_LEFT === $ this -> position ) { $ x = 0 ; $ y = 0 ; } else if ( self :: TOP_CENTER === $ this -> position ) { $ x = ( int ) round ( ( $ canvasWidth / 2 ) - ( $ imageWidth / 2 ) ) ; $ y = 0 ; } else if ( self :: TOP_RIGHT === $ this -> position ) { $ x = $ canvasWidth - $ imageWidth ; $ y = 0 ; } else if ( self :: CENTER_LEFT === $ this -> position ) { $ x = 0 ; $ y = ( int ) round ( ( $ canvasHeight / 2 ) - ( $ imageHeight / 2 ) ) ; } else if ( self :: CENTER_RIGHT === $ this -> position ) { $ x = $ canvasWidth - $ imageWidth ; $ y = ( int ) round ( ( $ canvasHeight / 2 ) - ( $ imageHeight / 2 ) ) ; } else if ( self :: BOTTOM_LEFT === $ this -> position ) { $ x = 0 ; $ y = $ canvasHeight - $ imageHeight ; } else if ( self :: BOTTOM_CENTER === $ this -> position ) { $ x = ( int ) round ( ( $ canvasWidth / 2 ) - ( $ imageWidth / 2 ) ) ; $ y = $ canvasHeight - $ imageHeight ; } else if ( self :: BOTTOM_RIGHT === $ this -> position ) { $ x = $ canvasWidth - $ imageWidth ; $ y = $ canvasHeight - $ imageHeight ; } else if ( self :: CENTER === $ this -> position ) { $ x = ( int ) round ( ( $ canvasWidth / 2 ) - ( $ imageWidth / 2 ) ) ; $ y = ( int ) round ( ( $ canvasHeight / 2 ) - ( $ imageHeight / 2 ) ) ; } else { throw new \ Exception ( sprintf ( 'Invalid position "%s".' , $ this -> position ) ) ; } return array ( $ x + $ this -> offsetX , $ y + $ this -> offsetY ) ; }
Translate the textual position + offsets into x,y values.

@param int $canvasWidth Width of canvas.
@param int $canvasHeight Height of canvas.
@param int $imageWidth Width of image/object added.
@param int $imageHeight Height of image/object added.

@return array Array of X and Y coordinates: array($x, $y).
@throws \Exception When invalid position.
Translate the textual position + offsets into x y values .