{"id":27218020,"url":"https://github.com/nahco3-code/arenats-minemotion","last_synced_at":"2025-04-10T05:35:43.731Z","repository":{"id":261938804,"uuid":"885758699","full_name":"NaHCO3-code/arenats-minemotion","owner":"NaHCO3-code","description":"简单的动画库","archived":false,"fork":false,"pushed_at":"2024-11-09T11:17:17.000Z","size":972,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-09T12:20:59.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NaHCO3-code.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-11-09T10:18:16.000Z","updated_at":"2024-11-09T11:17:20.000Z","dependencies_parsed_at":"2024-11-09T12:21:05.432Z","dependency_job_id":"f9efa283-c47c-49a9-8d41-389f28e90cf8","html_url":"https://github.com/NaHCO3-code/arenats-minemotion","commit_stats":null,"previous_names":["nahco3-code/arenats-minemotion"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaHCO3-code%2Farenats-minemotion","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaHCO3-code%2Farenats-minemotion/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaHCO3-code%2Farenats-minemotion/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NaHCO3-code%2Farenats-minemotion/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NaHCO3-code","download_url":"https://codeload.github.com/NaHCO3-code/arenats-minemotion/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248164040,"owners_count":21058069,"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":"2025-04-10T05:35:43.302Z","updated_at":"2025-04-10T05:35:43.719Z","avatar_url":"https://github.com/NaHCO3-code.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MineMotion\n简单的动画库\n\n# Example\n```javascript\nconst box = UiBox.create();\nbox.size.offset.x = 100;\nbox.size.offset.y = 100;\nbox.backgroundColor.r = 255;\nbox.backgroundColor.g = 0;\nbox.backgroundColor.b = 0;\nbox.parent = ui;\n;(async function(){\n  // 在1s内移动到(300, 200)\n  await MineMotion.fromTo(\n    box.position.offset, // 要进行变换的对象\n    1000,                // 变换时间，单位为ms\n    { x: 0, y: 0 },      // 起始值\n    { x: 300, y: 200 },  // 目标值\n    Ease.easeInOut       // 缓动函数\n  ).wait;\n\n  // 变色的同时移动到(0, 0)\n  // 这里不await，否则会先变色后移动\n  MineMotion.fromTo(\n    box.backgroundColor, \n    1000, \n    { r: 255, g: 0, b: 0 }, \n    { r: 0, g: 255, b: 0 }, \n    Ease.easeInOut\n  );\n  await MineMotion.fromTo(\n    box.position.offset,\n    1000,\n    { x: 300, y: 200 },\n    { x: 0, y: 0 },\n    Ease.linear         // 使用线性缓动函数\n  ).wait;\n})();\n```\n效果：\n![](https://static.codemao.cn/pickduck/rkeYhTh-kx.gif?hash=FgTcHWUYxdyQDRPghdjzFeYTKTuc)\n\n# API\n## MineMotion.fromTo(obj, duration, start, end, ease)\n创建一个动画，从start到end，在duration时间内完成。\n### definition\n```javascript\nstatic fromTo\u003cT extends Object\u003e(\n  obj: T, \n  duration: number, \n  from: Partial\u003cT\u003e,\n  to: Partial\u003cT\u003e,\n  ease: (rate: number) =\u003e number = Ease.linear\n)\n```\n## MineMotion.enable()\n启用动画。默认导入时自动启用。\n\n## MineMotion.disable()\n禁用动画。\n\n# Classes\n## MineMotion\n动画类。通过此类控制动画。\n### Methods\n#### pause()\n暂停动画。\n#### resume()\n继续动画。\n### Properties\n#### wait: Promise\u0026lt;void\u0026gt;\n动画完成时，该Promise会被resolve。\n\n# Constants\n## Ease\n一些常见缓动函数的集合。\n\n你也可以自己编写缓动函数或使用网上的缓动函数，只要它们是符合形如 $f: [0, 1] \\rightarrow [0, 1]$ 的函数即可。\n### linear\n线性缓动函数。\n### easeInOut\n平滑缓动函数。\n### easeIn\n平滑缓入函数。\n### easeOut\n平滑缓出函数。\n### sine\n正弦缓动函数。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnahco3-code%2Farenats-minemotion","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnahco3-code%2Farenats-minemotion","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnahco3-code%2Farenats-minemotion/lists"}