All Projects → konvajs → Vue Konva

konvajs / Vue Konva

Licence: mit
Vue & Canvas - JavaScript library for drawing complex canvas graphics using Vue.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Vue Konva

Konva
Konva.js is an HTML5 Canvas JavaScript framework that extends the 2d context by enabling canvas interactivity for desktop and mobile applications.
Stars: ✭ 6,985 (+924.19%)
Mutual labels:  graphics, shape, canvas
Gcanvas
A lightweight cross-platform graphics rendering engine. (超轻量的跨平台图形引擎) https://alibaba.github.io/GCanvas
Stars: ✭ 1,705 (+150%)
Mutual labels:  graphics, canvas
G2
📊 A highly interactive data-driven visualization grammar for statistical charts.
Stars: ✭ 11,020 (+1515.84%)
Mutual labels:  graphics, canvas
Wechart
Create all the [ch]arts by cax or three.js - Cax 和 three.js 创造一切图[表]
Stars: ✭ 152 (-77.71%)
Mutual labels:  graphics, canvas
Core
A canvas-based super high performant grid renderer API
Stars: ✭ 857 (+25.66%)
Mutual labels:  graphics, canvas
Lowpoly
Lowpoly image generator
Stars: ✭ 83 (-87.83%)
Mutual labels:  graphics, canvas
Plutovg
Tiny 2D vector graphics library in C
Stars: ✭ 141 (-79.33%)
Mutual labels:  graphics, canvas
Mylittlecanvas
🎨Need to create a custom view ? You don't know how to use Canvas, use MyLittleCanvas instead !
Stars: ✭ 870 (+27.57%)
Mutual labels:  shape, canvas
Picasso
Picasso is a high quality 2D vector graphic rendering library. It support path , matrix , gradient , pattern , image and truetype font.
Stars: ✭ 205 (-69.94%)
Mutual labels:  graphics, canvas
Gooey React
The gooey effect for React, used for shape blobbing / metaballs (0.5 KB) 🧽
Stars: ✭ 219 (-67.89%)
Mutual labels:  graphics, shape
Rough
Create graphics with a hand-drawn, sketchy, appearance
Stars: ✭ 16,472 (+2315.25%)
Mutual labels:  graphics, canvas
React Native Canvas
A Canvas component for React Native
Stars: ✭ 736 (+7.92%)
Mutual labels:  graphics, canvas
Mojs
The motion graphics toolbelt for the web
Stars: ✭ 17,189 (+2420.38%)
Mutual labels:  graphics, shape
Hilo3d
Hilo3d, a WebGL Rendering Engine.
Stars: ✭ 123 (-81.96%)
Mutual labels:  graphics, canvas
Ng2 Konva
Angular & Canvas - JavaScript library for drawing complex canvas graphics using Angular.
Stars: ✭ 78 (-88.56%)
Mutual labels:  shape, canvas
Sprite Wxapp
spritejs 小程序版
Stars: ✭ 138 (-79.77%)
Mutual labels:  graphics, canvas
Mesh.js
A graphics system born for visualization 😘.
Stars: ✭ 156 (-77.13%)
Mutual labels:  graphics, canvas
pikaso
Seamless and headless HTML5 Canvas library
Stars: ✭ 23 (-96.63%)
Mutual labels:  canvas, shape
Pts
A library for visualization and creative-coding
Stars: ✭ 4,628 (+578.59%)
Mutual labels:  graphics, canvas
Freedrawview
A View on which you can freely draw, customizing paint width, alpha and color, and take a screenshot of the content. Useful for note apps, signatures or free hand writing.
Stars: ✭ 627 (-8.06%)
Mutual labels:  canvas

Vue Konva

Version License

ReactKonva Logo

Vue Konva is a JavaScript library for drawing complex canvas graphics using Vue.

It provides declarative and reactive bindings to the Konva Framework.

All vue-konva components correspond to Konva components of the same name with the prefix 'v-'. All the parameters available for Konva objects can add as config in the prop for corresponding vue-konva components.

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

To get more info about Konva you can read Konva Overview.

Documentation / live edit

See Tutorials page

Quick Start

Vue.js version 2.4+ is required.

1 Install via npm

npm install vue-konva konva --save

2 Import and use VueKonva

import Vue from 'vue';
import VueKonva from 'vue-konva'

Vue.use(VueKonva)

3 Reference in your component templates

<template>
  <v-stage :config="configKonva">
    <v-layer>
      <v-circle :config="configCircle"></v-circle>
    </v-layer>
  </v-stage>
</template>
<script>
export default {
  data() {
    return {
      configKonva: {
        width: 200,
        height: 200
      },
      configCircle: {
        x: 100,
        y: 100,
        radius: 70,
        fill: "red",
        stroke: "black",
        strokeWidth: 4
      }
    };
  }
};

</script>

Or use a CDN

<html>
  <head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
    <meta http-equiv='x-ua-compatible' content='ie=edge'>
  </head>
  <body>
    <div id='app'>
      <v-stage ref="stage" :config="configKonva">
        <v-layer ref="layer">
          <v-circle :config="configCircle"></v-circle>
        </v-layer>
      </v-stage>
    </div>
    <!--1. Link Vue Javascript & Konva-->
    <script src='https://unpkg.com/vue/dist/vue.js'></script>
    <script src='https://unpkg.com/konva/konva.js'></script>
    <!--2. Link VueKonva Javascript -->
    <script src='https://unpkg.com/vue-konva/umd/vue-konva.min.js'></script>
    <script>
      // 3. Create the Vue instance
      new Vue({
        el: '#app',
        data: {
          configKonva: {
            width: 200,
            height: 200
          },
          configCircle: {
            x: 100,
            y: 100,
            radius: 70,
            fill: 'red',
            stroke: 'black',
            strokeWidth: 4
          }
        }
      })
    </script>
  </body>
</html>

Core API

Getting reference to Konva objects

You can use ref feature from vue.

<template>
<v-stage ref="stage">
  <v-layer ref="layer">
    <v-rect
      ref="rect"
    />
  </v-layer>
</v-stage>
</template>

<script>
const width = window.innerWidth;
const height = window.innerHeight;

export default {
  mounted() {
    const stage = this.$refs.stage.getNode();
    const layer = this.$refs.layer.getNode();
    const rect = this.$refs.rect.getNode();
  }
};
</script>

Strict mode

By default vue-konva works in "non-strict" mode. If you changed a property manually (or by user action like drag&drop) properties of the node will be not matched with properties passed as config. vue-konva updates ONLY changed properties.

In strict mode vue-konva will update all properties of the nodes to the values that you provided in config, no matter changed they or not.

You should decide what mode is better in your actual use case.

To enable strict mode pass __useStrictMode attribute:

<v-rect :config="{}" __useStrictMode >

Configurable prefix

By default vue-konva is using v- prefix for all components.

You can use your own prefix if default one conflicts with some other libs or your components.

import Vue from 'vue';
import VueKonva from 'vue-konva'

Vue.use(VueKonva, { prefix: 'Konva'});

// in template:
<konva-stage ref="stage" :config="stage">

Change log

The change log can be found on the Releases page.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].