Skip to content

Commit 5ac4fba

Browse files
authored
Merge pull request #44 from kotlin-graphics/vec2i-times-float
Vec2::times(Float)
2 parents 80ab04b + ee7ffaa commit 5ac4fba

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/kotlin/glm_/vec2/Vec2i.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ class Vec2i(@JvmField var ofs: Int, @JvmField var array: IntArray) : Vec2t<Int>,
252252

253253

254254
infix operator fun times(b: Int) = times(Vec2i(), this, b, b)
255+
infix operator fun times(b: Float) = times(Vec2i(), this, b, b)
255256
infix operator fun times(b: Vec2i) = times(Vec2i(), this, b.x, b.y)
256257

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

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

354356
@JvmOverloads
355357
fun times(bX: Number, bY: Number, res: Vec2i = Vec2i()) = times(res, this, bX.i, bY.i)

src/main/kotlin/glm_/vec2/operators/opVec2i.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ interface opVec2i {
3737
return res
3838
}
3939

40+
fun times(res: Vec2i, a: Vec2i, bX: Float, bY: Float): Vec2i {
41+
res.x = (a.x * bX).toInt()
42+
res.y = (a.y * bY).toInt()
43+
return res
44+
}
45+
4046
fun div(res: Vec2i, a: Vec2i, bX: Int, bY: Int): Vec2i {
4147
res.x = a.x / bX
4248
res.y = a.y / bY
@@ -149,4 +155,4 @@ infix fun Number.divAssign(b: Vec2i) = div(b, this.i, this.i, b)
149155

150156
infix operator fun Number.rem(b: Vec2i) = rem(Vec2i(), this.i, this.i, b)
151157
fun Number.rem(b: Vec2i, res: Vec2i) = rem(res, b, this.i, this.i)
152-
infix fun Number.remAssign(b: Vec2i) = rem(b, this.i, this.i, b)
158+
infix fun Number.remAssign(b: Vec2i) = rem(b, this.i, this.i, b)

0 commit comments

Comments
 (0)