mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #1657 from Borundin/easystarjs
Added type definitions for EasyStar.js 0.1.6
This commit is contained in:
@@ -65,6 +65,7 @@ List of Definitions
|
||||
* [domo](http://domo-js.com/) (by [Steve Fenton](https://github.com/Steve-Fenton))
|
||||
* [dust](http://linkedin.github.com/dustjs) (by [Marcelo Dezem](https://github.com/mdezem))
|
||||
* [EaselJS](http://www.createjs.com/#!/EaselJS) (by [Pedro Ferreira](https://bitbucket.org/drk4))
|
||||
* [EasyStar](http://easystarjs.com/) (by [Magnus Gustafsson](https://github.com/Borundin))
|
||||
* [ember.js](http://emberjs.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [EpicEditor](http://epiceditor.com/) (by [Boris Yankov](https://github.com/borisyankov))
|
||||
* [ES6-Promises](https://github.com/jakearchibald/ES6-Promises) (by [François de Campredon](https://github.com/fdecampredon/))
|
||||
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
/// <reference path="easystarjs.d.ts"/>
|
||||
|
||||
// For node.js compile using: tsc --module commonjs easystarjs-tests.ts
|
||||
// then run using: node easystarjs-tests.js
|
||||
import EasyStar = require('easystarjs');
|
||||
|
||||
var test = new EasyStar.js();
|
||||
|
||||
test.setGrid([
|
||||
[0, 0, 0, 1, 0],
|
||||
[0, 0, 0, 1, 0],
|
||||
[0, 0, 1, 1, 0],
|
||||
[0, 0, 0, 0, 0],
|
||||
[0, 0, 0, 1, 0]
|
||||
]);
|
||||
test.setAcceptableTiles([0]);
|
||||
test.setIterationsPerCalculation(1000);
|
||||
test.findPath(2, 0, 4, 4, function (path: EasyStar.Position[])
|
||||
{
|
||||
if (path == null)
|
||||
{
|
||||
console.log("No path found!");
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < path.length; i++)
|
||||
{
|
||||
var pos = path[i];
|
||||
console.log("%d, %d", pos.x, pos.y);
|
||||
}
|
||||
});
|
||||
|
||||
test.calculate();
|
||||
|
||||
/*
|
||||
Should log:
|
||||
|
||||
2, 0
|
||||
2, 1
|
||||
1, 1
|
||||
1, 2
|
||||
1, 3
|
||||
2, 3
|
||||
3, 3
|
||||
4, 3
|
||||
4, 4
|
||||
|
||||
*/
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// Type definitions for EasyStar.js 0.1.6
|
||||
// Project: http://easystarjs.com/
|
||||
// Definitions by: Magnus Gustafsson <https://github.com/borundin>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
/*
|
||||
easystarjs.d.ts may be freely distributed under the MIT license.
|
||||
*/
|
||||
|
||||
declare module "easystarjs"
|
||||
{
|
||||
class js
|
||||
{
|
||||
new (): js;
|
||||
setGrid(grid: number[][]): void;
|
||||
setAcceptableTiles(tiles: number[]): void;
|
||||
findPath(startX: number, startY: number, endX: number, endY: number, callback: (path: Position[]) => void): void;
|
||||
calculate(): void;
|
||||
setIterationsPerCalculation(iterations: number): void;
|
||||
avoidAdditionalPoint(x: number, y: number): void;
|
||||
stopAvoidingAdditionalPoint(x: number, y: number): void;
|
||||
stopAvoidingAllAdditionalPoints(): void;
|
||||
enableDiagonals(): void;
|
||||
disableDiagonals(): void;
|
||||
setTileCost(tileType: number, multiplicativeCost: number): void;
|
||||
}
|
||||
|
||||
interface Position
|
||||
{
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user