* 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)
| 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. |
no test coverage detected