Skip to content

Commit

Permalink
Added CSS percentage outputs
Browse files Browse the repository at this point in the history
For background-position when using background-size:cover
  • Loading branch information
jonom committed Sep 15, 2014
1 parent db14a42 commit 2600632
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions code/FocusPointImage.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,28 @@ public function BasicFocusArea() {
return 'focus-'.$horzFocus.'-'.$vertFocus;
}

/**
* Generate a percentage based description of x focus point for use in CSS.
* Range is 0% - 100%. Example x=.5 translates to 75%
* Use in templates with {$PercentageX}%
*
* @return int
*/
public function PercentageX() {
return round(($this->owner->FocusX + 1)*50);
}

/**
* Generate a percentage based description of y focus point for use in CSS.
* Range is 0% - 100%. Example y=-.5 translates to 75%
* Use in templates with {$PercentageY}%
*
* @return int
*/
public function PercentageY() {
return round(($this->owner->FocusY - 1)*-50);
}

/**
* Generate a resized copy of this image with the given width & height, cropping to maintain aspect ratio and focus point.
* Use in templates with $CroppedFocusedImage
Expand Down

0 comments on commit 2600632

Please sign in to comment.