{"version":3,"sources":["https://lively-kernel.org/lively4/BP2019RH1/scratch/individualsAsPoints/regl-basic.js"],"names":["regl","drawTriangle","frag","vert","attributes","position","uniforms","color","prop","count","frame","time","clear","depth","Math","cos","sin"],"mappings":";;;;;;AAEOA,U;;;;;;;;;;;;;;;;;;;;AAEP;AACA,YAAMC,eAAeD,KAAK;;AAExB;AACA;AACAE,cAAO;;;;;MAJiB;;AAWxBC,cAAO;;;;;MAXiB;;AAkBxB;AACAC,oBAAY;AACV;AACAC,oBAAU;AACR,WAAC,CAAC,CAAC,CAAF,EAAK,CAAC,CAAN,CAAD,EAAa;AACb,WAAC,CAAD,EAAI,CAAC,CAAL,CADA,EACY;AACZ,WAAC,CAAD,EAAK,CAAL,CAFA;AAGF;AACA;AAPU,SAnBY;;AA6BxBC,kBAAU;AACR;AACAC,iBAAOP,KAAKQ,IAAL,CAAU,OAAV;AAFC,SA7Bc;;AAkCxB;AACAC,eAAO;AAnCiB;;AAsC1B;AAtCqB,OAArB,C;;;;;;;;;;;;;AAuCAT,WAAKU,KAAL,CAAW,CAAC,EAACC,IAAD,EAAD,KAAY;AACrB;AACAX,aAAKY,KAAL,CAAW;AACTL,iBAAO,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CADE;AAETM,iBAAO;AAFE;;AAKX;AALA,UAMAZ,aAAa;AACXM,iBAAO,CACLO,KAAKC,GAAL,CAASJ,OAAO,KAAhB,CADK,EAELG,KAAKE,GAAL,CAASL,OAAO,MAAhB,CAFK,EAGLG,KAAKC,GAAL,CAASJ,OAAO,KAAhB,CAHK,EAIL,CAJK;AADI,SAAb;AAQD,OAhBD","file":"regl-basic.js","sourcesContent":["// Calling the regl module with no arguments creates a full screen canvas and\n// WebGL context, and then uses this context to initialize a new REGL instance\nimport regl from \"src/external/regl.js\"\n\n// Calling regl() creates a new partially evaluated draw command\nconst drawTriangle = regl({\n\n  // Shaders in regl are just strings.  You can use glslify or whatever you want\n  // to define them.  No need to manually create shader objects.\n  frag: `\n    precision mediump float;\n    uniform vec4 color;\n    void main() {\n      gl_FragColor = color;\n    }`,\n\n  vert: `\n    precision mediump float;\n    attribute vec2 position;\n    void main() {\n      gl_Position = vec4(position, 0, 1);\n    }`,\n\n  // Here we define the vertex attributes for the above shader\n  attributes: {\n    // regl.buffer creates a new array buffer object\n    position: // regl.buffer([\n      [[-2, -2],   // no need to flatten nested arrays, regl automatically\n      [4, -2],    // unrolls them into a typedarray (default Float32)\n      [4,  4]]\n    // ])\n    // regl automatically infers sane defaults for the vertex attribute pointers\n  },\n\n  uniforms: {\n    // This defines the color of the triangle to be a dynamic variable\n    color: regl.prop('color')\n  },\n\n  // This tells regl the number of vertices to draw in this command\n  count: 3\n})\n\n// regl.frame() wraps requestAnimationFrame and also handles viewport changes\nregl.frame(({time}) => {\n  // clear contents of the drawing buffer\n  regl.clear({\n    color: [0, 0, 0, 0],\n    depth: 1\n  })\n\n  // draw a triangle using the command defined above\n  drawTriangle({\n    color: [\n      Math.cos(time * 0.001),\n      Math.sin(time * 0.0008),\n      Math.cos(time * 0.003),\n      1\n    ]\n  })\n})"]}