Socket
Socket
Sign inDemoInstall

canvas-grid

Package Overview
Dependencies
90
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    canvas-grid

draw canvas grid and react to events


Version published
Weekly downloads
3
increased by50%
Maintainers
1
Install size
3.00 MB
Created
Weekly downloads
 

Readme

Source

Canvas-grid

NPM

Draw a grid on canvas and be able to interact with rows, and columns as well as get data about the grid.

Usage


var CanvasGrid = require('canvas-grid');

var cvs = document.getElementById('grid');
var grid = new CanvasGrid(cvs, {
  borderColor: '#777'
});

var activeColor = '#ff0beb';

grid.drawMatrix({
  x: 16,
  y: 4
});

cvs.addEventListener('click', function(ev) {
  if (ev.gridInfo.color.hex !== activeColor) {
    grid.fillCell(ev.gridInfo.x, ev.gridInfo.y, activeColor);
  } else {
    grid.clearCell(ev.gridInfo.x, ev.gridInfo.y);
  }
});
  

Available Methods:

  • drawRow: args[y axis, # of columns, width of cells];
  • drawMatrix: args[Object with attrs "x"(# of columns) & "y"(# of rows)]
  • fillCell: args[columnNumber, rowNumber, color(string, hex or rgba)]
  • clearCell: args[columnNumber, rowNumber]

Example

http://davejustice.com/canvas-grid

License

MIT

Keywords

FAQs

Last updated on 02 Oct 2014

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc