Can someone help with this code?
in
Programming Questions
•
2 years ago
Check out
http://www.bit-101.com/blog/?p=3251
I am trying to use the code to create the image on the site
However all I am able to get done are greyscale bands
Here is my processing code
Here is the original on the site
Here is what I can get done so far
I am trying to use the code to create the image on the site
However all I am able to get done are greyscale bands
Here is my processing code
- PImage imageData;
void setup(){
size(255,255,P3D);
imageData = createImage(255,255,ARGB);
for(int y = 0; y < imageData.height; y += 1) {
for(int x = 0; x < imageData.width; x += 1) {
//offset = x * 4 + y * 4 * imageData.width;
//imageData.data[offset] = Math.sin(x * 0.01) * 127 + 128;
//imageData.set(x+1,y+3,color(sin(x * 0.01) * 127 + 128));
// imageData.data[offset + 1] = Math.sin(y * 0.02) * 127 + 128;
// imageData.data[offset + 2] = Math.cos(x * 0.04 + y * 0.03) * 127 + 128;
// imageData.set((x*4)+2,y,color(cos(x * 0.04 + y * 0.03) * 127 + 128));
imageData.set((x*2),(y*1),color(cos(x * 0.04 + y * 0.03) * 127 + 128));
//imageData.set((x*2)+1,(y*1),color(cos(x * 0.04 + y * 0.03) * 127 + 128));
imageData.set((x*2)+1,(y*1)+1,color(cos(x * 0.04 + y * 0.03) * 127 + 128));
// imageData.data[offset + 3] = 255;
}
}
image(imageData,0,0);
}
Here is the original on the site
for
(y = 0; y < imageData.height; y += 1) {
for
(x = 0; x < imageData.width; x += 1) {
offset = x * 4 + y * 4 * imageData.width;
imageData.data[offset] = Math.sin(x * 0.01) * 127 + 128;
imageData.data[offset + 1] = Math.sin(y * 0.02) * 127 + 128;
imageData.data[offset + 2] = Math.
cos
(x * 0.04 + y * 0.03) * 127 + 128;
imageData.data[offset + 3] = 255;
}
}
Here is what I can get done so far
1