Hi,
I'm new here and I'm also starting to learn programming from scratch (non-IT grad). Hoping to switch career from teaching to programming.
HELP!
How can I change a 200x200 black image to yellow using Javascript's For Loop? Nalilito kasi ako sa "formula".
Eto ang naisip ko. Black is (0,0,0) while yellow is (255,255,0).
var img = new SimpleImage(200,200);
print(img);
for (var pixel of img.values()){
var newG = 255 - pixel.getGreen();
var newR = 255 - pixel.getRed();
var newB = 0 - pixel.getBlue();
pixel.setGreen(newG);
pixel.setRed(newR);
pixel.setBlue(newB);
}
Thanks for the help!
I'm new here and I'm also starting to learn programming from scratch (non-IT grad). Hoping to switch career from teaching to programming.
HELP!
How can I change a 200x200 black image to yellow using Javascript's For Loop? Nalilito kasi ako sa "formula".
Eto ang naisip ko. Black is (0,0,0) while yellow is (255,255,0).
var img = new SimpleImage(200,200);
print(img);
for (var pixel of img.values()){
var newG = 255 - pixel.getGreen();
var newR = 255 - pixel.getRed();
var newB = 0 - pixel.getBlue();
pixel.setGreen(newG);
pixel.setRed(newR);
pixel.setBlue(newB);
}
Thanks for the help!