Skip to content
This repository

Canvas2D API in WebGL

branch: transparency

This branch is 0 commits ahead and 84 commits behind master

Fetching latest commit…


Cannot retrieve the latest commit at this time

Octocat-spinner-32 LICENSE
Octocat-spinner-32 example.html
Octocat-spinner-32 webgl-2d.js


HTML5 Canvas2D API in WebGL.


This project aims to be a complete port of the Canvas2D API implemented in a WebGL context. WebGL-2D is a proof of concept and attempts to ascertain performance improvements over Canvas2D.

It should allow most Canvas2D applications to be switched to a WebGL context.

Switching your Canvas2D sketch to a WebGL2D is very simple and only requires one additional line of code:

var cvs = document.getElementById("myCanvas");

WebGL2D.enable(cvs); // adds "webgl-2d" context to cvs

var ctx = cvs.getContext("webgl-2d"); // easily switch between "webgl-2d" and "2d" contexts

Supported Canvas2D Features

WebGL-2D is a work in progress and currently supports a very small subset of the Canvas2D API.

  • strokeStyle
  • fillStyle
  • fillRect
  • translate
  • rotate
  • scale
  • save
  • restore
Something went wrong with that request. Please try again.