Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ private fun oriented(contours: List<FloatArray>, sign: Float): List<FloatArray>

// Twice the signed area
private fun area(c: FloatArray): Float {
var sum = 0f
var sum = 0.0
for (k in c.indices step 2) {
val j = (k + 2) % c.size
sum += c[k] * c[j + 1] - c[j] * c[k + 1]
sum += c[k].toDouble() * c[j + 1] - c[j].toDouble() * c[k + 1]
}
return sum
return sum.toFloat()
}

private fun convex(contours: List<FloatArray>): FloatArray? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,19 @@ class PolyPathOpsTest {
assertEquals(listOf(true, false, false), clipped.hits(7f, 7f, 12f, 12f, 2f, 2f))
}

@Test
fun intersectKeepsTinyBoxFarFromOrigin() {
val box = rect(1299.995f, 305.995f, 1300.005f, 306.005f)
assertFalse(op(rect(1100f, 286f, 1500f, 326f), box, PathOperation.Intersect).isEmpty)
assertTrue(op(rect(1100f, 286f, 1290f, 326f), box, PathOperation.Intersect).isEmpty)
}

@Test
fun intersectKeepsStretchedTriangle() {
val triangle = Path().apply { moveTo(-1e8f, -1e8f); lineTo(0f, 0f); lineTo(0f, 1f); close() }
assertFalse(op(triangle, triangle, PathOperation.Intersect).isEmpty)
}

@Test
fun nonUniformRoundedBorderRenders() {
val rec = FrameRecomposer(Dispatchers.Unconfined) {}
Expand Down