{"id":37026006,"url":"https://github.com/curiousnikhil/compose-particle-system","last_synced_at":"2026-01-14T03:01:07.527Z","repository":{"id":43042037,"uuid":"412779399","full_name":"CuriousNikhil/compose-particle-system","owner":"CuriousNikhil","description":"A lightweight particle system for Jetpack Compose - Quarks","archived":false,"fork":false,"pushed_at":"2022-07-11T01:44:48.000Z","size":149,"stargazers_count":80,"open_issues_count":3,"forks_count":10,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-24T08:41:25.615Z","etag":null,"topics":["android","android-library","jetpack-compose","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CuriousNikhil.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-02T11:41:47.000Z","updated_at":"2025-03-05T11:42:36.000Z","dependencies_parsed_at":"2022-08-24T14:35:41.873Z","dependency_job_id":null,"html_url":"https://github.com/CuriousNikhil/compose-particle-system","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/CuriousNikhil/compose-particle-system","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousNikhil%2Fcompose-particle-system","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousNikhil%2Fcompose-particle-system/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousNikhil%2Fcompose-particle-system/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousNikhil%2Fcompose-particle-system/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CuriousNikhil","download_url":"https://codeload.github.com/CuriousNikhil/compose-particle-system/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CuriousNikhil%2Fcompose-particle-system/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28408799,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T01:52:23.358Z","status":"online","status_checked_at":"2026-01-14T02:00:06.678Z","response_time":107,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-library","jetpack-compose","kotlin"],"created_at":"2026-01-14T03:01:02.489Z","updated_at":"2026-01-14T03:01:07.474Z","avatar_url":"https://github.com/CuriousNikhil.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# compose-particle-system\n\nQuarks is a lightweight particle system for Jetpack Compose. There are endless possibilities for creating generative art with this particle system. Here are few examples - \n\n| Fountain | Meteor | Confetti | Explosion | Snowfall |\n|---|---|---|---|---|\n| ![fountain](https://user-images.githubusercontent.com/16976114/135747145-9abf8e1e-8829-4442-98be-ea63189c9422.gif) | ![meteor](https://user-images.githubusercontent.com/16976114/135746889-846c3c9c-896c-40b4-ba9e-72da5bbdd19c.gif) | ![confetti](https://user-images.githubusercontent.com/16976114/135746899-1a5a24c4-f968-4ab2-ab05-fc3de6e1cde7.gif) | ![explosion](https://user-images.githubusercontent.com/16976114/135746912-099591ac-9b37-42ed-aee5-e43ab0a4c69a.gif) | ![snowfall](https://user-images.githubusercontent.com/16976114/135746941-998bea7b-f9ed-455b-92e0-1c4de21ad2ee.gif)\n\n\n## Getting started\n\n1. Add the following dependencies in your `build.gradle` file\n\n```groovy\nimplementation \"me.nikhilchaudhari:quarks:{latest-release-version}\"\n```\n\n2. Call `CreateParticles(...)` composable function\n\n```kotlin\n\n Box(\n    modifier = Modifier\n        .fillMaxSize()\n        .background(Color.Black)\n) {\n    CreateParticles(\n        modifier = Modifier.fillMaxSize(),\n        // Set the initial position particles (From where do you want to shoot/generate particles)\n        x = 500f, y = 1000f,\n        // Set the velocity of particle in x and y direction\n        velocity = Velocity(xDirection = 1f, yDirection = 1f),\n        // Set the force acting on particle\n        force = Force.Gravity(0f),\n        // set acceleration on both x and y direction\n        acceleration = Acceleration(0f, 0f),\n        // set the desired size of particle that you want\n        particleSize = ParticleSize.RandomSizes(25..100),\n        // set particle colors or color\n        particleColor = ParticleColor.RandomColors(listOf(Color.White, Color.Yellow, Color.Red, Color.Blue)),\n        // set the max lifetime and aging factor of a particle\n        lifeTime = LifeTime(255f, 0.2f),\n        // set the emission type - how do you want to generate particle - as a flow/stream, as a explosion/blast\n        emissionType = EmissionType.ExplodeEmission(numberOfParticles = 100),\n        // duration of animation \n        durationMillis = 10 * 1000\n    )\n}\n```\n3. That's it. You're done. Check the configuration section to apply the required configs to your particle system.\n\n## Configuration\n\nThis Particle system (or any other particle system) runs on basic physics principles like velocity, force, acceleration etc. Also the emission of particle can be done in two ways 1. A continuous stream/flow of particle or 2. Explosion/Bursting of particles. To apply various configuration to particle system, here are the things you can configure for a particle and as well as for a system - \n\n### Position\n\nSet the initial position of particle emitter, from where do you want to start the emission. Set position `x = 500f` and `y = 500f`. This is canvas, coordinate system starts from top left corner. Horizontal - right direction is positive x axis and vertical-downwards is positive y axis.\n\n```kotlin\n CreateParticles(\n   //...\n    x = 500f, y = 1000f,\n  //...\n)\n```\n\n### Emission Type\n\nSet emission type to set particle emission as flow/stream of steady particles or as explosion at once.\n\n#### EmissionType.ExplodeEmission 🎊\n\nIf you want to explode/burst particles at once, you can set emission type to `emissionType = EmissionType.ExplodeEmission(numberOfParticles = 100)`. Pass the number of particles that you want at the time of explosion. \n\n#### EmissionType.FlowEmission 💧\n\n**Definite Emission**\n\nIf you want a slow and steady stream/flow of _constant number of particles_, set \n`emissionType = EmissionType.FlowEmission(maxParticlesCount = 500, emissionRate = 0.6f)`. \n\nPass the maximum number of particles you want for ex, `maxParticlesCount = 500`. This will create a steady flow of 500 particles. \n\n\n**Indefinite Emission** \n\nIf you want an indefinite stream/flow of particles you can set `maxParticlesCount = EmissionType.FlowEmission.INDEFINITE`. This will create an indefinite steady flow of _infinite number of particles_.\n\n⚠️  _`durationMillis = 10000` config does not work for indefinite emission. It'll run continuously, so make sure you only use it whenever needed. The stopping mechanism is yet to be added in the code._\n\n\n### Duration ⏰\n\nSet the duration value `durationMillis = 10000` for how long do you want to run the animation. Your animation of particle will run for the given number of milliseconds. Duration won't work for indefinte emission of particles.\n\n_Default value_ = 10000\n\n\n### Velocity 🚤\n\nYou can define the particle velocity in both directions. Set `velocity = Velocity(xDirection = 1f, yDirection = 1f, angle = TWO_PI, randomize = true)`. \n\n1. Angle - \n\n   By default, the `angle` is used to compute the sin and cos components of velocity over x and y direction. And the supplied values of `xDirection` and `yDirection` acts as magnitude. Default valye of `angle` is TWO_PI (in radians). You can set `angle` value in [radians](https://en.wikipedia.org/wiki/Radian). \n\n\n\n2. Randomizing velocities -\n   \n   By default, random velocities are applied to each particles but you can configure to keep it single value. Change the `randomize=false` flag to false.\n\n_Default value_ = `Velocity(xDirection = 1f, yDirection = 1f, angle = TWO_PI, randomize = true)`\n\n\n\n### Force 🏋️\n\nForce can be applied on each particle. Two types of force options are available. \n\n1. Force.Gravity - \n\n   You can apply gravitational force on particle by setting `force = Force.Gravity(magnitude = 2f)`. This way particle will experience a downward force\nIf you pass the negative value in the magnitude then it'll become an anti-gravity and particle will experience an upward force.\n\n2. Force.Wind - 🎐\n\n   You can apply Wind force on each particle in both directions. `force = Force.Wind(1.5f, 0.3f)`. Wind will move particle in the specified direction.\n\n_Default value_ = `Force.Gravity(0.0f)`\n\n### Acceleration 🏃\n\nYou can apply acceleration by setting `acceleration = Acceleration(xComponent = 1f, yComponent = 1f)`. Acceleration (x and y component) will be applied uniformly on each frame of animation to a particle.\n\n_Default value_ = `Acceleration(0f, 0f)`\n\n### Particle Size 🌏\n\nYou can configure particle size in two ways. \n\n1. Setting random size of particles\n\n   `particleSize = ParticleSize.RandomSizes(25..100)` Set range of sizes and a random size will be applied to each particle.\n\n2. Setting fixed size\n\n   `particleSize = ParticleSize.ConstantSize(25f)` sets the constant size to each particle.\n\n_Default value_ = `ParticleSize.ConstantSize(25f)`\n\n\n### Particle Color 🔶\n\nYou can configure random colors or single color to a particle.\n1. Random colors - \n   \n   `particleColor = ParticleColor.RandomColors(listOf(Color.White, Color.Yellow, Color.Red, Color.Blue))` pass the list of colors and a random value will be selected and applied to different particles.\n\n2. Single color -\n\n   `particleColor = ParticleColor.SingleColor(Color.Yellow)` sets the single color to each particle.\n\n_Default value_ = `ParticleColor.SingleColor(Color.Yellow)`\n\n\n### Lifetime \u0026 Aging factor 🧝‍♂️\n\nSet the lifetime of a particle to a value and an aging factor by which the life of particle is reduced in each frame.\n\n`lifeTime = LifeTime(maxLife = 255f, agingFactor = 1f)`\n\nHere at each frame the `againgFactor` will be removed from the `maxlife` value of particle.\n\n_Default value_ = `LifeTime(maxLife = 255f, agingFactor = 1f)`\n\n## TODOs\n- [ ] Add angular velocity\n- [ ] Add stopping mechanism for infinite flow\n- [ ] Add a custom `onDraw()` config to let user draw anything as a particle shape.\n\n\n## License \nLicensed under Apache License, Version 2.0 [here](https://github.com/CuriousNikhil/compose-particle-system/blob/main/README.md)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuriousnikhil%2Fcompose-particle-system","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcuriousnikhil%2Fcompose-particle-system","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcuriousnikhil%2Fcompose-particle-system/lists"}