Compare commits

...
1 Commits
Author SHA1 Message Date
bdew 377fe3c27a Added helper stuff to Point and Rect 2013-12-12 18:16:57 +02:00
3 changed files with 12 additions and 1 deletions

No files matched your search

+1 -1
View File
@@ -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
+9
View File
@@ -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)
}
+2
View File
@@ -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)
}