Repository navigation
Respect particleSizes for ParticleShape.Image particles - #27
Merged
Merged
Conversation
Image particles were always drawn at the bitmap's intrinsic pixel size, so particleSizes had no effect and there was no config knob to control how big image particles appear (unlike Circle/PathShape). Draw the bitmap into a destination box sized from canvasParticle.size (converted to px) via drawImage(dstOffset, dstSize), with scale/rotation applied on top. Image particles are now size-consistent with every other shape and independent of the source asset's resolution. Applied to both the live render branch in DrawScope.draw and the ParticleShape.Image.draw extension. Updated the particleSizes KDoc. Note: this is a behavior change for anyone relying on intrinsic-size image rendering. Closes #23 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Give the star particles a long lifespan (4-6s) and a large scale ramp (1x to ~5x) so the per-particle size change is easy to watch. This makes the particleSizes fix for image particles visually obvious: stars start at the configured size and grow smoothly instead of being locked to the bitmap's intrinsic pixels. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Keep the resized/growing star particles (10.dp base + 1x->5x scale ramp) but revert lifespan, fade, scale duration, force, and birth rate to their original short-lived values so the sample is back to a snappy burst. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Use a mix of particleSizes (3/5/7/9.dp) and a gentler 1x->2x scale ramp so the sample shows a natural spread of star sizes while still exercising the image-resize fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #23.
particleSizeshad no effect forParticleShape.Image: the bitmap was always drawn at its intrinsic pixel size, so image particles couldn't be sized via the config the wayCircleandPathShapecan.Now the bitmap is drawn into a destination box sized from
canvasParticle.size(converted to px) usingdrawImage(dstOffset, dstSize), withscale/rotationapplied on top. Image particles are size-consistent with every other shape and independent of the source asset's resolution.Changes
ui/ParticleShapeExtensions.kt— fixed the liveis ParticleShape.Image ->branch inDrawScope.drawand theParticleShape.Image.drawextension (kept consistent).CanvasEmitterConfig.kt— clarified theparticleSizesKDoc to state it applies to image particles too.Behavior change
particleSizesinstead of the bitmap's pixel dimensions. (NoCHANGELOG.mdin the repo, so noting it here.)Testing
:particle-emitter:compileKotlinMetadatacompiles cleanly.star_four.png(10×10 px) withparticleSizes = 8.dpnow renders as crisp, correctly-sized stars scaled to the configured size rather than the raw 10px bitmap.🤖 Generated with Claude Code