-
-
Save Ahmed-Sellami/c6f0e907635e7934914e11e93db0c531 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val explosionParticleRadius: Float | |
val explosionRadius: Float | |
with(LocalDensity.current) { | |
explosionParticleRadius = dimensionResource(id = R.dimen.explosion_particle_radius).toPx() | |
explosionRadius = dimensionResource(id = R.dimen.explosion_radius).toPx() | |
} | |
Box { | |
Canvas(/* ... */) {/* ... */} | |
Canvas(modifier = Modifier.height(itemHeightDp) { | |
val numberOfExplosionParticles = 10 | |
val particleAngle = Math.PI * 2 / numberOfExplosionParticles | |
var angle = 0.0 | |
repeat(numberOfExplosionParticles / 2 + 1) { | |
val hTranslation = (cos(angle).toFloat() * explosionRadius) | |
val vTranslation = (sin(angle).toFloat() * explosionRadius) | |
translate(hTranslation, vTranslation) { | |
drawCircle( | |
color = shoesArticle.color, | |
radius = explosionParticleRadius | |
) | |
} | |
if (vTranslation.round(2) != -vTranslation.round(2)) { | |
translate(hTranslation, -vTranslation) { | |
drawCircle( | |
color = shoesArticle.color, | |
radius = explosionParticleRadius | |
) | |
} | |
} | |
angle += particleAngle | |
} | |
} | |
Box(/* ... */) {/* ... */} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment