Skip to content

Commit

Permalink
Clarify drawing logic with kotlin stlib functions.
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbutcher committed Jul 10, 2017
1 parent a64a458 commit 7922b72
Showing 1 changed file with 7 additions and 6 deletions.
Expand Up @@ -159,15 +159,16 @@ class AdaptiveIconView(
}

private fun transformLayer(layer: Paint, dx: Float, dy: Float, layerScale: Float) {
val shader = layer.shader as BitmapShader
shader.getLocalMatrix(tempMatrix)
tempMatrix.setScale(layerScale, layerScale, layerCenter, layerCenter)
tempMatrix.postTranslate(dx - viewportOffset, dy - viewportOffset)
shader.setLocalMatrix(tempMatrix)
with(layer.shader as BitmapShader) {
getLocalMatrix(tempMatrix)
tempMatrix.setScale(layerScale, layerScale, layerCenter, layerCenter)
tempMatrix.postTranslate(dx - viewportOffset, dy - viewportOffset)
setLocalMatrix(tempMatrix)
}
}

private fun velocityToDisplacement(velocity: Float): Float {
val clampedVelocity = Math.min(Math.max(velocity, -1000f), 1000f)
val clampedVelocity = velocity.coerceIn(-1000f, 1000f)
return iconSize * clampedVelocity / -1000f
}

Expand Down

0 comments on commit 7922b72

Please sign in to comment.