diff --git a/build.gradle b/build.gradle index 5b66914..036fb21 100644 --- a/build.gradle +++ b/build.gradle @@ -18,7 +18,7 @@ buildscript { apply plugin: 'forge' apply plugin: 'scala' -version = "0.9.1" +version = "0.9.2" if (project.hasProperty('buildnum')) { project.version = project.version + '.' + project.buildnum diff --git a/src/net/bdew/lib/gui/Point.scala b/src/net/bdew/lib/gui/Point.scala index 5f10034..54ac81e 100644 --- a/src/net/bdew/lib/gui/Point.scala +++ b/src/net/bdew/lib/gui/Point.scala @@ -14,3 +14,12 @@ class Point(val x: Int, val y: Int) { def +(that: Point) = new Point(this.x + that.x, this.y + that.y) def -(that: Point) = new Point(this.x - that.x, this.y - that.y) } + +object Point { + + import language.implicitConversions + + implicit def awt2point(p: java.awt.Point): Point = new Point(p.x, p.y) + implicit def point2awt(p: Point): java.awt.Point = new java.awt.Point(p.x, p.y) + implicit def tuple2point(p: (Int, Int)): Point = new Point(p._1, p._2) +} diff --git a/src/net/bdew/lib/gui/Rect.scala b/src/net/bdew/lib/gui/Rect.scala index 93f2526..f914e30 100644 --- a/src/net/bdew/lib/gui/Rect.scala +++ b/src/net/bdew/lib/gui/Rect.scala @@ -13,4 +13,6 @@ class Rect(val x: Int, val y: Int, val w: Int, val h: Int) { def this(p: Point, w: Int, h: Int) = this(p.x, p.y, w, h) def contains(p: Point) = p.x >= x && p.y >= y && p.x <= x + w && p.y <= y + h def origin = new Point(x, y) + def +(p: Point) = new Rect(origin + p, w, h) + def -(p: Point) = new Rect(origin - p, w, h) }