Created
June 1, 2026 22:14
-
-
Save costafotjet/53d4ec648c752aa1a4bd13f3437ec8a5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| @RunWith(RobolectricTestRunner::class) | |
| @Config(sdk = [35]) | |
| class PulsingCirclesDocument { | |
| @Test | |
| fun generate() { | |
| val context = ApplicationProvider.getApplicationContext<Context>() | |
| val displayInfo = RemoteCreationDisplayInfo( | |
| width = 1080, | |
| height = 1080, | |
| densityDpi = 420, | |
| ) | |
| val doc = runBlocking { | |
| captureSingleRemoteDocument( | |
| context = context, | |
| creationDisplayInfo = displayInfo, | |
| ) { | |
| RemoteCanvas( | |
| modifier = RemoteModifier.fillMaxSize().background(Color(0xFF0A0A23)), | |
| ) { | |
| val cx = remote.component.centerX | |
| val cy = remote.component.centerY | |
| val maxRad = remote.component.width.min(remote.component.height) * 0.45f | |
| val t = remote.time.ContinuousSec() | |
| val colors = listOf( | |
| Color(0xFFFF006E), | |
| Color(0xFFFF4D6D), | |
| Color(0xFFFB5607), | |
| Color(0xFFFF9E00), | |
| Color(0xFFFFBE0B), | |
| Color(0xFF3A86FF), | |
| Color(0xFF8338EC), | |
| ) | |
| // Draw rings from outermost to innermost | |
| for (i in colors.indices.reversed()) { | |
| val baseRadius = maxRad * ((i + 1).toFloat() / colors.size) | |
| // Each ring pulses with a phase offset | |
| val pulse = sin(t * 2f + i.toFloat() * 0.8f) * maxRad * 0.06f | |
| val radius = baseRadius + pulse | |
| drawCircle( | |
| paint = RemotePaint { | |
| color = colors[i].rc | |
| style = PaintingStyle.Stroke | |
| strokeWidth = 8f.rf | |
| }, | |
| center = RemoteOffset(cx, cy), | |
| radius = radius, | |
| ) | |
| } | |
| // Glowing center dot | |
| val centerPulse = (sin(t * 3f) + 1f.rf) * 10f + 15f | |
| drawCircle( | |
| paint = RemotePaint { color = Color(0xFFFFFFFF).rc }, | |
| center = RemoteOffset(cx, cy), | |
| radius = centerPulse, | |
| ) | |
| } | |
| } | |
| } | |
| File("../output/pulsing_circles.rc").apply { parentFile?.mkdirs() }.writeBytes(doc.bytes) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment