Skip to content
Permalink
Browse files

Added math operators to Size

  • Loading branch information...
darkfrog26 committed Jul 22, 2018
1 parent 756c7bd commit 4158b13c1f0d8c2ebf66c4d1294043ba43aa0e6a
Showing with 10 additions and 0 deletions.
  1. +10 −0 spatial/shared/src/main/scala/io/youi/spatial/Size.scala
@@ -6,6 +6,16 @@ sealed trait Size extends SpatialValue[Size] {
def width: Double
def height: Double

def *(d: Double): Size = Size(width * d, height * d)
def /(d: Double): Size = Size(width / d, height / d)
def +(d: Double): Size = Size(width + d, height + d)
def -(d: Double): Size = Size(width - d, height - d)

def *(that: Size): Size = Size(this.width * that.width, this.height * that.height)
def /(that: Size): Size = Size(this.width / that.width, this.height / that.height)
def +(that: Size): Size = Size(this.width + that.width, this.height + that.height)
def -(that: Size): Size = Size(this.width - that.width, this.height - that.height)

def set(width: Double, height: Double): Size
def set(that: Size): Size = set(that.width, that.height)
def duplicate(): Size

0 comments on commit 4158b13

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.