Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Alien Code?
- First try by: Chris M. Thomasson
- ____________________________________________________*/
- float g_pradius = 200;
- void setup()
- {
- size(800, 800);
- noFill();
- noLoop();
- background(0);
- colorMode(RGB, 255);
- translate(width / 2, height / 2);
- ct_alien_code_render(0, 2, 0, 0, 100);
- saveFrame("ct_alien_code.jpg");
- }
- void ct_alien_code_render(
- int irecur,
- int irecur_max,
- float ox,
- float oy,
- int imax
- ) {
- if (irecur >= irecur_max) return;
- float angle_start = 1 / (imax - 1.0) * (PI*2);
- float ptx = 1;
- float pty = 0;
- float ptx_x = (cos(angle_start) + floor(sin(angle_start)) * 2 + 1) * .5;
- float ptx_y = sin(angle_start) * .5;
- float dif_x = ptx_x - ptx;
- float dif_y = ptx_y - pty;
- float dis = abs(dif_x * dif_x + dif_y * dif_y);
- for (int i = 1; i < imax; ++i)
- {
- float ir = i / (imax - 1.0);
- float angle = (PI*2) * ir;
- float np_x = (cos(angle) + floor(sin(angle)) * 2 + 1) * .5;
- float np_y = (sin(angle)) * .5;
- np_x += ox;
- np_y += oy;
- float dif_np_x = np_x - ptx;
- float dif_np_y = np_y - pty;
- float ddd = abs(dif_np_x * dif_np_x + dif_np_y * dif_np_y);
- if (ddd <= dis && i > 1)
- {
- // line in.plot.line(pt, np, CT_RGBF(0, 1, 1));
- float proj_pt_x = ptx * g_pradius;
- float proj_pt_y = -pty * g_pradius;
- float proj_np_x = np_x * g_pradius;
- float proj_np_y = -np_y * g_pradius;
- stroke(255, 255, 0);
- line(proj_pt_x, proj_pt_y, proj_np_x, proj_np_y);
- stroke(255, 0, 0);
- line(-proj_pt_x, -proj_pt_y, -proj_np_x, -proj_np_y);
- }
- ct_alien_code_render(irecur + 1, irecur_max, np_x, np_y, imax);
- ptx = np_x;
- pty = np_y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment