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
|
|
|
|
*/
|
2019-06-21 23:02:08 +00:00
|
|
|
data class Rect(val left: Double, val top: Double, val width: Double, val height: Double) {
|
2019-06-21 20:22:23 +00:00
|
|
|
|
2019-06-23 03:03: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
|
|
|
|
|
|
|
}
|