Last active
August 29, 2015 14:11
-
-
Save fatihacet/1ece4fc516b5dda8b9d7 to your computer and use it in GitHub Desktop.
Revisions
-
fatihacet revised this gist
Dec 20, 2014 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,6 +3,10 @@ class Box ###* Class for representing a box. A box is specified as a top, right, bottom and left. @constructor @param {Object} options Options object to hold top, right, bottom and left values. ### constructor: (options = {}) -> -
fatihacet created this gist
Dec 20, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,51 @@ class Box ###* Class for representing a box. A box is specified as a top, right, bottom and left. ### constructor: (options = {}) -> @top = options.top or 0 @right = options.right or 0 @bottom = options.bottom or 0 @left = options.left or 0 ###* Returns box width. @return {number} Box width. ### getWidth: -> return @right - @left ###* Returns box height. @return {number} Box height. ### getHeight: -> return @top - @bottom ###* Creates a copy of the box with the same dimensions. @return {Box} Cloned box. ### clone: -> return new Box { @top, @right, @bottom, @left } ###* Scales the box with given ratio. @param {!number} ratio Ratio to scale all dimensions. ### scale: (ratio) -> @top *= ratio @right *= ratio @top *= ratio @bottom *= ratio