Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // WARNING edit: this has no framerate limit and will genuinely draw a lot of electrical power.
- // press CTRL+C to stop animation! (or just close window)
- // if you get question marks in boxes, you may need to run it in smth like Git Bash
- w = 52; // If the sphere looks squished on your screen, change width and height here
- h = 27;
- iter = 2000; // increase iter to slow down animation, decrease to speed up
- dot = (u, v) => u.reduce((a, x, i)=>a + x*v[i], 0);
- PI = Math.PI;
- f = "⠈⠑⠋⠛⠽⠿".split("");
- for(;;){
- for(i=0; i < iter; i++){
- S=[];
- v = [-1/2, Math.cos(2*PI*i/iter), Math.sin(2*PI*i/iter)];
- v = v.map(x => x/dot(v,v));
- for(y = 0; y < h; y++){
- for(x = 0; x < w; x++){
- [p, t] = [x/w, y/h].map(e => e*PI/2 + PI/4);
- [x1, y1, z1] = [0, 0, -1.6];
- [x2, y2, z2] = [Math.sin(p)*Math.cos(t), Math.cos(p), Math.sin(p)*Math.sin(t)];
- a = x2*x2 + y2*y2 + z2*z2;
- b = -2*(-x1*x2 - y1*y2 - z1*z2);
- c = x1*x1 + y1*y1 + z1*z1-1;
- d = b*b - 4*a*c;
- if(d >= 0) {
- u = (-b + Math.sqrt(d))/2/a;
- n = [x1 + x2*u, y1 + y2*u, z1 + z2*u];
- r = Math.acos(dot(n,v));
- S.push(f[Math.floor(r*6/PI)]);
- }
- else S.push("⠀");
- }
- S.push("\n");
- }
- console.log(S.join(""));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement