#!perl -w # note: should be saved as tao.pl 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 { < 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 }