2019-07-11 03:14:02 +00:00
|
|
|
/* radare2 - LGPL - Copyright 2019 - pancake */
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
// Inspired by:
|
|
|
|
|
|
|
|
// https://www.a1k0n.net/2006/09/15/obfuscated-c-donut.html
|
|
|
|
|
2021-08-25 12:46:21 +00:00
|
|
|
k;float sin()
|
2019-07-11 03:14:02 +00:00
|
|
|
,cos();main(){float A=
|
|
|
|
0,B=0,i,j,z[1760];char b[
|
|
|
|
1760];printf("\x1b[2J");for(;;
|
|
|
|
){memset(b,32,1760);memset(z,0,7040)
|
|
|
|
;for(j=0;6.28>j;j+=0.07)for(i=0;6.28
|
|
|
|
>i;i+=0.02){float c=sin(i),d=cos(j),e=
|
|
|
|
sin(A),f=sin(j),g=cos(A),h=d+2,D=1/(c*
|
|
|
|
h*e+f*g+5),l=cos (i),m=cos(B),n=s\
|
|
|
|
in(B),t=c*h*g-f* e;int x=40+30*D*
|
|
|
|
(l*h*m-t*n),y= 12+15*D*(l*h*n
|
|
|
|
+t*m),o=x+80*y, N=8*((f*e-c*d*g
|
|
|
|
)*m-c*d*e-f*g-l *d*n);if(22>y&&
|
|
|
|
y>0&&x>0&&80>x&&D>z[o]){z[o]=D;;;b[o]=
|
|
|
|
".,-~:;=!*#$@"[N>0?N:0];}}/*#****!!-*/
|
|
|
|
printf("\x1b[H");for(k=0;1761>k;k++)
|
|
|
|
putchar(k%80?b[k]:10);A+=0.04;B+=
|
|
|
|
0.02;}}/*****####*******!!=;:~
|
|
|
|
~::==!!!**********!!!==::-
|
|
|
|
.,~~;;;========;;;:~-.
|
|
|
|
..,--------,*/
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
#include <r_util.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
// global iterators
|
2019-07-11 03:14:41 +00:00
|
|
|
R_API char *r_str_donut(int osize) {
|
|
|
|
int size = osize;
|
2021-08-25 12:46:21 +00:00
|
|
|
static float A = 0;
|
|
|
|
static float B = 0;
|
|
|
|
float i,j,z[1760];
|
2019-07-11 03:14:02 +00:00
|
|
|
int k;
|
|
|
|
char b[1760];
|
|
|
|
char o[1760];
|
2021-08-17 21:12:22 +00:00
|
|
|
memset (b, 32, 1760);
|
|
|
|
memset (z, 0, 7040) ;
|
2019-07-11 03:14:41 +00:00
|
|
|
if (osize == 0) {
|
2019-07-11 03:14:02 +00:00
|
|
|
size = 100;
|
2019-07-11 03:14:41 +00:00
|
|
|
} else {
|
2020-04-05 13:02:46 +00:00
|
|
|
A = B = 0;
|
2019-07-11 03:14:02 +00:00
|
|
|
}
|
2021-08-25 12:46:21 +00:00
|
|
|
float Zero = (((float)(100 - size) / 100) * 6);
|
|
|
|
float Width = 30;
|
|
|
|
float Height = 15;
|
|
|
|
float Align = 25; // 40;
|
2019-07-11 03:14:41 +00:00
|
|
|
if (osize != 0) {
|
|
|
|
Align = 40;
|
|
|
|
}
|
2021-06-21 20:02:09 +00:00
|
|
|
for (j = Zero; 6.28f > j; j += 0.07f) {
|
|
|
|
for (i = Zero; 6.28f > i; i+= 0.02f) {
|
2020-04-05 13:02:46 +00:00
|
|
|
float c = sin (i);
|
|
|
|
float d = cos (j);
|
|
|
|
float e = sin (A);
|
|
|
|
float f = sin (j);
|
|
|
|
float g = cos (A);
|
|
|
|
float h = d + 2;
|
2021-11-28 21:10:51 +00:00
|
|
|
float D = 1 / (c* h*e+f*g+5);
|
|
|
|
float l = cos (i);
|
|
|
|
float m = cos (B);
|
|
|
|
float n = sin (B);
|
|
|
|
float t = c*h*g-f*e;
|
2021-08-17 21:12:22 +00:00
|
|
|
int x = (int)(Align+Width*D*(l*h*m-t*n));
|
|
|
|
int y = (int)(12 + Height*D*(l*h*n +t*m));
|
2020-04-05 13:02:46 +00:00
|
|
|
int o = x + 80 * y;
|
2021-11-28 21:10:51 +00:00
|
|
|
int N = (int)(8 * ((f*e-c*d*g)*m-c*d*e-f*g-l*d*n));
|
2021-08-25 12:46:21 +00:00
|
|
|
if (22 > y && y > 0 && x > 0 && 80 > x && D > z[o]) {
|
2019-07-11 03:14:41 +00:00
|
|
|
z[o] = D;
|
|
|
|
b[o] = " .,-:!/|S$@&"[N > 0? N: 0];
|
2019-07-11 03:14:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-04-05 13:02:46 +00:00
|
|
|
for (k = 0; k < 1760; k++) {
|
|
|
|
o[k] = (k % 80)? b[k]: 10;
|
2019-07-11 03:14:02 +00:00
|
|
|
}
|
2019-07-11 03:14:41 +00:00
|
|
|
o[sizeof (o) - 1] = 0;
|
|
|
|
if (osize == 0) {
|
2021-11-14 18:15:14 +00:00
|
|
|
A += 0.03f;
|
|
|
|
B += 0.02f;
|
2019-07-11 03:14:41 +00:00
|
|
|
} else {
|
2021-11-14 18:15:14 +00:00
|
|
|
A += 0.0f;
|
|
|
|
B += 0.01f;
|
2019-07-11 03:14:41 +00:00
|
|
|
}
|
2019-07-11 03:14:02 +00:00
|
|
|
char *r = strdup (o);
|
2020-03-02 20:39:37 +00:00
|
|
|
r_str_trim_tail (r);
|
2019-07-11 03:14:02 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|