Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/konvajs/ng2-konva

Angular & Canvas - JavaScript library for drawing complex canvas graphics using Angular.
https://github.com/konvajs/ng2-konva

angular angular2 canvas canvas-animation konva konvajs ng2 shape

Last synced: 4 days ago
JSON representation

Angular & Canvas - JavaScript library for drawing complex canvas graphics using Angular.

Awesome Lists containing this project

README

        

# ng2-konva


Version


License

![Ng2Konva Logo](n2-konva.png)

**ng2-konva** is a JavaScript library for drawing complex canvas graphics using Angular.

It provides declarative and reactive bindings to the [Konva Framework](http://konvajs.github.io/).

All `ng2-konva` components correspond to `Konva` components of the same name with the prefix 'ko-'. All the parameters available for `Konva` objects can be passed as `config` to the corresponding `ng2-konva` components.

Core shapes are: ko-stage, ko-layer, ko-rect, ko-circle, ko-ellipse, ko-line, ko-image, ko-text, ko-text-path, ko-star, ko-label, SVG Path, ko-regular-polygon.
Also you can create custom shape.

To get more info about `Konva` you can read [Konva Overview](http://konvajs.github.io/docs/overview.html).

## Documentation

[http://rafaelescala.com/ng2-konva/](http://rafaelescala.com/ng2-konva/)

## Installation

To install this library, run:

```bash
$ npm install ng2-konva --save
```

`ng2-konva` components are all standalone. There are two components you will need to import: `CoreShapeComponent` and `StageComponent`

```typescript
import { Component } from '@angular/core';
import { StageConfig } from 'konva/lib/Stage';
import { CircleConfig } from 'konva/lib/shapes/Circle';
import {
CoreShapeComponent,
NgKonvaEventObject,
StageComponent,
} from 'ng2-konva';

@Component({
selector: 'app-circle-example',
template: `









`,
standalone: true,
imports: [StageComponent, CoreShapeComponent],
})
export class CircleExampleComponent {
public configStage: Partial = {
width: 200,
height: 500,
};
public configCircle: CircleConfig = {
x: 100,
y: 100,
radius: 70,
fill: 'red',
stroke: 'black',
strokeWidth: 4,
};

public handleClick(event: NgKonvaEventObject): void {
console.log('Hello Circle', event);
}
}
```

## Demo
You can find more examples in the demo project located in `projects/demo`.

## Related repositories

* [react-konva](https://github.com/lavrton/react-konva) - React + Konva
* [vue-konva](http://rafaelescala.com/vue-konva-doc/) - Vue + Konva

## License

MIT © [Rafael Escala](mailto:[email protected])