Skip to content

Instantly share code, notes, and snippets.

@MetroWind
Created January 20, 2017 02:32
Show Gist options
  • Save MetroWind/cac06268c64d6cd756ad22e2898d4a10 to your computer and use it in GitHub Desktop.
Save MetroWind/cac06268c64d6cd756ad22e2898d4a10 to your computer and use it in GitHub Desktop.
Processing program to generate "halftone" pattern.
void setup() {
size(4096, 2048);
// The background image must be the same size as the parameters
// into the size() method. In this program, the size of the image
// is 640 x 360 pixels.
background(0);
noStroke();
noLoop();
}
int maxr = 32;
int mod = 1;
void draw()
{
int steps = 2048 / maxr / 2;
float delta_r = maxr / steps * 1.5;
float r = maxr * 1.5;
for(int iy = 0; iy * maxr * 2 <= 2048; iy++)
{
for(int ix = 0; ix * maxr * 2 <= 4096; ix++)
{
if((ix + iy) % mod == 0)
{
ellipse(ix * maxr * 2, iy * maxr * 2, 2*r, 2*r);
}
}
r -= delta_r;
}
save("halftone.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment