{"id":22165828,"url":"https://github.com/tutorialsandroid/particles","last_synced_at":"2025-10-18T23:47:21.621Z","repository":{"id":114468521,"uuid":"348383942","full_name":"TutorialsAndroid/Particles","owner":"TutorialsAndroid","description":"Particles is an android library that will help you to show particles on your app screen","archived":false,"fork":false,"pushed_at":"2023-09-04T16:21:05.000Z","size":7451,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-29T21:51:34.647Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","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/TutorialsAndroid.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-16T14:44:15.000Z","updated_at":"2022-04-11T13:50:16.000Z","dependencies_parsed_at":"2025-01-29T21:47:59.480Z","dependency_job_id":null,"html_url":"https://github.com/TutorialsAndroid/Particles","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TutorialsAndroid%2FParticles","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TutorialsAndroid%2FParticles/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TutorialsAndroid%2FParticles/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TutorialsAndroid%2FParticles/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TutorialsAndroid","download_url":"https://codeload.github.com/TutorialsAndroid/Particles/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245304870,"owners_count":20593626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-12-02T05:16:47.493Z","updated_at":"2025-10-18T23:47:16.574Z","avatar_url":"https://github.com/TutorialsAndroid.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://github.com/TutorialsAndroid/Particles/blob/main/sample/src/main/res/mipmap-xxhdpi/ic_launcher.png)\n\n#Particles\n\nParticles is an android library that will help you to show particles on your app screen\n\n## And Don't Forget To Follow Me On Instagram\n\n\u003cp align=\"center\"\u003eFollow me on instagram to stay up-to-date https://instagram.com/a.masram444\n\n## ScreenShot\n![](https://github.com/TutorialsAndroid/MenuSheet/blob/main/art/device-2021-03-15-192350.gif)\n\n## Setup\nThe simplest way to use MenuSheet is to add the library as dependency to your build.\n\n## Gradle\n\nAdd it in your root build.gradle at the end of repositories:\n\n    allprojects {\n        repositories {\n            ...\n            maven { url 'https://jitpack.io' }\n        }\n    }\n\nStep 2. Add the dependency\n\n    dependencies {\n            implementation 'com.github.TutorialsAndroid:Particles:v1.0'\n    }\n\n\n## Simple usage\n------------\n\nThe only thing you need to get particles on your screen is a parent view to host the `ParticlesView`\nand thus the particles animation. From this point on, this parent view is referred to as `container`.\n\nPlease note that the library uses measurements from `container` to figure out how to best animate\nthe particles. If the `container` is not measured when creating the particles, then nothing will\nshow up on the screen. A common pitfall is creating particles inside activity lifecycle as the views\nare most likely not measured at those points.\n\nYou can generate pre-configured particles from `CommonParticles`. You only need to provide it with\nthe parent `container`, a `ParticlesSource`, and an array of possible colors for the particles.\nThe default particles shapes are circle, triangle, and square.\n\n```java\nCommonParticles.rainingParticles(container, new int[] {\n                            Color.BLACK,Color.BLUE,Color.GREEN,Color.RED,Color.YELLOW\n                    }).oneShot();\n```\n\n\nMore custom usage\n-----------------\n\nFirst, we need to define what our individual particles is through the `ParticlesGenerator`. Each call of `generateParticles` must generate a brand new `Particles` object (the `ParticlesManager` will recycle the generated particles as needed so youmight see fewer and fewer calls to `generateParticles` as the animation goes on). We pass in a`Random` into `generateParticles` in case you want to randomly generate a particles from a list\nof possible particles.\n\nA simple `ParticlesGenerator` might look like this:\n\n```java\n    final List\u003cBitmap\u003e allPossibleParticles = Utils.generateParticlesBitmaps(new int[] { Color.BLACK }, 20 /* size */);\n    // Alternatively, we provide some helper methods inside `Utils` to generate square, circle,\n    // and triangle bitmaps.\n    // Utils.generateParticlesBitmaps(new int[] { Color.BLACK }, 20 /* size */);\n\n    final int numParticles = allPossibleParticles.size();\n    final ParticlesGenerator particlesGenerator = new ParticlesGenerator() {\n        @Override\n        public Particles generateParticles(Random random) {\n            final Bitmap bitmap = allPossibleParticles.get(random.nextInt(numParticles));\n            return new BitmapParticles(bitmap);\n        }\n    };\n```\n\nOnce we have our `ParticlesGenerator`, we'll need to define a `ParticlesSource` from which particles\nwill appear out of. This source can be any arbitrary point or line.\n\n```java\nfinal int containerMiddleX = container.getWidth() / 2;\nfinal int containerMiddleY = container.getHeight() / 2;\nfinal ParticlesSource particlesSource = new ParticlesSource(containerMiddleX, containerMiddleY);\n```\n\nNow you are ready! construct your `ParticlesManager`, configure the animation to your liking, and\nthen call `animate()`!\n\n```java\nnew ParticlesManager(context, particlesGenerator, particlesSource, container)\n        .setEmissionDuration(1000)\n        .setEmissionRate(100)\n        .setVelocityX(20, 10)\n        .setVelocityY(100)\n        .setRotationalVelocity(180, 180)\n        .animate();\n```\n\nThe `animate()` call will create and configure the various `Particles` objects on demand,\ncreate a new `ParticlesView`, initialize the proper states for all of the components, attach the\nview to the `container` and start the animation. The `ParticlesView` will auto-detach itself once\nall of the particles have terminated and are off the screen.\n\nFor more sample usage of the library, please check out the\n[particles-sample](https://github.com/TutorialsAndroid/Particles/tree/main/sample/src/main/java/com/tutorials/android/particles/sample) app that's\nincluded in this project.\n\n\nConfiguration\n-------------\n\nThe `ParticlesManager` is easily configurable. For simplicity's sake, all of the velocity and\nacceleration attributes are in pixels per second or pixels per second^2, whereas all of the raw\ntime attributes (such as `ttl` and `emissionDuration`) are in milliseconds.\n\nYou will notice that most of the setters for the physical attributes (e.g. velocity, acceleration,\nrotation) can take in either one argument for the actual value or two arguments. The second\nargument allows you to specify a random deviation if you want to randomize the behavior among\nall of the generated particles.\n\nFor example:\n\n```java\nparticlesManager.setVelocityX(200f, 50f);\n```\n\nThe generated particles will have an initial X velocity of anywhere between `200 - 50` or `150` and\n`200 + 50` or `250`, eventually distributed.\n\n`enableFadeOut(Interpolator fadeOutInterpolator)` is another interesting method. You can specify\nthat fade out occurs as a particles nears its boundary (either reaching the physical boundary\nspecified in `bound` (this is either the entirety of `container` or set in `setBound`) or reaching\n`ttl`). The interpolator essentially takes in a value between 0 and 1 (0 means that the particles\nis at its source, 1 means the particles is at its bound) and outputs an alpha value between 0 and 1\n(0 is transparent and 1 is opaque). This way, we allow you to have the full power of specifying\nhow the fade out occurs.\n\nOr, if you are lazy, you can just use `Utils.getDefaultAlphaInterpolator()`.\n\n\nAdvanced usage\n==============\n\nEnable touch and drag\n---------------------\n\nIf you call `particlesManager.setTouchEnabled(true)`, you can allow the user to touch and drag\nthe particles that are on the screen. When the user let go of the particles, the particles will\nstart at that location with the user initiated velocity and the pre-configured acceleration\nand resume animation from there.\n\n\nCustom Particles\n---------------\n\nIt's very easy to define a custom `Particles` (see `BitmapParticles`). You simply need to extend\nfrom the `Particles` class and implement `drawInternal`. The function will provide you with a\n`Canvas` to draw on as well as a work `Matrix` and `Paint` so you don't have to allocate objects\nin the draw path. You then need to essentially draw your particles however you want onto the canvas\nusing the specified `x`, `y`, and `rotation`.\n\nThe cool part is that you can interpret `rotation` however you want. Instead of an angle in degrees,\nyou can choose to interpret rotation where each degree corresponds to a new shape or new image.\nThis way, you can achieve some cool animation effects as the particles flow through the screen.\n\n\nChanging particles configuration mid-animation\n---------------------------------------------\n\nIf you have a handle on the `ParticlesManager`, you can actually very easily change the configuration\nmid-animation for more unique experiences. For example:\n\n```java\nparticlesManager.setEmissionRate(100)\n        .animate();\n\nnew Handler().postDelayed(new Runnable() {\n    @Override public void run() {\n        particlesManager.setEmissionRate(20);\n    }\n}, 3000);\n```\n\nThe above snippet will configure the initial emission rate to be 100 particles per second and start\nthe animation. After 3 seconds, it will reduce the emission rate to 20 particles per second. This \napplies to all attributes (e.g. changing velocity or acceleration based on some outside condition).\n\n\n## License\n\n* [Apache Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.html)\n\n```\nCopyright 2021 MenuSheet\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftutorialsandroid%2Fparticles","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftutorialsandroid%2Fparticles","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftutorialsandroid%2Fparticles/lists"}