Skip to content

Commit

Permalink
Merge pull request #44 from kotlin-graphics/vec2i-times-float
Browse files Browse the repository at this point in the history
Vec2::times(Float)
  • Loading branch information
elect86 authored May 17, 2024
2 parents 80ab04b + ee7ffaa commit 5ac4fba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/kotlin/glm_/vec2/Vec2i.kt
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class Vec2i(@JvmField var ofs: Int, @JvmField var array: IntArray) : Vec2t<Int>,


infix operator fun times(b: Int) = times(Vec2i(), this, b, b)
infix operator fun times(b: Float) = times(Vec2i(), this, b, b)
infix operator fun times(b: Vec2i) = times(Vec2i(), this, b.x, b.y)

@JvmOverloads
Expand Down Expand Up @@ -350,6 +351,7 @@ class Vec2i(@JvmField var ofs: Int, @JvmField var array: IntArray) : Vec2t<Int>,

infix operator fun times(b: Number) = times(Vec2i(), this, b.i, b.i)
infix operator fun times(b: Vec2t<out Number>) = times(Vec2i(), this, b._x.i, b._y.i)
infix operator fun times(b: Vec2) = times(Vec2i(), this, b.x, b.y)

@JvmOverloads
fun times(bX: Number, bY: Number, res: Vec2i = Vec2i()) = times(res, this, bX.i, bY.i)
Expand Down
8 changes: 7 additions & 1 deletion src/main/kotlin/glm_/vec2/operators/opVec2i.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ interface opVec2i {
return res
}

fun times(res: Vec2i, a: Vec2i, bX: Float, bY: Float): Vec2i {
res.x = (a.x * bX).toInt()
res.y = (a.y * bY).toInt()
return res
}

fun div(res: Vec2i, a: Vec2i, bX: Int, bY: Int): Vec2i {
res.x = a.x / bX
res.y = a.y / bY
Expand Down Expand Up @@ -149,4 +155,4 @@ infix fun Number.divAssign(b: Vec2i) = div(b, this.i, this.i, b)

infix operator fun Number.rem(b: Vec2i) = rem(Vec2i(), this.i, this.i, b)
fun Number.rem(b: Vec2i, res: Vec2i) = rem(res, b, this.i, this.i)
infix fun Number.remAssign(b: Vec2i) = rem(b, this.i, this.i, b)
infix fun Number.remAssign(b: Vec2i) = rem(b, this.i, this.i, b)

0 comments on commit 5ac4fba

Please sign in to comment.