雲のスクリーンセーバー Cloud Screensaver
雲のスクリーンセーバーをprocessingで作りました。
空の色は、プログラムの数字を変えれば、青空にでも夕焼けにでも変えることができます。
使用画像は、扇形(4分の1円)のみです。
これは、スクリーンセーバーなので、マウスやキーを触れば、すぐに消えます。
I made cloud screensaver with “processing”.
You can change the sky color to blue sky or evening glow by changing the number of the program.
The image used is only a sector (circle of one quarter).
This is a screensaver, so if you touch the mouse or key, it disappears immediately.
ソースコード👇
kumosaver
color bgcolor = color(128, 128, 128);
PGraphics bg;
String[] op = {
"200,220,255",
"一行目だけを読み取ってます。",
"夕焼けにしたい場合は一行目を 255,195,125 に置き換えてください",
"スペースを空けると多分クラッシュします。",
"ではでは。",
"kohacraft"
};
String[] sp = {
"3",
"一行目だけを読み取ってます。",
"1以上にしないとクラッシュします。",
"数値が高い方が遅くなります(分周?)。",
"ではでは。",
"kohacraft"
};
int tat;
int spa = 3;
void setup() {
//fullScreen(P2D);
size(1920,1080,P2D);
noStroke();
noSmooth();
bgsetting(0);
tat = height/4;
noCursor();
String[] opa = loadStrings("color.txt");
if (opa != null) {
if (splitTokens(opa[0], ",").length > 2) {
int r = int(splitTokens(opa[0], ",")[0]);
int g = int(splitTokens(opa[0], ",")[1]);
int b = int(splitTokens(opa[0], ",")[2]);
bgcolor = color(r, g, b);
println(r, g, b);
}
} else {
saveStrings("color.txt", op);
}
String[] spaa = loadStrings("speed.txt");
if (spaa != null) {
int spt = int(spaa[0]);
println(spaa[0], spt);
spa = spt;
} else {
saveStrings("speed.txt", sp);
}
//spa = 1;
frameRate(60/spa);
//bgcolor = color(255,195,125);
bg = createGraphics(width, height);
bg.noSmooth();
bg.beginDraw();
bg.noSmooth();
bg.noStroke();
float f = 1;
for (int i = 0; i < 50; i++) {
float g = ((float)(50-i)/500)+1;
bg.fill(red(bgcolor)*g, green(bgcolor)*g, blue(bgcolor)*g);
bg.rect(0, (height/1.5)+f, width, height/4);
f *= 1.1;
}
bg.endDraw();
}
void draw() {
bg();
image(bg, 0, 0);
}
void mouseMoved() {
if (frameCount > 10) {
//exit();
}
}
void keyPressed() {
exit();
}
bg
PGraphics bger;
PImage kumo0, kumo1, kumos0, kumos1;
float s;
int kky = height*8, kkys = -16;
void bgsetting(int ba) {
kumo0 = loadImage("data/kr.png");
kumo1 = loadImage("data/kl.png");
kumos0 = loadImage("data/krs.png");
kumos1 = loadImage("data/kls.png");
background(bgcolor);
bger = createGraphics(width+32, height);
bger.noSmooth();
noiseDetail(1);
}
boolean fai = false;
int okk;
void bg() {
background(bgcolor);
noiseDetail(2);
bger.beginDraw();
okk = kkys;
if (frameCount%(16) == 1) {
bger.noStroke();
bger.fill(bgcolor);
bger.rect(width+16, 0, 16, height);
bger.fill(255);
bger.rect(width+16, kky+16, 16, height-kky);
if (kkys > 0) {
bger.image(kumo1, width+16, kky);
bger.tint(bgcolor);
bger.image(kumos1, width, kky-18);
bger.noTint();
} else {
bger.image(kumo0, width+16, kky);
bger.tint(bgcolor);
bger.image(kumos0, width, kky-18);
bger.noTint();
}
kkys = okk;
if (noise(s)/1.3 > (float)int(((float)kky/height)*tat)/tat) {
kkys = 16;
} else {
kkys = -16;
}
s += 0.07;
if (int(okk) == int(kkys))kky += kkys;
}
bger.image(bger.get(1, 0, width+31, height), 0, 0);
bger.endDraw();
image(bger, 0, 0);
}
Download zip here↓