html head head body canvas id canvas width 640 height 480 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 abc A gl enable gl SCISSOR_TEST function drawRect x y width height color abc B 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
or 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