當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript MathUtil.lerp方法代碼示例

本文整理匯總了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),
   };
 }
開發者ID:arpitsaan,項目名稱:ShapeShifter,代碼行數:9,代碼來源:LineCalculator.ts

示例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);
 }
開發者ID:arpitsaan,項目名稱:ShapeShifter,代碼行數:10,代碼來源:LineCalculator.ts

示例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),
   });
 }
開發者ID:arpitsaan,項目名稱:ShapeShifter,代碼行數:14,代碼來源:ColorProperty.ts

示例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));
 });
開發者ID:arpitsaan,項目名稱:ShapeShifter,代碼行數:19,代碼來源:PathUtil.ts

示例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();
 }
開發者ID:arpitsaan,項目名稱:ShapeShifter,代碼行數:30,代碼來源:LineCalculator.ts

示例6: interpolateValue

 // @Override
 interpolateValue(start: number, end: number, fraction: number) {
   return MathUtil.lerp(start, end, fraction);
 }
開發者ID:arpitsaan,項目名稱:ShapeShifter,代碼行數:4,代碼來源:NumberProperty.ts


注:本文中的app/scripts/common.MathUtil.lerp方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。