JSFiddle - React, Tailwind, and code Playground

by Darby Rathbone

JavaScript

var Canvas = function (w, h) {
    this.canvas = document.createElement('canvas');
    if (w) {
        this.canvas.width = w;
    }
    if (h) {
        this.canvas.height = h;
    }
    this.context = this.canvas.getContext('2d');
    this.addToDocument = function () {
        document.body.appendChild(this.canvas);
        return this.canvas;
    }
    return this;
}.bind(null);
var c = new Canvas(500,500);
c.addToDocument();