let canvas = document.createElement("canvas");
canvas.width = 150;
canvas.height = 150;
let ctx = canvas.getContext('webgl2');
let shader = ctx.createShader(35633);
ctx.shaderSource(shader,'\n        attribute vec4 aPosition;\n        attribute vec4 aColor;\n        uniform vec4 anOffset;\n        varying vec4 vColor;\n        void main(void) {\n          gl_Position = aPosition + anOffset;\n          vColor = aColor;\n        }\n      ');
ctx.compileShader(shader);
let shaderParam1 = ctx.getShaderParameter(shader, 35713);
let shader2 = ctx.createShader(35632);
ctx.shaderSource(shader2,'\n        precision mediump float;\n        varying vec4 vColor;\n        void main(void) {\n          gl_FragColor = vColor;\n        }\n      ');
ctx.compileShader(shader2);
let shaderParam2 =  ctx.getShaderParameter(shader2, 35713);
let program = ctx.createProgram();
ctx.attachShader(program, shader);
ctx.attachShader(program, shader2);
ctx.linkProgram(program);
let programParam1 = ctx.getProgramParameter(program, 35714);
let buffer1 = ctx.createBuffer();
ctx.bindBuffer(34962, buffer1);
var bl_27 = [0, 0.5, 0.699999988079071, -0.6000000238418579, -0.4000000059604645, -0.800000011920929];

var bl_0 = [0.30000001192092896, 0.699999988079071, 0, 1, 0.10000000149011612, 0, 0.8999999761581421, 1, 0.8999999761581421, 0, 0, 1];

let Float32Array1 = new Float32Array(bl_27);
ctx.bufferData(34962, Float32Array1, 35044);
let buffer2 = ctx.createBuffer();
ctx.bindBuffer(34962, buffer2);
let Float32Array2 = new Float32Array(bl_0);
ctx.bufferData(34962, Float32Array2, 35044);
let attribLocationAPosition = ctx.getAttribLocation(program, 'aPosition');
let attribLocationAColor = ctx.getAttribLocation(program, 'aColor');
ctx.bindBuffer(34962, buffer1);
ctx.vertexAttribPointer(0, 2, 5126, false, 0, 0);
ctx.enableVertexAttribArray(0);
ctx.bindBuffer(34962, buffer2);
ctx.vertexAttribPointer(1, 4, 5126, false, 0, 0);
ctx.enableVertexAttribArray(1);
ctx.useProgram(program);
let webglUniformLocation = ctx.getUniformLocation(program, 'anOffset');
ctx.uniform4fv(webglUniformLocation, [0.2, 0, 0, 0])
ctx.drawArrays(5,0,3)
let unint8Array = new Uint8Array(90000);
ctx.readPixels(50, 0, 100, 128, 6408, 5121, unint8Array);
console.log(unint8Array+'')

var compressString = function (S) {
    let nums = S.split(",")
    let str = ''
    let i = 0
    while (i < nums.length) {
        let j = i + 1
        while (nums[i] == nums[j]) {
            j++
        }
        if ((j - i) !== 1) {
            str = str + '|' + nums[i] + '-' + (j - i)
        }else{
            str = str + '|' + nums[i]
        }
        i = j
    }
    res = str.length >= S.length ? S : str
    return res
};

console.log(compressString(unint8Array+''))


