The image() function draws an image to the display window. Images must be in the sketch's "data" directory to load correctly. Select "Add file..." from the "Sketch" menu to add the image to the data directory, or just drag the image file onto the sketch window. Processing currently works with
(PImage img, float a, float b)
| 3903 | * @see PGraphics#alpha(int) |
| 3904 | */ |
| 3905 | public void image(PImage img, float a, float b) { |
| 3906 | // Starting in release 0144, image errors are simply ignored. |
| 3907 | // loadImageAsync() sets width and height to -1 when loading fails. |
| 3908 | if (img.width == -1 || img.height == -1) return; |
| 3909 | |
| 3910 | if (imageMode == CORNER || imageMode == CORNERS) { |
| 3911 | imageImpl(img, |
| 3912 | a, b, a+img.width, b+img.height, |
| 3913 | 0, 0, img.width, img.height); |
| 3914 | |
| 3915 | } else if (imageMode == CENTER) { |
| 3916 | float x1 = a - (img.width >> 1); |
| 3917 | float y1 = b - (img.height >> 1); |
| 3918 | imageImpl(img, |
| 3919 | x1, y1, x1+img.width, y1+img.height, |
| 3920 | 0, 0, img.width, img.height); |
| 3921 | } |
| 3922 | } |
| 3923 | |
| 3924 | /** |
| 3925 | * @param c width to display the image by default |