D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
tmcw
Full window
Github gist
Colorize Alpha, Canvas
<!DOCTYPE html> <html> <head> <title></title> <link rel='stylesheet' type='text/css' href='' /> <meta http-equiv='content-type' content='text/html; charset=utf-8' /> </head> <body> <canvas id='c'></canvas> <script src='index.js'></script> <script> var c = document.getElementById('c'); c.width = c.height = 500; var ctx = c.getContext('2d'); for (var i = 0; i < 100; i++) { ctx.globalAlpha = i / 300; ctx.fillRect(i, i * 2, 100, 100); } colorizeAlpha(c, [[255, 0, 0], [255, 255, 0], [0, 255, 0], [0, 255, 255], [255, 0, 0], [255, 0, 255]]); </script> </body> </html>