Merge pull request #1657 from Borundin/easystarjs

Added type definitions for EasyStar.js 0.1.6
This commit is contained in:
Basarat Ali Syed
2014-02-08 10:15:27 +11:00
3 changed files with 82 additions and 0 deletions
+1
View File
@@ -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/))
+47
View File
@@ -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
*/
Vendored Executable
+34
View File
@@ -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;
}
}