Blame onefile/gen-galaxy.c

a5e8d6
a5e8d6
#include <math.h></math.h>
a5e8d6
#include <helianthus.h></helianthus.h>
a5e8d6
a5e8d6
a5e8d6
void init() {
a5e8d6
}
a5e8d6
a5e8d6
a5e8d6
void put(double level) {
a5e8d6
  double x = level;
a5e8d6
  double e = exp(1+level);
a5e8d6
  double l = log(1+level);
a5e8d6
a5e8d6
  double angle  = l*360*4;
a5e8d6
  double dist   = x*2;
a5e8d6
  double radius = (1-l)*0.2;
a5e8d6
a5e8d6
  int cnt = 2;
a5e8d6
a5e8d6
  saveState();
a5e8d6
  rotate(angle);
a5e8d6
  for(int i = 0; i < cnt; ++i) {
a5e8d6
    rotate(360.0/cnt);
a5e8d6
    saveState();
a5e8d6
    translate(dist, 0);
a5e8d6
    circle(0, 0, radius);
a5e8d6
    restoreState();
a5e8d6
  }
a5e8d6
  restoreState();
a5e8d6
}
a5e8d6
a5e8d6
a5e8d6
void draw() {
a5e8d6
  double w = windowGetWidth();
a5e8d6
  double h = windowGetHeight();
a5e8d6
a5e8d6
  saveState();
a5e8d6
  noStroke();
a5e8d6
  fill(COLOR_BLACK);
a5e8d6
  translate(w/2, h/2);
a5e8d6
  zoom(100);
a5e8d6
a5e8d6
  int cnt = 100;
a5e8d6
  for(int i = 0; i < cnt; ++i)
a5e8d6
    put((i+1)/(double)cnt);
a5e8d6
a5e8d6
  restoreState();
a5e8d6
}
a5e8d6
a5e8d6
a5e8d6
int main() {
a5e8d6
  windowSetResizable(TRUE);
a5e8d6
  windowSetVariableFrameRate();
a5e8d6
  windowSetInit(&init);
a5e8d6
  windowSetDraw(&draw);
a5e8d6
  windowRun();
a5e8d6
  return 0;
a5e8d6
}