Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 956 Bytes

README.md

File metadata and controls

33 lines (26 loc) · 956 Bytes

avoid.js

Tiny C/JavaScript wrapper around libavoid.

Example

First, include the libs.

<!-- emscripten-compiled libavoid with a C wrapper -->
<script type="text/javascript" src="avoid.bin.js"></script>
<!-- JavaScript interface to use avoid.bin.js painlessly -->
<script type="text/javascript" src="avoid.js"></script>

Then, add some javascript.

var router = new Avoid.Router();
var shape = new Avoid.Shape(router, 20, 35, 40, 12);
var connection = Avoid.Connection.connectPoints(router, 1.2, 0.5, 3, 4);

var route;

router.processTransaction();
route = connection.displayRoute();
document.write(JSON.stringify(route) + "<br/>"); // [[1.2,0.5],[3,4]]

router.moveShapeRect(shape, 1, 0.5, 3, 4);

router.processTransaction();
route = connection.displayRoute();
document.write(JSON.stringify(route) + "<br/>"); // [[1.2,0.5],[3,0.5],[3,4]]