Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/jimeh87/pencil

A Canvas mouse / touch detection directive for Angular. It uses Bresenham's Line Drawing Algorithm to insure a smooth draw.
https://github.com/jimeh87/pencil

angular canvas library

Last synced: about 1 month ago
JSON representation

A Canvas mouse / touch detection directive for Angular. It uses Bresenham's Line Drawing Algorithm to insure a smooth draw.

Awesome Lists containing this project

README

        

# Pencil

A Canvas mouse / touch detection directive for Angular. It uses Bresenham's Line Drawing Algorithm to ensure a smooth draw.

## Demo

[StackBlitz Demo](https://stackblitz.com/edit/pencil-sample)

## Latest Version

@jimeh87/[email protected]

## Setup

Add dependency `@jimeh87/pencil`

npm:
```shell
npm install --save @jimeh87/pencil
```

yarn:
```shell
yarn add @jimeh87/pencil
```

Add the `PencilModule` to your application module

```js
import { PencilModule } from '@jimeh87/pencil';

@NgModule({
...
imports: [PencilModule, ...],
...
})
export class YourAppModule {
}
```

Add the directive to your canvas:
```html

```

```js
export class AppComponent {

onDraw(point: { x: number, y: number }) {
console.log(point);
}

}
```

## API

### Pencil Directive

#### Selector
`[jrPencil]`

##### Properties
| Property | Description | Example |
|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
| @Output('jrPencil') pencilPositionEvent = new EventEmitter<{ x: number, y: number }>(); | Emits mouse coordinates when `mousedown` or `touchstart` until `mouseup` or `touchend` | ``` ``` |
| @Output() pencilUp = new EventEmitter(); | Emits event when `mouseup` or `touchend` | ``` ``` |
| @Input() pencilDisabled = false; | disables pencil directive | ``` ``` |

## Usage

* [https://gameoflife.xyz](https://gameoflife.xyz)

## Development

### Publishing

Run `yarn build` and then in `./dist/pencil` run `yarn publish`