本文整理匯總了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);
}