mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-05-26 06:04:35 +00:00
Added type definitions for EasyStar.js 0.1.6
This commit is contained in:
61
easystarjs/README.md
Executable file
61
easystarjs/README.md
Executable file
@@ -0,0 +1,61 @@
|
||||
easystarjs.d.ts
|
||||
===========
|
||||
|
||||
This is a typescript definitions file for EasyStar.js located here: https://github.com/prettymuchbryce/easystarjs
|
||||
Main site: http://easystarjs.com/
|
||||
|
||||
Basic Usage
|
||||
==========
|
||||
|
||||
Import Statements
|
||||
-----------------
|
||||
|
||||
Reference the easystarjs.d.ts file in your project and include the following import statement
|
||||
|
||||
```typescript
|
||||
/// <reference path="easystarjs.d.ts" />
|
||||
|
||||
// Include the following import
|
||||
import EasyStar = require("easystarjs");
|
||||
```
|
||||
|
||||
See tests for further details on how to use this library.
|
||||
|
||||
Change Log
|
||||
==========
|
||||
|
||||
1.0 2014/02/02
|
||||
---------------
|
||||
* First version for EasyStar.js 0.1.6
|
||||
|
||||
|
||||
License
|
||||
=======
|
||||
|
||||
easystarjs.d.ts Copyright (c) 2014 Magnus Gustafsson http://github.com/borundin/easystarjs.d.ts
|
||||
This definitions file is for EasyStar.js ->
|
||||
https://github.com/prettymuchbryce/easystarjs
|
||||
|
||||
|
||||
|
||||
EasyStar.js Copyright (c) 2012-2013 Bryce Neal
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
47
easystarjs/easystarjs-tests.ts
Executable file
47
easystarjs/easystarjs-tests.ts
Executable 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
|
||||
|
||||
*/
|
||||
34
easystarjs/easystarjs.d.ts
vendored
Executable file
34
easystarjs/easystarjs.d.ts
vendored
Executable 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user