Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/component/pipe

Canvas pipe connection between two points
https://github.com/component/pipe

Last synced: 13 days ago
JSON representation

Canvas pipe connection between two points

Awesome Lists containing this project

README

        

# pipe

Canvas "pipe" between two points.

## Installation

$ component install component/pipe

## Example

```html

var raf = require('raf');
var pipe = require('pipe');
var canvas = document.querySelector('canvas');
var ctx = canvas.getContext('2d');

var a = { x: 500, y: 300 };
var b = { x: 500, y: 500 };
var g = 0;
var x;
var y;

canvas.onmousemove = function(e){
x = e.offsetX;
y = e.offsetY;
};

function draw(){
ctx.strokeStyle = '#ddd';
canvas.width = canvas.width;
b.x = x;
b.y = y;
pipe(ctx, a, b);
}

function animate() {
raf(animate);
draw();
}

animate();

```

## License

MIT