Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boolean recording = true;
- int samples_per_frame = 2;
- int[][] frame_buffer;
- float shutter_time = 0.55; // must be normal
- float running_time = 8;
- int fps = 60;
- float millis_per_frame = 1000.0 / fps;
- int millis_per_cycle = int(running_time * 1000);
- int num_frames = int(running_time * fps);
- int WIDTH = 1600;
- int HEIGHT = 760;
- float TEXT_SIZE = 200;
- PFont font;
- color colors[];
- float cweights[];
- void settings() {
- size(WIDTH, HEIGHT, P2D);
- smooth(8);
- }
- void setup() {
- frameRate(fps);
- String[] font_list = PFont.list();
- printArray(font_list);
- colors = new color[7];
- cweights = new float[7];
- colors[0] = color(255, 255, 255);
- colors[1] = color(9, 207, 242);
- colors[2] = color(116, 231, 3);
- colors[3] = color(255, 210, 0);
- colors[4] = color(252, 45, 152);
- colors[5] = color(255, 0, 90);
- colors[6] = color(255, 255, 255);
- cweights[0] = 0.04;
- //cweights[0] = 0.15;
- cweights[1] = 0.19;
- cweights[2] = 0.32;
- cweights[3] = 0.45;
- cweights[4] = 0.65;
- cweights[5] = 0.80;
- cweights[6] = 0.94;
- font = createFont("HelveticaNeueLTStd-BlkExO", TEXT_SIZE, true);
- textFont(font);
- frame_buffer = new int[width*height][3];
- }
- void draw() {
- if (recording) {
- for (int i = 0; i < width*height; i++) {
- frame_buffer[i][0] = 0;
- frame_buffer[i][1] = 0;
- frame_buffer[i][2] = 0;
- }
- for (int sample = 0; sample < samples_per_frame; sample++) {
- float time = map((frameCount - 1) + sample * shutter_time / samples_per_frame, 0, num_frames, 0, 1);
- _draw(time);
- loadPixels();
- for (int i = 0; i < pixels.length; i++) {
- frame_buffer[i][0] += (pixels[i] >> 16) & 0xff;
- frame_buffer[i][1] += (pixels[i] >> 8) & 0xff;
- frame_buffer[i][2] += (pixels[i] ) & 0xff;
- }
- }
- loadPixels();
- for (int i = 0; i < pixels.length; i++) {
- pixels[i] = ((frame_buffer[i][0] / samples_per_frame) << 16) |
- ((frame_buffer[i][1] / samples_per_frame) << 8) |
- ((frame_buffer[i][2] / samples_per_frame) ) |
- 255 << 24;
- }
- updatePixels();
- String file_out[] = new String[3];
- file_out[0] = "BRCKHMPTN_";
- file_out[1] = nf(frameCount, 4);
- file_out[2] = ".png";
- saveFrame(join(file_out, ""));
- if (frameCount == num_frames) {
- exit();
- }
- } else {
- float time = map(millis() % millis_per_cycle, 0, millis_per_cycle, 0, 1);
- _draw(time);
- }
- }
- color determine_color(float t) {
- int end = 5;
- for (int i = 0; i < 6; i++) {
- if (cweights[i] > t) {
- end = i;
- break;
- }
- }
- int start = 0;
- for (int i = 0; i < 6; i++) {
- if (cweights[5-i] < t) {
- start = 5-i;
- break;
- }
- }
- float a;
- if (start == end) {
- float r = 1.0 - cweights[5] + cweights[0];
- if (start == 5) {
- // in the last bit
- a = map(t - cweights[5], 0, r, 0, 1);
- } else {
- // in the first bit
- a = map(t + (1.0 - cweights[5]), 0, r, 0, 1);
- }
- start = 5;
- end = 0;
- } else {
- a = map(t, cweights[start], cweights[end], 0, 1);
- }
- return lerpColor(colors[start], colors[end], a);
- }
- void _draw(float time) {
- background(3, 10, 105);
- noStroke();
- // ================ BROCKHAMPTON ===================
- for (int i = 0; i < 200; i++) {
- float t = time + i * 0.001 + 0.02;
- while (t >= 1.0) { t -= 1.0; }
- color c = determine_color(t);
- fill(c);
- text("HAMPTON", 150 + i * 0.2 + random(1) * 1, i + TEXT_SIZE + 280 + random(1) * 1);
- }
- for (int i = 0; i < 200; i++) {
- float t = time + i * 0.001;
- while (t >= 1.0) { t -= 1.0; }
- color c = determine_color(t);
- fill(c);
- text("BROCK", i * 0.2 + random(1) * 1, i + TEXT_SIZE + 30 + random(1) * 1);
- }
- // ============ FILM GRAIN ==============
- loadPixels();
- for (int i = 0; i < width*height; i++) {
- float k = random(1);
- if (k > 0.95) {
- pixels[i] = lerpColor(color(255), pixels[i], 0.75 + random(0.25));
- } else {
- pixels[i] = lerpColor(color(0), pixels[i], 0.9 + random(0.1));
- }
- }
- updatePixels();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement