q5play
    Preparing search index...

    Function colorMode

    • 🎨 Sets the color mode for the sketch, which changes how colors are interpreted and displayed.

      Color gamut is 'display-p3' by default, if the device supports HDR.

      The default color mode is RGB in float format.

      Parameters

      • mode: "rgb" | "oklch"

        color mode

      • format: 1 | 255

        color format (1 for float, 255 for integer)

      • Optionalgamut: "srgb" | "display-p3"

        color gamut

      Returns void

      await Canvas(200);

      colorMode(RGB, 1);
      fill(1, 0, 0);
      rect(-100, -100, 66, 200);
      fill(0, 1, 0);
      rect(-34, -100, 67, 200);
      fill(0, 0, 1);
      rect(33, -100, 67, 200);
      await Canvas(200);

      colorMode(OKLCH);

      fill(0.25, 0.15, 0);
      rect(-100, -100, 100, 200);

      fill(0.75, 0.15, 0);
      rect(0, -100, 100, 200);