dist/claygl.es.js
function (size, unitSize, color1, color2) {
        size = size || 512;
        unitSize = unitSize || 64;
        color1 = color1 || 'black';
        color2 = color2 || 'white';

        var repeat = Math.ceil(size / unitSize);

        var canvas = document.createElement('canvas');
        canvas.width = size;
        canvas.height = size;
        var ctx = canvas.getContext('2d');
        ctx.fillStyle = color2;
        ctx.fillRect(0, 0, size, size);

        ctx.fillStyle = color1;
        for (var i = 0; i < repeat; i++) {
            for (var j = 0; j < repeat; j++) {
                var isFill = j % 2 ? (i % 2) : (i % 2 - 1);
                if (isFill) {
                    ctx.fillRect(i * unitSize, j * unitSize, unitSize, unitSize);
                }
            }
        }

        var texture = new Texture2D({
            image: canvas,
            anisotropic: 8
        });

        return texture;
    }
function (size, unitSize, color1, color2) {
        size = size || 512;
        unitSize = unitSize || 64;
        color1 = color1 || 'black';
        color2 = color2 || 'white';

        var repeat = Math.ceil(size / unitSize);

        var canvas = document.createElement('canvas');
        canvas.width = size;
        canvas.height = size;
        var ctx = canvas.getContext('2d');
        ctx.fillStyle = color2;
        ctx.fillRect(0, 0, size, size);

        ctx.fillStyle = color1;
        for (var i = 0; i < repeat; i++) {
            for (var j = 0; j < repeat; j++) {
                var isFill = j % 2 ? (i % 2) : (i % 2 - 1);
                if (isFill) {
                    ctx.fillRect(i * unitSize, j * unitSize, unitSize, unitSize);
                }
            }
        }

        var texture = new Texture2D({
            image: canvas,
            anisotropic: 8
        });

        return texture;
    }
function ( size , unitSize , color1 , color2 ) { size = size || 512 ; unitSize = unitSize || 64 ; color1 = color1 || 'black' ; color2 = color2 || 'white' ; var repeat = Math . ceil ( size / unitSize ) ; var canvas = document . createElement ( 'canvas' ) ; canvas . width = size ; canvas . height = size ; var ctx = canvas . getContext ( '2d' ) ; ctx . fillStyle = color2 ; ctx . fillRect ( 0 , 0 , size , size ) ; ctx . fillStyle = color1 ; for ( var i = 0 ; i < repeat ; i ++ ) { for ( var j = 0 ; j < repeat ; j ++ ) { var isFill = j % 2 ? ( i % 2 ) : ( i % 2 - 1 ) ; if ( isFill ) { ctx . fillRect ( i * unitSize , j * unitSize , unitSize , unitSize ) ; } } } var texture = new Texture2D ( { image : canvas , anisotropic : 8 } ) ; return texture ; }
Create a chessboard texture
@param  {number} [size]
@param  {number} [unitSize]
@param  {string} [color1]
@param  {string} [color2]
@return {clay.Texture2D}
Create a chessboard texture