We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Dear friends I have this code and the result in the following image. It's a simple gradient from black to white.
//linear gradient
void setup() {
size(766, 200);
}
void draw() {
long k=0;
for (int i = 0; i <= 256; i++) {
k=(long)Math.pow(i,2);
if(k<=256){
fill(k);
rect(i*23, 10, 23, 180);
noStroke();
}
}
}
I want to add the missing colors betwen every column. The result is only 17 colors. The result I want is from 0 to 255 colors.
Answers
Hmm... This reminds me of some old posts of yours: =:)
Maybe like this? Not sure if rect()s are important to you:
A different approach still using rect() too: :ar!
Yes I am the same person ... :D The codes you both sent me are much better than mine with better results. However my professor asked me to add the missing colors in the existing code. >-)
I think this would be the smaller change to existing code... But looks stupid to me...
line 10
k=(long)Math.pow(i,1);
: Pline 13
rect(i*3, 10, 3, 180);