Dancing Star


How to make this video.

I made an animation with Processing and applied various video effects with Kdenlive video editor.

Applied Kdenlive video effects.
  • Edge glow
  • Sigmoidaltransfer
  • Glow
  • Dither

Thanks to nice music:
Big Tree by Evan Schaeffer
2017/02/21
http://freemusicarchive.org/music/Evan_Schaeffer/Glow_1216/Evan_Schaeffer_-_18_-_Big_Tree
Big Tree by Evan Schaeffer is licensed under a Attribution License.
For more permissions:
contact artist
クリエイティブ・コモンズ・ライセンス


Processing example code.

I tried to apply custom noise to shape moving in this code.
// Dancing Star
// Processing 3.2.1
// 2017.03.04
import processing.opengl.*;
import java.util.Random;

World wd;
Stage sg;

void setup() {
  size(1280, 720, OPENGL);
  colorMode(HSB, 256, 100, 100, 100);
  blendMode(SCREEN);
  hint(DISABLE_DEPTH_TEST);
  smooth();
  frameRate(12);

  wd = new World();
  sg = new Stage();
}

void draw() {

  wd.redraw();

  sg.spark();
  sg.rotatestar();
  sg.circle();
  sg.dance();
  
  /*
    saveFrame("frames/####.png");
    if (frameCount >= 1801) {
    exit();
    }
  */

}

class World {
  float r_X;
  float r_Y;
  float r_Z;

  World() {
    r_X = 0;
    r_Y = 0;
    r_Z = 0;
  }

  void redraw() {
    background(0, 0, 0);
    ambientLight(0, 0, 100);

    translate(width / 2, height / 2, 0);

    camera(0, 0, 300,
           0, 0, 0,
           0, 1, 0);
  }

}

class Stage {
  float radius;
  int vertex_num;
  Random obj_random;
  float noise_sd;

  Stage() {
    vertex_num = 10;
    radius = 100;
    obj_random = new Random();
    noise_sd = 0;
  }

  void spark() {
    noStroke();
    for (int y = -195; y <= 165; y += 30) {
      for (int x = -315; x <= 285; x += 30) {
        pushMatrix();
        translate(x, y, -10);
        fill(
             frameCount % 85 * 3,
             35,
             random(5, 35),
             100);
        rect(2, 2, 26, 26);
        popMatrix();
      }
    }
  }

  void rotatestar() {
    pushMatrix();

    rotateZ(radians(frameCount % 240) * 1.5);
    translate(0, 0, -5);
    strokeWeight(30);
    stroke(
           (frameCount % 51) * 5,
           40,
           40,
           100
           );
    starshape();

    popMatrix();
  }

  void circle() {
    float rotation = radians(frameCount % 36) * 10;
    float cradius = 280 * sin(radians(frameCount % 120) * 1.5);

    pushMatrix();

    translate(sin(rotation) * cradius / 8, cos(rotation) * cradius / 10, 0);
    stroke(
           frameCount % 256,
           50,
           45,
           100
           );
    fill(
         frameCount % 256,
         50,
         30,
         100
         );
    ellipse(0, 0, cradius, cradius);

    popMatrix();
  }
  
  void dance() {
    pushMatrix();

    rotateZ(radians(-frameCount % 240) * 1.5);
    translate(0, 0, 10);
    strokeWeight(10);
    stroke(
           42,
           40,
           80,
           100
           );
    fill(
         0,
         40,
         80,
         100
         );
    starcurve();

    popMatrix();
  }
 
  void starshape() {

    float points[][] = new   float[vertex_num][2];
    float vertex_r = 0;

    for (int i = 0; i < vertex_num; ++i) {
      if (i%2 == 0) {
        vertex_r = radius * 1.1;
      } else {
        vertex_r = radius / 2;
      }

      points[i][0] = vertex_r * cos(radians(360/vertex_num * i));
      points[i][1] = vertex_r * sin(radians(360/vertex_num * i));

    }
    for (int i = 0; i < vertex_num - 1; ++i) {
      line(points[i][0], points[i][1], points[i+1][0], points[i+1][1]);
    }
    line(points[vertex_num - 1][0], points[vertex_num - 1][1], points[0][0], points[0][1]);
  }

  void starcurve() {

    float vertex_r = 0;

    beginShape();
    for (int i = 0; i <= vertex_num + 1; ++i) {
      noise_sd = customnoise(noise_sd, 20.0, 0.5);

      if (i%2 == 0) {
        vertex_r = radius + noise_sd;
      } else {
        vertex_r = radius / 1.8 - noise_sd / 4;
      }

      curveVertex(
                  vertex_r * cos(radians(360/vertex_num * i)),
                  vertex_r * sin(radians(360/vertex_num * i))
                  );
    }
    endShape(CLOSE);
  }

  float customnoise(float value, float limit, float divide) {
    float seed = value;
    float gauss = (float) obj_random.nextGaussian() * (divide * pow(1 + abs(seed) / limit, 2));
    
    if (random(100) < 8) {
      if (seed == 0.0) {
        seed += gauss;
      } else if (seed < 0) {
        seed -= abs(gauss) / 2;
      } else {
        seed += abs(gauss) / 2;
      }
    } else {
      seed += gauss;
    }

    if (abs(seed) >= limit) {
      seed = value * (limit - divide) / limit;
    }

    return seed;
  }

}

/*
Copyright (C) 2017- deconbatch

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see 
*/



Next Post Previous Post
No Comment
Add Comment
comment url