by over-engineer

GitHub whiteboard

GitHub GitHub last commit Demo

🎨 HTML5 canvas real-time drawing using

Table of Contents

πŸ–Œ What is this?

This is a simplified version of the JavaScript code I use for a sketch guessing multiplayer game I'm working on. Keep in mind that it's still under development as I'm experimenting with different ways to build this. Still, this could be a nice start for similar projects.

πŸ“¦ Installation

  1. Include in your client-side code

    <script src=""
  2. Include this library in your client-side code

    <script src="" 
  3. Create a Whiteboard instance using new Whiteboard(), passing your canvas, your socket and optionally a default color and thickness.

    For example:

    const canvas = document.querySelector('canvas');
    const whiteboard = new Whiteboard(canvas, socket);
  4. For the server-side, check the /demo/backend directory

πŸŽ‰ Demo

Check out the demo (open the console!)

You can also:


…or do it yourself:

  1. Make sure you have Node.js installed.

  2. Clone this repository

    $ git clone
    $ cd ./
  3. Install the dependencies

    $ npm install
  4. Start the server

    $ npm start
  5. Go to localhost:3000

πŸ“š Documentation

The demo has the bare minimum functionality to keep it as simple as possible.

In a real-world scenario you would have to customize the color, the thickness of the line, download drawings etc

These are the public methods you'll find in the /lib/whiteboard.js file:

Method Explanation whiteboard.color = newValue Sets the line color to the given value whiteboard.color Returns the current color of the line whiteboard.thickness = newValue Sets the line thickness to the given value whiteboard.thickness Returns the current thickness of the line whiteboard.increaseThickness(step) Increases the thickness of the line by the given step whiteboard.decreaseThickness(step) Decreases the thickness of the line by the given step Exports the canvas drawing as an image file and saves it with the given name

In the above table whiteboard is an instance of Whiteboard

πŸ—„ Dependencies

πŸ“– License

The MIT License, check the LICENSE file.