A few months ago, I was in the middle of another Perl project, and on an impulse took time out to try something new. As is often the case, I didn't expect it would take more than a few days to finish it.

Many weeks later, I have this obfuscation to show for it:

` use Tk ; ($ "= q \$ +;
W) i(s -9o ),B )$,} n$ p90)=2+$
m$sdnr 0,;/)$,=w uo,ix+((; E,s)bw$
n3&" -())h=N -ot/9x?$} ?i(A>,fg
0"[xp (f"{n$"; ,e0,u$t" meP#$4q-$
s1|,yw," J5$9yhe|J( ;$ .=,Z])@q3 ($ $O"~9)+=B"
;1fM,%s0&)(,*@,,-$0/ :&($H"F4$>k2#2n[v()=)t
a)xp4e:,$?@))f="/0xx $b$A;=t@x1,t]I,2Rm@e$3
0-;?)$:Ga_r_,09i)} B1Vp;(;A,0f(},/;{$1$(2
:(-$$$@(f0V041" ?Me2F"+0-,02.[-,:="r=>2
,0"0>$1sea>d 5 7,e-uF;pqnse52-q9p,$l$dul
):3$]d1liW(b e,20Z+a)=t)${tA8:))t;("otd
e(04{?e($&r -o(0,0p/($U"$${$,-,u;)b=,W
f$k 27-s(;,~".) V)5 26h"$$/9=}=;5x0@:HB^0"s$f)4
:B";)(,,uMo,/6,e p=[3" b-rAg0Hqu(a6;N>((;,($s$-0
$PC$0$-$shez,W {aj,J6 b) @,]9.mn=2 =0,aS$+0=yv05~
:$n,F):s(a;5s 4B d$)/6p $s$ )/0,(H}i0 rq (j;#,$$;(),
i,-<@h-cPp0?-n$h@_/3,,u.09 treA=80$$s.:0f ),;s0 :Cd
h@$:"=6$p,7,)@UU6%@4jl301=I-;0d_0+i2,)(,1$ ,*;,+t0 9;1
$)r9%(-)",0n,A}=0.$w{,6:e$}(s:3ri$"01xP@0 q1f*,
Z,:4t)F.r2"c6=$20};;.t0,o4$J4,$$p@(,Js0A;0
+sPrA$9($,[$,&=|i-s00q-$x-3$|n1*:,,bj=66c=
t)$63$g]$00-1$}s06r=;Xx,$;/@+,0*>$=54bw;
$$-)s"bs/5;h&HS9,ib=hg,$i_;*0Anl$i;9Sl(
$$:($anf$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, 3/}rFsx@i)7u$0@();,
, Bn=5sa,A$-$($=t(:h,9)u 1M[y(($8@$0*,,=*,)A
b0C _:($ 1M/ $;(+,,[3 $s )a]vm@$7$0 8O,;i),a
_D5Y]0-$( n ($p),:=} , $P$W.I{\ )=~s"[
$/ ]""g ;map{$h{$_} .=substr $",0
,1,""} split//, crypt(qw/ FRaCtal:
/, q+rp +)x160; $_=join //,map
{$h {$_ }} sort keys %h ;s /N
/ /xg; eval #l iv er po le
`

The purpose of the program (if peek you must) is ...

... to calculate fractals, using Perl/Tk. By default it will "fractalize" the word "JAPH", but one can instruct it to use one or more shapes, as well as a fractal algorithm for each shape.

My inspiration for this was the Koch snowflake.

When passed two or more arguments, the first specifies how many "generations" to evolve each fractal. The second argument(and any remaining arguments) specify what shape to draw, and how to evolve it.

You can either use give the coordinates of the shape, or use a shorthand ('#t' for triangle, '#s' for square, '#p' for pentagon', and '#h' for hexagon), followed by an optional algorithm. If no algorithm is given, an algorithm will be generated randomly.

For example, to draw a square (and evolve it with a random algorithm for 4 generations) you could do either of:

` fractal.pl 4 #s
-or-
fractal.pl 4 100,100,90:400,-90:400,-90:400,-90:400
`

The second form specifies to start at location (x,y) = (100,100) (in the lower left corner of the Tk window), and draw the first line at an angle of 90 degrees for 400 pixels. The next 3 lines are then drawn with -90 degree angles, also for 400 pixels each.

The algorithm should given by putting '=' immediately after the shape definition, followed by the algorithm. Each line segment of the current shape is permuted according to the algorithm, where the following symbols are used:

` . => don't permute this portion of the line segment
! => go to next portion of line segment (next rule)
A*B => specify next angle/distance for this portion
, => go on to next angle/distance
+ => complete journey to next point in line segment
`

So, for example, to draw a Koch snowflake with 5 iterations:

`fractal.pl 5 #t=.!60*1,+!.
`

In the above example, the algorithm divides each line segment into 3 portions with the following rules:

` . # Do not change the first portion
60*1,+ # Rotate 60 degrees away from the current
# heading, for a distance equal to 1 times
# the length of the current portion of the
# line segment. (The '*1' can be omitted,
# without changing the effect). Then,
# draw a final line completing the trip
# to the next point beginning the next
# portion of the line segment.
. # Do not change the last portion
`

One more example:

` fractal.pl 4 #s=.!90,-90*.5,-90*1.5!.
`

which will create a square, and then replace the middle third of each line segment with a 90 degree angle going the length of that portion, followed by a -90 degree angle for half the length, followed by another -90 degree angle for 1.5 times the length. In this case, there is no '+', so the resulting shape will be discontinuous each time.

I hope you have as much fun watching it as I do!

**Update:** Can you figure out why the plaintext "FRaCtal:" and salt "rp" were used as arguments to the crypt function?

s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/