本文整理汇总了TypeScript中app/scripts/common.MathUtil.lerp方法的典型用法代码示例。如果您正苦于以下问题:TypeScript MathUtil.lerp方法的具体用法?TypeScript MathUtil.lerp怎么用?TypeScript MathUtil.lerp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app/scripts/common.MathUtil
的用法示例。
在下文中一共展示了MathUtil.lerp方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getPointAtLength
getPointAtLength(distance: number): Point {
const t = distance / this.getPathLength();
const { x: x1, y: y1 } = this.p1;
const { x: x2, y: y2 } = this.p2;
return {
x: MathUtil.lerp(x1, x2, t),
y: MathUtil.lerp(y1, y2, t),
};
}
示例2: split
split(t1: number, t2: number) {
const { x: x1, y: y1 } = this.p1;
const { x: x2, y: y2 } = this.p2;
const p1 = { x: MathUtil.lerp(x1, x2, t1), y: MathUtil.lerp(y1, y2, t1) };
const p2 = { x: MathUtil.lerp(x1, x2, t2), y: MathUtil.lerp(y1, y2, t2) };
if (MathUtil.arePointsEqual(p1, p2)) {
return new PointCalculator(this.id, this.svgChar, p1);
}
return new LineCalculator(this.id, this.svgChar, p1, p2);
}
示例3: interpolateValue
// @Override
interpolateValue(start: string, end: string, f: number) {
if (!start || !end) {
return undefined;
}
const s = ColorUtil.parseAndroidColor(start);
const e = ColorUtil.parseAndroidColor(end);
return ColorUtil.toAndroidString({
r: _.clamp(Math.round(MathUtil.lerp(s.r, e.r, f)), 0, 0xff),
g: _.clamp(Math.round(MathUtil.lerp(s.g, e.g, f)), 0, 0xff),
b: _.clamp(Math.round(MathUtil.lerp(s.b, e.b, f)), 0, 0xff),
a: _.clamp(Math.round(MathUtil.lerp(s.a, e.a, f)), 0, 0xff),
});
}
示例4: Command
start.getCommands().forEach((startCmd, i) => {
const endCmd = end.getCommands()[i];
const points: Point[] = [];
for (let j = 0; j < startCmd.points.length; j++) {
const p1 = startCmd.points[j];
const p2 = endCmd.points[j];
if (p1 && p2) {
// The 'start' point of the first Move command in a path
// will be undefined. Skip it.
const px = MathUtil.lerp(p1.x, p2.x, fraction);
const py = MathUtil.lerp(p1.y, p2.y, fraction);
points.push({ x: px, y: py });
} else {
points.push(undefined);
}
}
// TODO: avoid re-generating unique ids on each animation frame.
newCommands.push(new Command(startCmd.type, points));
});
示例5: toCommand
toCommand() {
let points: Point[];
switch (this.svgChar) {
case 'L':
case 'Z':
points = [this.p1, this.p2];
break;
case 'Q':
const cp = {
x: MathUtil.lerp(this.p1.x, this.p2.x, 0.5),
y: MathUtil.lerp(this.p1.y, this.p2.y, 0.5),
};
points = [this.p1, cp, this.p2];
break;
case 'C':
const cp1 = {
x: MathUtil.lerp(this.p1.x, this.p2.x, 1 / 3),
y: MathUtil.lerp(this.p1.y, this.p2.y, 1 / 3),
};
const cp2 = {
x: MathUtil.lerp(this.p1.x, this.p2.x, 2 / 3),
y: MathUtil.lerp(this.p1.y, this.p2.y, 2 / 3),
};
points = [this.p1, cp1, cp2, this.p2];
break;
default:
throw new Error('Invalid command type: ' + this.svgChar);
}
return new CommandBuilder(this.svgChar, points).setId(this.id).build();
}
示例6: interpolateValue
// @Override
interpolateValue(start: number, end: number, fraction: number) {
return MathUtil.lerp(start, end, fraction);
}