{"id":15028168,"url":"https://github.com/yasic/particletextview","last_synced_at":"2025-04-12T17:46:05.417Z","repository":{"id":93072095,"uuid":"90394599","full_name":"Yasic/ParticleTextView","owner":"Yasic","description":"一个用粒子动画显示文字的 Android 自定义 View","archived":false,"fork":false,"pushed_at":"2017-05-31T16:23:21.000Z","size":48025,"stargazers_count":1324,"open_issues_count":11,"forks_count":197,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-03T20:11:21.455Z","etag":null,"topics":["android","customview","particles"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yasic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-05-05T16:12:39.000Z","updated_at":"2025-02-18T03:16:11.000Z","dependencies_parsed_at":"2023-06-04T16:00:32.839Z","dependency_job_id":null,"html_url":"https://github.com/Yasic/ParticleTextView","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yasic%2FParticleTextView","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yasic%2FParticleTextView/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yasic%2FParticleTextView/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yasic%2FParticleTextView/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yasic","download_url":"https://codeload.github.com/Yasic/ParticleTextView/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248609627,"owners_count":21132916,"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":["android","customview","particles"],"created_at":"2024-09-24T20:07:44.097Z","updated_at":"2025-04-12T17:46:05.391Z","avatar_url":"https://github.com/Yasic.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ParticleTextView\n\n# 一、总述\n\nParticleTextView 是一个 Android 平台的自定义 view 组件，可以用彩色粒子组成指定的文字，并配合多种动画效果和配置属性，呈现出丰富的视觉效果。\n\n\u003cimg src=\"https://github.com/Yasic/ParticleTextView/blob/master/Screenshot/Total.gif?raw=true\" width=\"300px\" height=\"500px\"\u003e\n\n# 二、使用\n\n## 1. 引入依赖\n\n```\ncompile 'yasic.library.ParticleTextView:particletextview:0.0.6'\n```\n\n## 2. 加入到布局文件中\n\n```Java\n    \u003ccom.yasic.library.particletextview.View.ParticleTextView\n        android:id=\"@+id/particleTextView\"\n        android:layout_width=\"match_parent\"\n        android:layout_height=\"match_parent\" /\u003e\n```\n\n## 3. 实例化配置信息类 ParticleTextViewConfig\n\n```Java\nParticleTextView particleTextView = (ParticleTextView) findViewById(R.id.particleTextView);\nRandomMovingStrategy randomMovingStrategy = new RandomMovingStrategy();\nParticleTextViewConfig config = new ParticleTextViewConfig.Builder()\n                .setRowStep(8)\n                .setColumnStep(8)\n                .setTargetText(\"Random\")\n                .setReleasing(0.2)\n                .setParticleRadius(4)\n                .setMiniDistance(0.1)\n                .setTextSize(150)\n                .setMovingStrategy(randomMovingStrategy)\n                .instance();\nparticleTextView.setConfig(config);\n```\n\n## 4. 启动动画\n\n```Java\nparticleTextView.startAnimation();\n```\n\n## 5. 暂停动画\n\n```Java\nparticleTextView1.stopAnimation();\n```\n\n# 三、API说明\n\n## 粒子移动轨迹策略 MovingStrategy\n\n移动轨迹策略继承自抽象类 MovingStrategy，可以自己继承并实现其中的 setMovingPath 方法，以下是自带的几种移动轨迹策略。\n\n* RandomMovingStrategy\n\n\u003cimg src=\"https://github.com/Yasic/ParticleTextView/blob/master/Screenshot/Random.gif?raw=true\" width=\"300px\" height=\"500px\"\u003e\n\n* CornerStrategy\n\n\u003cimg src=\"https://github.com/Yasic/ParticleTextView/blob/master/Screenshot/Corner.gif?raw=true\" width=\"300px\" height=\"500px\"\u003e\n\n* HorizontalStrategy\n\n\u003cimg src=\"https://github.com/Yasic/ParticleTextView/blob/master/Screenshot/Horizontal.gif?raw=true\" width=\"300px\" height=\"500px\"\u003e\n\n* BidiHorizontalStrategy\n\n\u003cimg src=\"https://github.com/Yasic/ParticleTextView/blob/master/Screenshot/BidiHorizontal.gif?raw=true\" width=\"300px\" height=\"500px\"\u003e\n\n* VerticalStrategy\n\n\u003cimg src=\"https://github.com/Yasic/ParticleTextView/blob/master/Screenshot/Vertical.gif?raw=true\" width=\"300px\" height=\"500px\"\u003e\n\n* BidiVerticalStrategy\n\n\u003cimg src=\"https://github.com/Yasic/ParticleTextView/blob/master/Screenshot/BidiVertical.gif?raw=true\" width=\"300px\" height=\"500px\"\u003e\n\n## 配置信息类 ParticleTextViewConfig\n\n配置信息类采用工厂模式创建，以下属性均为可选属性。\n\n* 设置显示的文字\n\n```Java\nsetTargetText(String targetText)\n```\n\n* 设置文字大小\n\n```Java\nsetTextSize(int textSize)\n```\n\n* 设置粒子半径\n\n```Java\nsetParticleRadius(float radius)\n```\n\n* 设置横向和纵向像素采样间隔\n\n采样间隔越小生成的粒子数目越多，但绘制帧数也随之降低，建议结合文字大小与粒子半径进行调节。\n\n```Java\nsetColumnStep(int columnStep)\nsetRowStep(int rowStep)\n```\n\n* 设置粒子运动速度\n\n```Java\nsetReleasing(double releasing)\n```\n\n指定时刻，粒子的运动速度由下列公式决定，其中 Vx 和 Vy 分别是 X 与 Y 方向上的运动速度，target 与 source 分别是粒子的目的坐标与当前坐标\n\n```\nVx = (targetX - sourceX) * releasing\nVy = (targetY - sourceY) * releasing\n```\n\n* 设置最小判决距离\n\n当粒子与目的坐标距离小于最小判决距离时将直接移动到目的坐标，从而减少不明显的动画过程。\n\n```Java\nsetMiniDistance(double miniDistance)\n```\n\n* 设置粒子颜色域\n\n默认使用完全随机的颜色域\n\n```Java\nsetParticleColorArray(String[] particleColorArray)\n```\n\n* 设置粒子移动轨迹策略\n\n默认使用随机分布式策略\n\n```Java\nsetMovingStrategy(MovingStrategy movingStrategy)\n```\n\n* 设置不同路径间动画的间隔时间\n\ndelay \u003c 0 时动画不循环\n\n```Java\nsetDelay(Long delay)\n```\n\n## ParticleTextView类\n\n* 指定配置信息类\n\n```\nsetConfig(ParticleTextViewConfig config)\n```\n\n* 开启动画\n\n```\nvoid startAnimation()\n```\n\n* 停止动画\n\n```\nvoid stopAnimation()\n```\n\n* 获取动画是否暂停\n\n暂停是指动画完成了一段路径后的暂留状态\n\n```\nboolean isAnimationPause()\n```\n\n* 获取动画是否停止\n\n停止是指动画完成了一次完整路径后的停止状态\n\n```\nboolean isAnimationStop()\n```\n\n## ParticleTextSurfaceView 类\n\n继承自 SurfaceView 类，利用子线程进行 Canvas 绘制，在多个组件渲染情况下效率更高。所有 API 与 ParticleTextView 类一致。\n\n# License\n\n```\nCopyright 2017 Yasic\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\nhttp://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%2Fyasic%2Fparticletextview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyasic%2Fparticletextview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyasic%2Fparticletextview/lists"}