q5play
    Preparing search index...

    Function get

    • 🌆 Retrieves a subsection of an image or canvas as a new Q5 Image or the color of a pixel in the image or canvas.

      If only x and y are specified, this function returns the color of the pixel at the given coordinate in [R, G, B, A] array format. If loadPixels has never been run, it's run by this function.

      If you make changes to the canvas or image, you must call loadPixels before using this function to get current color data.

      Not applicable to WebGPU canvases.

      Parameters

      • x: number
      • y: number
      • Optionalw: number

        width of the area, default is 1

      • Optionalh: number

        height of the area, default is 1

      Returns Image | number[]

      await Canvas(200);

      let logo = await load('/q5js_logo.avif');

      let cropped = logo.get(256, 256, 512, 512);
      image(cropped, -100, -100, 200, 200);