Permalink
Browse files

Add initial scaledScreenFrame etc.

  • Loading branch information...
koenbok committed Oct 8, 2014
1 parent 5afa23f commit 0f0a7feabdae9732fcf250efad95737a5c7901aa
Showing with 47 additions and 14 deletions.
  1. +47 −14 framer/Layer.coffee
@@ -271,20 +271,6 @@ class exports.Layer extends BaseClass
else
@frame = Utils.convertPoint(frame, null, @superLayer)
screenScaleX: ->
if @superLayer
return @superLayer.screenScaleX()
else if @_context._parentLayer
return @_context._parentLayer.screenScaleX()
return @scale * @scaleX
screenScaleY: ->
if @superLayer
return @superLayer.screenScaleY()
else if @_context._parentLayer
return @_context._parentLayer.screenScaleY()
return @scale * @scaleY
contentFrame: ->
Utils.frameMerge(_.pluck(@subLayers, "frame"))
@@ -323,6 +309,53 @@ class exports.Layer extends BaseClass
@y = parseInt @y
##############################################################
# SCREEN GEOMETRY
# TODO: Account for rotation
# TODO: I don't think this is correct yet because you have to account
# for scale+origin and rotation+origin each step in the layer hierarchy.
_superOrParentLayer: ->
if @superLayer
return @superLayer
if @_context._parentLayer
return @_context._parentLayer
screenOriginX = ->
if @_superOrParentLayer()
return @_superOrParentLayer().screenOriginX()
return @originX
screenOriginY = ->
if @_superOrParentLayer()
return @_superOrParentLayer().screenOriginY()
return @originY
screenScaleX: ->
if @_superOrParentLayer()
return @_superOrParentLayer().screenScaleX()
return @scale * @scaleX
screenScaleY: ->
if @_superOrParentLayer()
return @_superOrParentLayer().screenScaleY()
return @scale * @scaleY
screenRotationX: ->
screenRotationY: ->
screenRotationZ: ->
scaledScreenFrame = ->
frame = @screenFrame
frame.width *= @screenScaleX()
frame.height *= @screenScaleY()
frame.x += (@width - frame.width) * @screenOriginX
frame.y += (@height - frame.height) * @screenOriginY
return frame
##############################################################
# CSS

0 comments on commit 0f0a7fe

Please sign in to comment.