diff --git a/easystarjs/README.md b/easystarjs/README.md new file mode 100755 index 0000000000..0f3b110f26 --- /dev/null +++ b/easystarjs/README.md @@ -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 +/// + +// 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. \ No newline at end of file diff --git a/easystarjs/easystarjs-tests.ts b/easystarjs/easystarjs-tests.ts new file mode 100755 index 0000000000..a63d4ea0f1 --- /dev/null +++ b/easystarjs/easystarjs-tests.ts @@ -0,0 +1,47 @@ +/// + +// 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 + +*/ \ No newline at end of file diff --git a/easystarjs/easystarjs.d.ts b/easystarjs/easystarjs.d.ts new file mode 100755 index 0000000000..7640b1a8b8 --- /dev/null +++ b/easystarjs/easystarjs.d.ts @@ -0,0 +1,34 @@ +// Type definitions for EasyStar.js 0.1.6 +// Project: http://easystarjs.com/ +// Definitions by: Magnus Gustafsson +// 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; + } +} + + \ No newline at end of file