Skip to content

Instantly share code, notes, and snippets.

@ecoopnet
Created July 30, 2020 11:55
Show Gist options
  • Save ecoopnet/409b543b138036cda29e963aa10c3a23 to your computer and use it in GitHub Desktop.
Save ecoopnet/409b543b138036cda29e963aa10c3a23 to your computer and use it in GitHub Desktop.
Android Kotlin Graphics Utility.
// python numpy の処理をRectに適用できても面白いかも。
// TODO:
// fun RectF().toInt(): Rect
// fun Rect().toFloat(): RectF
// fun Rect.scaleCenter(scaleX: Float, scaleY: Float): RectF
// fun Rect.scaleCenter(scaleXY: Float): RectF
/// Scale X and Y separately.
fun Rect.scale(scaleX: Float, scaleY): RectF
= Rect(
left * scaleX,
top * scaleY,
right * scaleX,
bottom * scaleY
)
// Scale with same scale factor.
fun Rect.scale(scaleXY: Float): RectF
= scale(scaleXY, scaleXY)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment