本文整理匯總了TypeScript中math2d.Vector.translate方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Vector.translate方法的具體用法?TypeScript Vector.translate怎麽用?TypeScript Vector.translate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類math2d.Vector
的用法示例。
在下文中一共展示了Vector.translate方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: constructor
x: number;
y: number;
constructor(x: number, y: number);
translate(dx: number, dy: number): Vector;
}
function getLength(p: Vector): number;
}
// @filename: math2d-augment.d.ts
import * as Math2d from 'math2d';
// Augment the module
declare module 'math2d' {
// Add a method to the class
interface Vector {
reverse(): Math2d.Point;
}
}
// @filename: b.ts
/// <reference path="math2d-augment.d.ts" />
import * as m from 'math2d';
let v = new m.Vector(3, 2);
let magnitude = m.getLength(v);
let p: m.Point = v.translate(5, 5);
p = v.reverse();
var t = p.x;
示例2: constructor
}
export class Vector implements Point {
x: number;
y: number;
constructor(x: number, y: number);
translate(dx: number, dy: number): Vector;
}
export function getLength(p: Vector): number;
// @filename: math2d-augment.d.ts
import * as Math2d from 'math2d';
// Augment the module
declare module 'math2d' {
// Add a method to the class
interface Vector {
reverse(): Math2d.Point;
}
}
// @filename: a.ts
/// <reference path="node_modules/math2d/index.d.ts" />
/// <reference path="math2d-augment.d.ts" />
let v = new Math2d.Vector(3, 2);
let magnitude = Math2d.getLength(v);
let p: Math2d.Point = v.translate(5, 5);
p = v.reverse();
var t = p.x;