So, I know that I’ve been harping on this a bit, but I’ve re-written my M-Set renderer in C, so it’s faster, and I’ve added a few more command line flags to make it easier to use.
Get the code here.
So, I know that I’ve been harping on this a bit, but I’ve re-written my M-Set renderer in C, so it’s faster, and I’ve added a few more command line flags to make it easier to use.
Get the code here.
I just recently revisited the M-Set code from my Perl Snippets post. The code I had was pretty ugly, so I decided to rewrite it in Python. The result is not only a lot cleaner and easier to understand, but it’s also a lot faster:
$ time python mandel.py > \dev\null real 0m0.051s user 0m0.036s sys 0m0.010s $ time perl mandel.pl > \dev\null real 0m3.518s user 0m3.463s sys 0m0.029s
You can find the code here.
This script works well for zooms, as long as you stay below a few thousand iterations. The following picture was generated with x=-1.1887204, y=-0.3032472, width=0.01 and 150 iterations.
I’ve been getting into a mood lately that makes me fiddle around with fun Perl stuff, but sadly school’s picking up to the point that writing anything up isn’t going to happen. However, I have a couple short scripts that I’m just dying to share.
I figured that it was about time in my hacking career (read: I was bored enough) that I should make a japh script. After a couple attempts I came up with this:
#!/usr/bin/perl
while(){
for (map{ord($_)-33}split ''){
$__++;
$_||(print(chr($__+19))&&($__=0));
}
}
print "\n";
__END__
/| |\
! ; : : :
| Y, ,P |
! | Yb. __ ,dP |
l\ YMMb,_ _,/ \,_ _,dMMP /f
! j; `YMMP' `--' `YMMP' ;j
: \ YP`-._ _.-'YP / ;
! ! \ `\, _,\_ _/,_ ,/' /
`,_, \`o>
I'll let you go ahead and figure it out on your own. It's not super-hard, but it's fun.
Mandelbrot
In another fit of boredom I decided that it was finally time to create a mandelbrot set renderer. I originally tried to make one of these in basic, long before I had the math to do so. I was proud that I got the real axis to render, and figured it was time to complexify it. To keep things simple I decided to make it render an ASCII-art version of the set that would fit in a terminal window. The output looks like this:
...............................:::::oo@@@@o::::..........
...............................::::::O@@@@@@@@o:::::.......
.............................::::::::oO@@@@@@@@o::::::::....
...........................::::OOO8ooO@O88@@@@@@8@O8o::::Oo:..
.......................:::::::::o8@@@@@@@@@@@@@@@@@@@@OO@@@@::.
...................:::::::::::::oOO@@@@@@@@@@@@@@@@@@@@@@@@@o:::
................:::::::::::::::o@@@@@@@@@@@@@@@@@@@@@@@@@@@@Oo:::
..............::::@oo::oOoo:::ooo@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@8o:
...........:::::::oO@@@O@@8@OooO8@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@O::
..........:::::::::oO@@@@@@@@@@88@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::
........:::::::8ooO8@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@o::
.:::::::::::::oO@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@o:::
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@Oo::::
.:::::::::::::oO@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@o:::
........:::::::8ooO8@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@o::
..........:::::::::oO@@@@@@@@@@88@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@::
...........:::::::oO@@@O@@8@OooO8@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@O::
..............::::@oo::oOoo:::ooo@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@8o:
................:::::::::::::::o@@@@@@@@@@@@@@@@@@@@@@@@@@@@Oo:::
...................:::::::::::::oOO@@@@@@@@@@@@@@@@@@@@@@@@@o:::
.......................:::::::::o8@@@@@@@@@@@@@@@@@@@@OO@@@@::.
...........................::::OOO8ooO@O88@@@@@@8@O8o::::Oo:..
.............................::::::::oO@@@@@@@@o::::::::....
...............................::::::O@@@@@@@@o:::::.......
...............................:::::oo@@@@o::::..........
The code's far from polished and not what I like to publish, but it's a fun thing to look at and offers you some neat abilities to poke things around and fix some pesky problems that just need clear thinking applied to them. It's available here.