Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit debcfb1

Browse files
committed
Sync from next
1 parent f2f4e98 commit debcfb1

File tree

11 files changed

+50
-13
lines changed

11 files changed

+50
-13
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ group=com.soywiz.korlibs.korma
99
version=2.0.0-SNAPSHOT
1010

1111
# korlibs
12-
kdsVersion=2.2.0
12+
kdsVersion=2.2.1
1313

1414
# bintray location
1515
project.bintray.org=korlibs

gradle/wrapper/gradle-wrapper.jar

333 Bytes
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

gradlew

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ case "`uname`" in
7272
Darwin* )
7373
darwin=true
7474
;;
75-
MINGW* )
75+
MSYS* | MINGW* )
7676
msys=true
7777
;;
7878
NONSTOP* )

korma/src/commonMain/kotlin/com/soywiz/korma/geom/Matrix.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ data class Matrix(
2525
Matrix(a.toDouble(), b.toDouble(), c.toDouble(), d.toDouble(), tx.toDouble(), ty.toDouble())
2626

2727
operator fun invoke(m: Matrix, out: Matrix = Matrix()): Matrix = out.copyFrom(m)
28+
29+
fun transformXf(a: Float, b: Float, c: Float, d: Float, tx: Float, ty: Float, px: Float, py: Float): Float = a * px + c * py + tx
30+
fun transformYf(a: Float, b: Float, c: Float, d: Float, tx: Float, ty: Float, px: Float, py: Float): Float = d * py + b * px + ty
2831
}
2932

3033
var af: Float
@@ -73,13 +76,15 @@ data class Matrix(
7376
}
7477
}
7578

76-
fun setTo(a: Double, b: Double, c: Double, d: Double, tx: Double, ty: Double): Matrix = this.apply {
79+
fun setTo(a: Double, b: Double, c: Double, d: Double, tx: Double, ty: Double): Matrix {
7780
this.a = a
7881
this.b = b
7982
this.c = c
8083
this.d = d
8184
this.tx = tx
8285
this.ty = ty
86+
return this
87+
8388
}
8489
fun setTo(a: Float, b: Float, c: Float, d: Float, tx: Float, ty: Float): Matrix = setTo(a.toDouble(), b.toDouble(), c.toDouble(), d.toDouble(), tx.toDouble(), ty.toDouble())
8590
fun setTo(a: Int, b: Int, c: Int, d: Int, tx: Int, ty: Int): Matrix = setTo(a.toDouble(), b.toDouble(), c.toDouble(), d.toDouble(), tx.toDouble(), ty.toDouble())
@@ -191,6 +196,7 @@ data class Matrix(
191196
fun deltaTransformY(x: Double, y: Double): Double = (x * b) + (y * d)
192197

193198
fun identity() = setTo(1.0, 0.0, 0.0, 1.0, 0.0, 0.0)
199+
fun setToNan() = setTo(Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN, Double.NaN)
194200

195201
fun isIdentity() = getType() == Type.IDENTITY
196202

@@ -332,8 +338,6 @@ data class Matrix(
332338
rectangle.height = ceil((if (y1 > y3) y1 else y3) - rectangle.y)
333339
}
334340

335-
336-
337341
fun copyFromArray(value: FloatArray, offset: Int = 0): Matrix = setTo(
338342
value[offset + 0], value[offset + 1], value[offset + 2],
339343
value[offset + 3], value[offset + 4], value[offset + 5]

korma/src/commonMain/kotlin/com/soywiz/korma/geom/triangle/Triangle.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ fun Triangle.edgeIndex(p1: IPoint, p2: IPoint): Int {
207207
return -1
208208
}
209209

210-
class TriangleList(val points: PointArrayList, val indices: IntArray, val numTriangles: Int = indices.size / 3) : Iterable<Triangle> {
210+
class TriangleList(val points: PointArrayList, val indices: ShortArray, val numTriangles: Int = indices.size / 3) : Iterable<Triangle> {
211211
val numIndices get() = numTriangles * 3
212212
val pointCount get() = points.size
213213

@@ -224,9 +224,9 @@ class TriangleList(val points: PointArrayList, val indices: IntArray, val numTri
224224
}
225225

226226
fun getTriangle(index: Int, out: MutableTriangle = MutableTriangle()): MutableTriangle {
227-
points.getPoint(indices[index * 3 + 0], out.p0)
228-
points.getPoint(indices[index * 3 + 1], out.p1)
229-
points.getPoint(indices[index * 3 + 2], out.p2)
227+
points.getPoint(indices[index * 3 + 0].toInt() and 0xFFFF, out.p0)
228+
points.getPoint(indices[index * 3 + 1].toInt() and 0xFFFF, out.p1)
229+
points.getPoint(indices[index * 3 + 2].toInt() and 0xFFFF, out.p2)
230230
return out
231231
}
232232

korma/src/commonMain/kotlin/com/soywiz/korma/interpolation/Interpolation.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.soywiz.korma.interpolation
22

3+
import com.soywiz.kds.*
4+
35
interface Interpolable<T> {
46
fun interpolateWith(ratio: Double, other: T): T
57
}
@@ -12,5 +14,5 @@ fun Double.interpolate(l: Float, r: Float): Float = (l + (r - l) * this).toFloat
1214
fun Double.interpolate(l: Double, r: Double): Double = (l + (r - l) * this)
1315
fun Double.interpolate(l: Int, r: Int): Int = (l + (r - l) * this).toInt()
1416
fun Double.interpolate(l: Long, r: Long): Long = (l + (r - l) * this).toLong()
15-
fun <T> Double.interpolate(l: Interpolable<T>, r: Interpolable<T>): T = l.interpolateWith(this, r as T)
17+
fun <T> Double.interpolate(l: Interpolable<T>, r: Interpolable<T>): T = l.interpolateWith(this, r.fastCastTo<T>())
1618
fun <T : Interpolable<T>> Double.interpolate(l: T, r: T): T = l.interpolateWith(this, r)

korma/src/commonMain/kotlin/com/soywiz/korma/math/Math.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,19 @@ fun Long.prevMultipleOf(multiple: Long) = if (this.isMultipleOf(multiple)) this
6464

6565
fun Int.isMultipleOf(multiple: Int) = multiple == 0 || (this % multiple) == 0
6666
fun Long.isMultipleOf(multiple: Long) = multiple == 0L || (this % multiple) == 0L
67+
68+
fun min(a: Int, b: Int, c: Int) = min(min(a, b), c)
69+
fun min(a: Float, b: Float, c: Float) = min(min(a, b), c)
70+
fun min(a: Double, b: Double, c: Double) = min(min(a, b), c)
71+
72+
fun min(a: Int, b: Int, c: Int, d: Int) = min(min(min(a, b), c), d)
73+
fun min(a: Float, b: Float, c: Float, d: Float) = min(min(min(a, b), c), d)
74+
fun min(a: Double, b: Double, c: Double, d: Double) = min(min(min(a, b), c), d)
75+
76+
fun max(a: Int, b: Int, c: Int) = max(max(a, b), c)
77+
fun max(a: Float, b: Float, c: Float) = max(max(a, b), c)
78+
fun max(a: Double, b: Double, c: Double) = max(max(a, b), c)
79+
80+
fun max(a: Int, b: Int, c: Int, d: Int) = max(max(max(a, b), c), d)
81+
fun max(a: Float, b: Float, c: Float, d: Float) = max(max(max(a, b), c), d)
82+
fun max(a: Double, b: Double, c: Double, d: Double) = max(max(max(a, b), c), d)

korma/src/commonMain/kotlin/com/soywiz/korma/triangle/EarCutTriangulator.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ object EarCutTriangulator {
1515
floats[n * 2 + 1] = points.getY(n).toFloat()
1616
}
1717
val result = EarCut.earcut(floats, holeIndices, 2)
18-
return TriangleList(points, result.toIntArray())
18+
return TriangleList(points, result.toShortArray())
1919
}
2020
}
2121

korma/src/commonMain/kotlin/com/soywiz/korma/triangle/poly2tri/TriangulateExt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@ fun VectorPath.triangulateSafe(doClipper: Boolean = true): TriangleList {
3232
points.add(it.p1.x, it.p1.y)
3333
points.add(it.p2.x, it.p2.y)
3434
}
35-
return TriangleList(points, indices.toIntArray())
35+
return TriangleList(points, indices.toShortArray())
3636
}

0 commit comments

Comments
 (0)