q5play
    Preparing search index...

    Function createFrameShader

    • ⚡ Creates a shader that q5 can use to draw frames.

      Use this function to customize a copy of the default frame shader.

      Parameters

      • code: string

      Returns GPUShaderModule

      await Canvas(200, 400);
      stroke(1);
      strokeWeight(8);
      strokeCap(PROJECT);

      let boxy = createFrameShader(`
      @fragment
      fn fragMain(f: FragParams) -> @location(0) vec4f {
      let x = sin(f.texCoord.y * 4 + q.time * 0.002);
      let y = cos(f.texCoord.x * 4 + q.time * 0.002);
      let uv = f.texCoord + vec2f(x, y);
      return textureSample(tex, samp, uv);
      }`);

      q5.draw = function () {
      line(mouseX, mouseY, pmouseX, pmouseY);
      mouseIsPressed ? resetShaders() : shader(boxy);
      };