mirror of
https://github.com/tapframe/NuvioStreaming.git
synced 2026-07-26 22:42:17 +00:00
ref: fine tuning grains
This commit is contained in:
parent
e6ef2fd3ae
commit
caad155308
4 changed files with 11 additions and 4 deletions
|
|
@ -9,6 +9,9 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.graphics.drawscope.DrawScope
|
||||
import androidx.compose.ui.graphics.nativeCanvas
|
||||
|
||||
internal actual val ashSwarmMaxGrainBudget: Int =
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) 26000 else 15000
|
||||
|
||||
internal actual class AshSwarmRenderer actual constructor(maxGrains: Int) {
|
||||
private val batched = Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ package com.nuvio.app.core.ui
|
|||
|
||||
import androidx.compose.ui.graphics.drawscope.DrawScope
|
||||
|
||||
internal expect val ashSwarmMaxGrainBudget: Int
|
||||
|
||||
internal expect class AshSwarmRenderer(maxGrains: Int) {
|
||||
fun draw(
|
||||
scope: DrawScope,
|
||||
|
|
|
|||
|
|
@ -99,8 +99,7 @@ private class AshField(
|
|||
val clipOutline = Path()
|
||||
}
|
||||
|
||||
private const val ASH_COLS = 100
|
||||
private const val ASH_MAX_TILES = 15000
|
||||
private const val ASH_COLS = 130
|
||||
private const val TILE_LIFESPAN = 0.5f
|
||||
private const val TAU = 6.2831855f
|
||||
|
||||
|
|
@ -112,10 +111,11 @@ private fun frontValue(nx: Float, ny: Float, phase: Float): Float =
|
|||
|
||||
private fun buildAshField(bitmap: ImageBitmap, seed: Long): AshField {
|
||||
val aspect = bitmap.height.toFloat() / bitmap.width.toFloat()
|
||||
val maxTiles = ashSwarmMaxGrainBudget
|
||||
var cols = ASH_COLS
|
||||
var rows = (cols * aspect).toInt().coerceAtLeast(8)
|
||||
if (cols * rows > ASH_MAX_TILES) {
|
||||
cols = (kotlin.math.sqrt(ASH_MAX_TILES / aspect)).toInt().coerceAtLeast(12)
|
||||
if (cols * rows > maxTiles) {
|
||||
cols = (kotlin.math.sqrt(maxTiles / aspect)).toInt().coerceAtLeast(12)
|
||||
rows = (cols * aspect).toInt().coerceAtLeast(8)
|
||||
}
|
||||
val pixels = bitmap.toPixelMap()
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@ import org.jetbrains.skia.BlendMode
|
|||
import org.jetbrains.skia.Paint
|
||||
import org.jetbrains.skia.VertexMode
|
||||
|
||||
internal actual val ashSwarmMaxGrainBudget: Int = 26000
|
||||
|
||||
internal actual class AshSwarmRenderer actual constructor(maxGrains: Int) {
|
||||
private val positions = FloatArray(maxGrains * 12)
|
||||
private val vertexColors = IntArray(maxGrains * 6)
|
||||
|
|
|
|||
Loading…
Reference in a new issue