I want to colour the pixels of a 255 px x 255 px square so the x axis (left to right) shows red from 0 to 255 and the y axis (top to bottom) shows green from 0 to 255.
This is only the first step of an ambitious project so I want to work from robust foundations.
Q1 Is Pimage the best way to do this (see below), or should I draw a shape, or just use the background? Or other?
Q2 Currently I have the size of the sketch the same as the size of the image. I actually want the sketch to be much larger than the image. The image will still be 255 x 255. How do I do that?
My code:
PImage img;
String filename = str(month()) + str(day());
void setup() {
size(255, 255); //I want a white margin. This is currently same size as image.
noLoop();
img = loadImage("blank.png"); // this is just a blank image 255 px by 255 px
colorMode(RGB, 255, 255, 255);
}
void draw() {
loadPixels();
img.loadPixels();
for (int y = 0; y < height; y++ ) {
for (int x = 0; x < width; x++ ) {
int loc = x + y*width;
pixels[loc] = color(loc%width, (loc - (loc%width))/width, 0); //
}
}
updatePixels();
save(filename + ".jpg");
println("done");
}