Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface Rect {
- var x: Float
- var y: Float
- var width: Float
- var height: Float
- }
- class UIRect: Rect {
- override var x: Float = 0f
- override var y: Float = 0f
- override var width: Float = 1f
- override var height: Float = 1f
- operator fun getValue(rect: Rect, property: KProperty<*>): Rect {
- x = rect.x
- y = rect.y
- width = rect.width
- height = rect.height
- return this
- }
- }
- class ScalableUIRect(
- private val scaleBehavior: ScalableRectBehavior
- ): Rect by UIRect() {
- private val cachedRect: Rect by UIRect()
- fun getScaledRect(viewWidth: Float, viewHeight: Float, scale: Float): Rect {
- return scaleBehavior.scale(cachedRect, viewWidth, viewHeight, scale)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement