drawPixel function

Image drawPixel (
  1. Image image,
  2. int x,
  3. int y,
  4. int color,
  5. [int opacity = 0xff]
)

Draw a single pixel into the image, applying alpha and opacity blending.

Implementation

Image drawPixel(Image image, int x, int y, int color, [int opacity = 0xff]) {
  if (image.boundsSafe(x, y)) {
    var pi = y * image.width + x;
    var dst = image[pi];
    image[pi] = alphaBlendColors(dst, color, opacity);
  }
  return image;
}