DOCTYPE html html xmlns http www w3 org 1999 xhtml lang en head title WebGL title meta charset utf 8 head body canvas id canvas width 640 height 480 Your browser doesn t appear to support the HTML5 b canvas b element canvas script use strict var canvas document getElementById canvas var gl canvas getContext webgl Enable scissoring operation and define the position and size of the scissoring area gl enable gl SCISSOR_TEST Important function drawRect x y width height color gl scissor x y width height gl clearColor color gl clear gl COLOR_BUFFER_BIT for let i 0 i 100 i const x rand 0 300 const y rand 0 150 const width rand 0 300 x const height rand 0 150 y drawRect x y width height rand 1 rand 1 rand 1 1 function rand min max if max undefined max min min 0 return Math random max min min script body html
nction drawRect x y width height color gl scissor x y width height gl clearColor color gl clear gl COLOR_BUFFER_BIT for let i 0 i 100 i const x rand 0 300 const y rand 0 150 const width rand 0 300 x const height rand 0 150 y drawRect x y width height rand 1 rand 1 rand 1 1 function rand min max if max undefined max min min 0 return Math random max min min script body html