Why doesn't the RGB argument in a PImage have a transparent background?
in
Programming Questions
•
2 years ago
I'm following a simple example in a processing book I'm reading, and in the book the PImage is supposed to have a transparent background with the RGB argument in the constructor. Here's the code.
- size(500,300);
- background(255);
- //usedbydiagonallines
- float slope=float(height)/float(width);
- PImage img=createImage(width,height, RGB);
- color c=color(0,0,0);
- //horizontalline
- for (int i=0; i<width; i++){
- img.set(i,height/2,c);
- }
- //verticalline
- for(int i=0;i<height;i++){
- img.set(width/2,i,c);
- }
- //diagonalline(TL-BR)
- for(float i=0;i<width;i++){
- img.set(int(i),int(i*slope),c);
- }
- //diagonalline(BL-TR)
- for(float i=0;i<width;i++){
- img.set(int(i), int(height-i*slope), c);
- }
- image(img,0,0);
When I run it, I can't see the lines the program is supposed to create because I'm assuming with RGB there's no transparency and each PImage has a black background by default. Is this a mistake in the book, or maybe it's changed since it was released? Also, when I swap out RGB for ARGB, it works fine.
1