(p5, fn)
| 13 | import { Framebuffer } from '../webgl/p5.Framebuffer'; |
| 14 | |
| 15 | function image(p5, fn){ |
| 16 | /** |
| 17 | * Creates a new <a href="#/p5.Image">p5.Image</a> object. |
| 18 | * |
| 19 | * `createImage()` uses the `width` and `height` parameters to set the new |
| 20 | * <a href="#/p5.Image">p5.Image</a> object's dimensions in pixels. The new |
| 21 | * <a href="#/p5.Image">p5.Image</a> can be modified by updating its |
| 22 | * <a href="#/p5.Image/pixels">pixels</a> array or by calling its |
| 23 | * <a href="#/p5.Image/get">get()</a> and |
| 24 | * <a href="#/p5.Image/set">set()</a> methods. The |
| 25 | * <a href="#/p5.Image/loadPixels">loadPixels()</a> method must be called |
| 26 | * before reading or modifying pixel values. The |
| 27 | * <a href="#/p5.Image/updatePixels">updatePixels()</a> method must be called |
| 28 | * for updates to take effect. |
| 29 | * |
| 30 | * Note: The new <a href="#/p5.Image">p5.Image</a> object is transparent by |
| 31 | * default. |
| 32 | * |
| 33 | * @method createImage |
| 34 | * @param {Integer} width width in pixels. |
| 35 | * @param {Integer} height height in pixels. |
| 36 | * @return {p5.Image} new <a href="#/p5.Image">p5.Image</a> object. |
| 37 | * |
| 38 | * @example |
| 39 | * function setup() { |
| 40 | * createCanvas(100, 100); |
| 41 | * |
| 42 | * background(200); |
| 43 | * |
| 44 | * // Create a p5.Image object. |
| 45 | * let img = createImage(66, 66); |
| 46 | * |
| 47 | * // Load the image's pixels into memory. |
| 48 | * img.loadPixels(); |
| 49 | * |
| 50 | * // Set all the image's pixels to black. |
| 51 | * for (let x = 0; x < img.width; x += 1) { |
| 52 | * for (let y = 0; y < img.height; y += 1) { |
| 53 | * img.set(x, y, 0); |
| 54 | * } |
| 55 | * } |
| 56 | * |
| 57 | * // Update the image's pixel values. |
| 58 | * img.updatePixels(); |
| 59 | * |
| 60 | * // Draw the image. |
| 61 | * image(img, 17, 17); |
| 62 | * |
| 63 | * describe('A black square drawn in the middle of a gray square.'); |
| 64 | * } |
| 65 | * |
| 66 | * @example |
| 67 | * function setup() { |
| 68 | * createCanvas(100, 100); |
| 69 | * |
| 70 | * background(200); |
| 71 | * |
| 72 | * // Create a p5.Image object. |
no test coverage detected