Skip to content

lmlong-huynh/VueDrawingGrid

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

animated

VueDrawingGrid

A simple drawing grid using HTML5 canvas for Vue.js

Demo

animated

Requirements

Vue.js >= 3.0.0

Installation

npm i vue-drawing-grid

Usage

import{ VueDrawingGrid } from 'vue-drawing-grid';

If you want to pass a preloaded grid you can use the modelValue prop, or v-model:modelValue for two way binding. The model of the modelValue prop is

{ "y-x": {y: string, x:string, size: number, color: string} }

There is also a VueDrawingGridColorPicker component that can be imported, but is not neccessary.

import{ VueDrawingGrid,VueDrawingGridColorPicker } from 'vue-drawing-grid';
export default {
  name: 'App',
  components: { VueDrawingGrid, VueDrawingGridColorPicker }
}

<template>
  <div class="app">
    <vue-drawing-grid />
    <vue-drawing-grid-color-picker @color="color = $event" />
  </div>
</template>

There are also a few other props that can be used in VueDrawingGrid

    modelValue: {
      type: Object,
      default: null,
      // { "y-x": {y: string, x:string, size: number, color: string} }
    },
    mode: {
      type: String,
      default: 'Draw', // Draw, Delete
    },
    gridSize: {
      type: Number,
      default: 1000,
    },
    gridColor: {
      type: String,
      default: '#d9d9d9',
    },
    cellSize: {
      type: Number,
      default: 20,
    },
    color: {
      type: String,
      default: '#FF9595',
    },

VueDrawingGrid emit update event that contains the updated grid model

 <vue-drawing-grid @update="$event" />
 {
    gridSize: number,
    cellSize: number,
    cells: object, // { "y-x": {y: string, x:string, size: number, color: string} }
  }

About

A simple vue drawing grid using canvas

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published