Combined build: the centred ident (from arcade-channel-chaos)

This commit is contained in:
2026-11-09 01:07:48 +00:00
2 changed files with 78 additions and 6 deletions
@@ -104,8 +104,8 @@ internal class ChaosArt(density: Density, measurer: TextMeasurer) {
/** Where the screens sit in the frame: the centre x and top of each TV (Stage B frame 31). */
val tvX = floatArrayOf(960f, 560f, 1360f, 960f)
val tvTop = floatArrayOf(80f, 395f, 395f, 702f)
val chuteX = 960f
val chuteY = 500f
val chuteX = ChaosArtGeometry.CHUTE_X
val chuteY = ChaosArtGeometry.CHUTE_Y
// ---------- symbols, signals ----------
@@ -144,7 +144,7 @@ internal class ChaosArt(density: Density, measurer: TextMeasurer) {
drawCircle(col, r * 1.25f, c, alpha = .16f * alpha)
drawCircle(col, r, c, alpha = alpha)
drawCircle(Color.White, r * .3f, Offset(c.x - r * .3f, c.y - r * .35f), alpha = .25f * alpha)
symbol(k, Offset(c.x, c.y + r * .04f), r * .56f)
symbol(k, c, r * .56f)
if (bonus) drawCircle(Color.White, r * 1.16f, c, alpha = .8f * alpha, style = dashes)
}
}
@@ -256,13 +256,44 @@ internal class ChaosArt(density: Density, measurer: TextMeasurer) {
translate(c.x - t.size.width * k / 2, c.y - t.size.height * k / 2) { scale(k, k, Offset.Zero) { drawText(t, ChaosColours.Ink) } }
}
/** The reward: every screen on its own channel, and the little Orbit ident in the chute. */
/** The logo's drawn part (its image has a wide clear margin on the right), found once from its pixels. */
private var logoBox: IntArray? = null
private var logoFor: ImageBitmap? = null
/** The reward: every screen on its own channel, and the little Orbit ident centred on the chute's pad. */
fun DrawScope.ident(logo: ImageBitmap, t: Float, calm: Boolean) {
val c = Offset(chuteX, chuteY)
val grow = if (calm) 1f else (t / .6f).coerceIn(0f, 1f)
drawCircle(Color(0xFF081A3C), 140f, c)
drawCircle(ChaosColours.channel[0], 140f, c, alpha = .35f, style = Stroke(4f))
val w = 220f * (.6f + .4f * grow); val h = w * logo.height / logo.width.coerceAtLeast(1)
drawImage(logo, IntOffset.Zero, IntSize(logo.width, logo.height), IntOffset((c.x - w / 2).toInt(), (c.y - h / 2).toInt()), IntSize(w.toInt(), h.toInt()), alpha = .4f + .6f * grow)
if (logoFor !== logo) {
val px = IntArray(logo.width * logo.height); logo.readPixels(px)
logoBox = alphaBounds(px, logo.width, logo.height); logoFor = logo
}
val box = logoBox ?: return
// As identRect, worked out here so a frame of the reward makes no new arrays.
val w = 220f * (.6f + .4f * grow); val h = w * (box[3] - box[1]) / (box[2] - box[0])
drawImage(logo, IntOffset(box[0], box[1]), IntSize(box[2] - box[0], box[3] - box[1]), IntOffset(Math.round(c.x - w / 2), Math.round(c.y - h / 2)),
IntSize(Math.round(w), Math.round(h)), alpha = .4f + .6f * grow)
}
}
/** The smallest box holding every pixel that isn't fully clear: left, top, right, bottom (exclusive); the whole image if none. */
internal fun alphaBounds(px: IntArray, w: Int, h: Int): IntArray {
var l = w; var t = h; var r = 0; var b = 0
for (y in 0 until h) for (x in 0 until w) if ((px[y * w + x] ushr 24) != 0) { if (x < l) l = x; if (x > r) r = x; if (y < t) t = y; if (y > b) b = y }
return if (r < l) intArrayOf(0, 0, w, h) else intArrayOf(l, t, r + 1, b + 1)
}
/** Where the logo's drawn part goes: [width] wide, its centre exactly on (cx, cy). Left, top, right, bottom. */
internal fun identRect(box: IntArray, cx: Float, cy: Float, width: Float): FloatArray {
val bw = (box[2] - box[0]).toFloat(); val bh = (box[3] - box[1]).toFloat()
val h = width * bh / bw
return floatArrayOf(cx - width / 2, cy - h / 2, cx + width / 2, cy + h / 2)
}
/** The pad at the end of the chute, in the Stage B frame's units: everything in the middle is centred on it. */
internal object ChaosArtGeometry {
const val CHUTE_X = 960f
const val CHUTE_Y = 500f
}