mirror of
https://github.com/motajs/template.git
synced 2026-11-18 10:14:30 +08:00
feat: 动画类 Animater
This commit is contained in:
1 parent
feb6abb5bb
commit
555cf96d76
9 files changed
+1363
-9
No files matched your search
@@ -49,6 +49,8 @@
|
||||
"47": "Cannot require text area outside the target map.",
|
||||
"48": "Cannot $1 excitables on destroyed excitation.",
|
||||
"49": "Cannot $1 on variator without excitation binding.",
|
||||
"50": "Expected a planEnd call after animation plan calling.",
|
||||
"51": "Animatable object cannot be animated by plans with the same start time.",
|
||||
"1201": "Floor-damage extension needs 'floor-binder' extension as dependency."
|
||||
},
|
||||
"warn": {
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/**
|
||||
* 创建一个等待指定时间长度的 `Promise`
|
||||
* @param time 等待时间
|
||||
* @example await sleep(1000);
|
||||
*/
|
||||
export function sleep(time: number) {
|
||||
return new Promise(res => setTimeout(res, time));
|
||||
}
|
||||
|
||||
/**
|
||||
* 对序列依次求和,结果为一个数组,每一项的值为该项及其前面所有项的和
|
||||
* @param seq 数字序列
|
||||
* @example cumsum([1, 2, 3, 4]); // [1, 3, 6, 10]
|
||||
*/
|
||||
export function cumsum(seq: Iterable<number>): number[] {
|
||||
const result: number[] = [];
|
||||
let now = 0;
|
||||
for (const ele of seq) {
|
||||
result.push((now += ele));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
Reference in new issue
Block a user