MCPcopy
hub / github.com/jimp-dev/jimp / setPixelColor

Method setPixelColor

packages/core/src/index.ts:646–659  ·  view source on GitHub ↗

* Sets the hex colour value of a pixel * * @param hex color to set * @param x the x coordinate * @param y the y coordinate * * @example * ```ts * import { Jimp } from "jimp"; * * const image = new Jimp({ width: 3, height: 3, color: 0xffffffff });

(hex: number, x: number, y: number)

Source from the content-addressed store, hash-verified

644 * ```
645 */
646 setPixelColor(hex: number, x: number, y: number) {
647 if (
648 typeof hex !== "number" ||
649 typeof x !== "number" ||
650 typeof y !== "number"
651 ) {
652 throw new Error("hex, x and y must be numbers");
653 }
654
655 const idx = this.getPixelIndex(x, y);
656 this.bitmap.data.writeUInt32BE(hex, idx);
657
658 return this;
659 }
660
661 /**
662 * Determine if the image contains opaque pixels.

Callers 2

scan.test.tsFile · 0.80
fisheyeFunction · 0.80

Calls 1

getPixelIndexMethod · 0.95

Tested by

no test coverage detected