ColorTexture constructor

ColorTexture(
  1. Color color, {
  2. int width = 1,
  3. int height = 1,
})

A texture that holds a single color. By default it creates a 1x1 texture.

Implementation

ColorTexture(Color color, {int width = 1, int height = 1})
  : super(
      Uint32List.fromList(
        List.filled(
          width * height,
          // Convert to a 32 bit value representing this color.
          (color.a * 255).round() << 24 |
              (color.r * 255).round() << 16 |
              (color.g * 255).round() << 8 |
              (color.b * 255).round(),
        ),
      ).buffer.asByteData(),
      width: width,
      height: height,
      format: PixelFormat.bgra8888,
    );