source: imaps-frontend/node_modules/konva/README.md@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 8.0 KB
Line 
1<p align="center">
2 <img src="https://konvajs.org/android-chrome-192x192.png" alt="Konva logo" height="180" />
3</p>
4
5<h1 align="center">Konva</h1>
6
7[![Financial Contributors on Open Collective](https://opencollective.com/konva/all/badge.svg?label=financial+contributors)](https://opencollective.com/konva)
8[![npm version](https://badge.fury.io/js/konva.svg)](http://badge.fury.io/js/konva)
9[![Build Status](https://github.com/konvajs/konva/actions/workflows/test-browser.yml/badge.svg)](https://github.com/konvajs/konva/actions/workflows/test-browser.ym)
10[![Build Status](https://github.com/konvajs/konva/actions/workflows/test-node.yml/badge.svg)](https://github.com/konvajs/konva/actions/workflows/test-node.ym)[![CDNJS version](https://img.shields.io/cdnjs/v/konva.svg)](https://cdnjs.com/libraries/konva)
11
12Konva is an HTML5 Canvas JavaScript framework that enables high performance animations, transitions, node nesting, layering, filtering, caching, event handling for desktop and mobile applications, and much more.
13
14You can draw things onto the stage, add event listeners to them, move them, scale them, and rotate them independently from other shapes to support high performance animations, even if your application uses thousands of shapes. Served hot with a side of awesomeness.
15
16This repository began as a GitHub fork of [ericdrowell/KineticJS](https://github.com/ericdrowell/KineticJS).
17
18- **Visit:** The [Home Page](http://konvajs.org/) and follow on [Twitter](https://twitter.com/lavrton)
19- **Discover:** [Tutorials](http://konvajs.org/docs), [API Documentation](http://konvajs.org/api)
20- **Help:** [StackOverflow](http://stackoverflow.com/questions/tagged/konvajs), [Discord Chat](https://discord.gg/8FqZwVT)
21
22# Quick Look
23
24```html
25<script src="https://unpkg.com/konva@9/konva.min.js"></script>
26<div id="container"></div>
27<script>
28 var stage = new Konva.Stage({
29 container: 'container',
30 width: window.innerWidth,
31 height: window.innerHeight,
32 });
33
34 // add canvas element
35 var layer = new Konva.Layer();
36 stage.add(layer);
37
38 // create shape
39 var box = new Konva.Rect({
40 x: 50,
41 y: 50,
42 width: 100,
43 height: 50,
44 fill: '#00D2FF',
45 stroke: 'black',
46 strokeWidth: 4,
47 draggable: true,
48 });
49 layer.add(box);
50
51 // add cursor styling
52 box.on('mouseover', function () {
53 document.body.style.cursor = 'pointer';
54 });
55 box.on('mouseout', function () {
56 document.body.style.cursor = 'default';
57 });
58</script>
59```
60
61# Browsers support
62
63Konva works in all modern mobile and desktop browsers. A browser need to be capable to run javascript code from ES2015 spec. For older browsers you may need polyfills for missing functions.
64
65At the current moment `Konva` doesn't work in IE11 directly. To make it work you just need to provide some polyfills such as `Array.prototype.find`, `String.prototype.trimLeft`, `String.prototype.trimRight`, `Array.from`.
66
67# Debugging
68
69The Chrome inspector simply shows the canvas element. To see the Konva objects and their details, install the konva-dev extension at https://github.com/konvajs/konva-devtool.
70
71# Loading and installing Konva
72
73Konva supports UMD loading. So you can use all possible variants to load the framework into your project:
74
75### Load Konva via classical `<script>` tag from CDN:
76
77```html
78<script src="https://unpkg.com/konva@9/konva.min.js"></script>
79```
80
81### Install with npm:
82
83```bash
84npm install konva --save
85```
86
87```javascript
88// The modern way (e.g. an ES6-style import for webpack, parcel)
89import Konva from 'konva';
90```
91
92#### Typescript usage
93
94Add DOM definitions into your `tsconfig.json`:
95
96```
97{
98 "compilerOptions": {
99 "lib": [
100 "es6",
101 "dom"
102 ]
103 }
104}
105```
106
107### 3 Minimal bundle
108
109```javascript
110import Konva from 'konva/lib/Core';
111// Now you have a Konva object with Stage, Layer, FastLayer, Group, Shape and some additional utils function.
112// Also core currently already have support for drag&drop and animations.
113// BUT there are no shapes (rect, circle, etc), no filters.
114
115// but you can simply add anything you need:
116import { Rect } from 'konva/lib/shapes/Rect';
117// importing a shape will automatically inject it into Konva object
118
119var rect1 = new Rect();
120// or:
121var shape = new Konva.Rect();
122
123// for filters you can use this:
124import { Blur } from 'konva/lib/filters/Blur';
125```
126
127### 4 NodeJS env
128
129In order to run `konva` in nodejs environment you also need to install `canvas` package manually. Konva will use it for 2d canvas API.
130
131```bash
132npm install konva canvas
133```
134
135Then you can use the same Konva API and all Konva demos will work just fine. You just don't need to use `container` attribute in your stage.
136
137```js
138import Konva from 'konva';
139
140const stage = new Konva.Stage({
141 width: 500,
142 height: 500,
143});
144// then all regular Konva code will work
145```
146
147# Backers
148
149![https://simpleshow.com](https://avatars.githubusercontent.com/u/99720652?s=200&v=4 'https://simpleshow.com')
150![https://www.notably.ai/](https://avatars.githubusercontent.com/u/80046841?s=200&v=4 'https://www.notably.ai/')
151
152- [myposter GmbH](https://www.myposter.de/)
153- [queue.gg](https://queue.gg/)
154
155# Change log
156
157See [CHANGELOG.md](https://github.com/konvajs/konva/blob/master/CHANGELOG.md).
158
159## Building the Konva Framework
160
161To make a full build run `npm run build`. The command will compile all typescript files, combine then into one bundle and run minifier.
162
163## Testing
164
165Konva uses Mocha for testing.
166
167- If you need run test only one time run `npm run test`.
168- While developing it is easy to use `npm start`. Just run it and go to [http://localhost:1234/unit-tests.html](http://localhost:1234/unit-tests.html). The watcher will rebuild the bundle on any change.
169
170Konva is covered with hundreds of tests and well over a thousand assertions.
171Konva uses TDD (test driven development) which means that every new feature or bug fix is accompanied with at least one new test.
172
173## Generate documentation
174
175Run `npx gulp api` which will build the documentation files and place them in the `api` folder.
176
177# Pull Requests
178
179I'd be happy to review any pull requests that may better the Konva project,
180in particular if you have a bug fix, enhancement, or a new shape (see `src/shapes` for examples). Before doing so, please first make sure that all of the tests pass (`npm run test`).
181
182## Contributors
183
184### Financial Contributors
185
186Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/konva/contribute)]
187
188#### Individuals
189
190<a href="https://opencollective.com/konva"><img src="https://opencollective.com/konva/individuals.svg?width=890"></a>
191
192#### Organizations
193
194Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/konva/contribute)]
195
196<a href="https://opencollective.com/konva/organization/0/website"><img src="https://opencollective.com/konva/organization/0/avatar.svg"></a>
197<a href="https://opencollective.com/konva/organization/1/website"><img src="https://opencollective.com/konva/organization/1/avatar.svg"></a>
198<a href="https://opencollective.com/konva/organization/2/website"><img src="https://opencollective.com/konva/organization/2/avatar.svg"></a>
199<a href="https://opencollective.com/konva/organization/3/website"><img src="https://opencollective.com/konva/organization/3/avatar.svg"></a>
200<a href="https://opencollective.com/konva/organization/4/website"><img src="https://opencollective.com/konva/organization/4/avatar.svg"></a>
201<a href="https://opencollective.com/konva/organization/5/website"><img src="https://opencollective.com/konva/organization/5/avatar.svg"></a>
202<a href="https://opencollective.com/konva/organization/6/website"><img src="https://opencollective.com/konva/organization/6/avatar.svg"></a>
203<a href="https://opencollective.com/konva/organization/7/website"><img src="https://opencollective.com/konva/organization/7/avatar.svg"></a>
204<a href="https://opencollective.com/konva/organization/8/website"><img src="https://opencollective.com/konva/organization/8/avatar.svg"></a>
205<a href="https://opencollective.com/konva/organization/9/website"><img src="https://opencollective.com/konva/organization/9/avatar.svg"></a>
Note: See TracBrowser for help on using the repository browser.