ASMR/src/main/kotlin/net/shadowfacts/cacao/geometry/Rect.kt

37 lines
751 B
Kotlin
Raw Normal View History

2019-06-22 19:02:17 +00:00
package net.shadowfacts.cacao.geometry
2019-06-21 20:22:23 +00:00
2019-06-22 14:59:18 +00:00
/**
2019-06-22 20:08:00 +00:00
* Helper class for defining rectangles. Provides helper values for calculating perpendicular components of a rectangle based on X/Y/W/H.
*
2019-06-22 14:59:18 +00:00
* @author shadowfacts
*/
data class Rect(val left: Double, val top: Double, val width: Double, val height: Double) {
2019-06-21 20:22:23 +00:00
constructor(origin: Point, size: Size): this(origin.x, origin.y, size.width, size.height)
2019-06-22 14:21:29 +00:00
val right: Double by lazy {
left + width
}
val bottom: Double by lazy {
top + height
}
val midX: Double by lazy {
left + width / 2
}
val midY: Double by lazy {
top + height / 2
}
val origin: Point by lazy {
Point(left, top)
}
val center: Point by lazy {
Point(midX, midY)
}
val size: Size by lazy {
Size(width, height)
}
2019-06-21 20:22:23 +00:00
}