Skip to content

Instantly share code, notes, and snippets.

@sasaki-shigeo
Last active January 16, 2022 17:33
Show Gist options
  • Save sasaki-shigeo/bc3e4c1e8b4ec483ab34709580ec7d89 to your computer and use it in GitHub Desktop.
Save sasaki-shigeo/bc3e4c1e8b4ec483ab34709580ec7d89 to your computer and use it in GitHub Desktop.
A sample code in Processing: a (translucent) rainbow in the sky / Processing で Perlin noise を使った雲と半透明な虹
size(800, 400);
colorMode(HSB, 360.0, 1.0, 1.0, 1.0);
// The sky by the perlin noise
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
stroke(210, noise(0.005 * i, 0.005 * j), 1.0);
point(i, j);
}
}
// A translucent rainbow
noFill();
for (int i = 0; i <60; i++) {
stroke(i*i/10, 1, 1, 0.3 * exp(-(i-30)*(i-30)/300));
ellipse(width/2, 1.2 * height, 600-2*i, 600-2*i);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment