Created
August 12, 2015 16:27
-
-
Save ed-lea/2b079e4319eaacda53b7 to your computer and use it in GitHub Desktop.
modify a value passed in to the extended Layer class
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 characters
class Main extends Layer | |
constructor: (options={}) -> | |
# override Layer default | |
options.width ?= 200 | |
# introduce the scaling factor | |
# Using Nexus 5 @3x by default | |
options.finalScale ?= 3 | |
super options | |
resize: (n) -> | |
# returns "undefined" | |
print @finalScale | |
return n * @finalScale | |
@define "finalScale", | |
get: -> @_finalScale | |
set: (value) -> | |
@_finalScale = value | |
@define "width", | |
get: -> @_width | |
set: (value) -> | |
@_width = @resize(value) | |
m = new Main | |
# this should draw 1000 wide | |
width: 500 | |
# previewing in iPhone so @2x | |
finalScale: 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment