Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

tao degradation

by dada (Chaplain)
on Jun 27, 2003 at 13:54 UTC ( #269572=CUFP: print w/replies, xml ) Need Help??

just a little drawing program. nothing fancy (surely not good code either), but something that at least entertained me for a little while, and a little history of how it was born :-)

first of all, let's picture the situation. some days ago, I was stuck in a meeting; you know, one of these long-term-strategy-planning meetings.

there's always one point, in such meetings, when everybody around the table seems to be spreading nonsense (things like "this database can handle 10k simultaneous connection, guaranteed" or "it is necessary that we use XML to store our data", or even "let's write it in Java").

at that point I (as most others do, I tend to believe) started sketching something on the noteblock. the sheets had small square blocks, so I initially went with something geometric.

after a while (and a lot of nonsense) I started drawing circles, and ended up playing with variations on the yin-yang theme (the tao circle, the tai chi, whatever you call it, I'm not a zen expert :-).

for some strange reason, I came home with the idea of producing something more beautiful than my handmade version on paper. so I enumerated my possibilities:

1) buy a compass, some good paper and a marker.
2) use some drawing software (CorelDRAW? AutoCAD? Sodipodi?)

neither of these were satisfying and/or easy, so I decided for:

3) write a little program to draw this for me!

and the choice was obvious. the morning after, the first thing I've done (in the first 20 minutes of just another boring workday) was I coded, I hacked, I ran it. I saw the result and it was good :-)

here you find the latest (re)incarnation of my 20-minutes script, beautified just a little for your viewing pleasure. a "proof of concept" page showing the produced images is at

#!perl -w # note: should be saved as use strict; use GD; use Getopt::Long; use vars qw( $PARTS $DIM $HELP ); GetOptions( 'parts=i' => \$PARTS, 'dimension=i' => \$DIM, 'help!' => \$HELP, ) or warn(qq(try "$0 --help"\n)), exit(1); if($HELP) { print usage(); exit(0); } $DIM ||= 500; $PARTS ||= 2; # zero is balance of powers anyway. my $arcw = $DIM/$PARTS; my $TAO = GD::Image->new($DIM, $DIM); my $yin = $TAO->colorAllocate(0x00, 0x00, 0x00); my $yang = $TAO->colorAllocate(0xFF, 0xFF, 0xFF); my @shade = (); foreach (0..$PARTS) { push(@shade, $TAO->colorAllocate( ( 255 * ($_+1) / ($PARTS+1) ) x 3 )); } $TAO->filledRectangle( 0, 0, $DIM, $DIM, $yang ); foreach my $arc (1..$PARTS) { $TAO->arc( ($arc*$arcw)/2, $DIM/2, $arc*$arcw, $arc*$arcw, 180, 0, $yin ); } foreach my $arc (1..$PARTS) { $TAO->arc( $DIM-($arc*$arcw)/2, $DIM/2, $arc*$arcw, $arc*$arcw, 0, 180, $yin ); } foreach my $arc (1..$PARTS-2) { $TAO->fill( $arcw/2+$arc*$arcw, $DIM/2, $shade[$arc-1] ); $TAO->arc( $arcw/2+$arc*$arcw, $DIM/2, $arcw/5, $arcw/5, 0, 360, $shade[$PARTS-$arc-1] ); $TAO->fill( $arcw/2+$arc*$arcw, $DIM/2, $shade[$PARTS-$arc-1] ); } $TAO->fill( $arcw/2-$arcw/5-2, $DIM/2, $yin ); $TAO->arc( $arcw/2, $DIM/2, $arcw/5+1, $arcw/5+1, 0, 360, $yang ); $TAO->fill( $arcw/2, $DIM/2, $yang ); $TAO->arc( $DIM-$arcw/2, $DIM/2, $arcw/5, $arcw/5, 0, 360, $yin ); $TAO->fill( $DIM-$arcw/2, $DIM/2, $yin ); open TAO, ">tao-$PARTS.png"; binmode TAO; print TAO $TAO->png(); close TAO; print "take a look at tao-$PARTS.png. have a nice day -- dada.\n"; sub usage { <<EOF; $0 (c) 2003 Aldo Calpini <dada\> usage: $0 [OPTIONS] options: -d=N (--dimension=N) width and height, in pixels, of the resulting image. -p=N (--parts=N) number of parts (2 for a "regular" tao image). -h (--help) show this text. the defaults, if OPTIONS are not specified, are: -d=500 -p=2 output will be saved in "tao-N.png", where N is the value of the -p option. EOF }

update: removed some silliness (just realized that $x/($x/$y) is $y).


King of Laziness, Wizard of Impatience, Lord of Hubris

Replies are listed 'Best First'.
Re: tao degradation
by abell (Chaplain) on Jun 27, 2003 at 19:31 UTC

    Probably a bit off-topic, but since I recently learned postscript, I think it would be worth showing how that cute language would deal with it:

    %!PS-Adobe-3.0 % The next line defines the number of "slices" /n { 3 } def % n i slice /slice { newpath dup % n i i dup 0 exch % n i i 0 i 180 0 arcn % n i 2 copy 2 copy add % n i n i n+i 3 1 roll sub % n i n+i n-i 0 exch 180 0 arc % n i 2 copy 2 copy add 1 add % n i n i n+i+1 3 1 roll sub 1 sub % n i n+i+1 n-i-1 0 exch 0 180 arcn % n i dup 1 add dup % n i i+1 i+1 0 exch 0 180 arc gsave exch 1 sub div setgray fill grestore 0 setgray stroke } def 50 400 translate 200 n div dup scale .005 n mul setlinewidth 0 1 n 1 sub { dup n exch slice dup n 1 sub div 1 sub neg setgray 2 mul 1 add 0 .2 0 360 arc fill } for showpage
    Besides being a Turing-complete language, it's a very nice format for such geometric constructions, and has the advantage of being fully vectorial and of being understood by a few printers, so your pc doesn't even have to compute all those arcs :-) As an additional plus, it is quite easy to generate via perl.

    Anyways, ++ for the node (or to put it in our native language: bella prova secco ;-). I especially like the three-fold version.


    The stupider the astronaut, the easier it is to win the trip to Vega - A. Tucket
Re: tao degradation
by Mr. Muskrat (Canon) on Jun 27, 2003 at 14:42 UTC

    ++dada for a lovely diversion. BTW, you might want to check the user input for a -p value greater than 256 as that causes GD to seg fault. ;-)

    I give you my tribute... entitled The Tao of Chaos.

Re: tao degradation
by zentara (Archbishop) on Jun 27, 2003 at 17:32 UTC
    Very nice dada. It kind of reminds me of going from the "earth level" of d=2, upwards into multidimensional space. Mr. Muskrat's effort at d=256 made me think of "quantuum foam". Just the sort of thing that triggers that "mental condition of mine" where I start drifting off into deep space. :-)

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://269572]
Approved by particle
Front-paged by broquaint
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (None)
    As of 2022-01-26 04:32 GMT
    Find Nodes?
      Voting Booth?
      In 2022, my preferred method to securely store passwords is:

      Results (69 votes). Check out past polls.