Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Taijitu ... the ultimate symbol of power

by zentara (Archbishop)
on Mar 21, 2012 at 12:00 UTC ( [id://960766]=poem: print w/replies, xml ) Need Help??

Sometimes a picture is better than 10,000 words. screenshot

P.S. If anyone knows how to rotate the entire Cairo surface, please show me. $cr->rotate( PI/6 ); dosn't seem to work.

#!/usr/bin/perl use strict; use warnings; use Cairo; use constant { IMG_WIDTH => 480, IMG_HEIGHT => 480, PI => 3.1416 }; die "png backend not supported" unless (Cairo::HAS_PNG_FUNCTIONS); my $png = "$0.png"; my $surf = Cairo::ImageSurface->create ('rgb24', IMG_WIDTH, IMG_HEIGHT +); my $cr = Cairo::Context->create ($surf); # to avoid a bit of angular confusion... :-) # arc angles are measured from 0 on the x-axis, and angles are # measured clockwise. So the usual 90 degree position is 3*PI/2. # There is a negative arc function, see the perldoc for Cairo. # In other words, the positive y axis is directed downward #left $cr->arc (IMG_WIDTH/2, IMG_HEIGHT/2, IMG_WIDTH/2, 3*PI/2, PI/2); $cr->set_source_rgb (1, 1, 1); $cr->fill; #right $cr->arc (IMG_WIDTH/2, IMG_HEIGHT/2, IMG_WIDTH/2, PI/2, 3*PI/2); $cr->set_source_rgb (0, 0, 0); $cr->fill; #top semicircle $cr->arc (IMG_WIDTH/2, 3*IMG_HEIGHT/4, IMG_HEIGHT/4, 3*PI/2, PI/2); $cr->set_source_rgb (0, 0, 0); $cr->fill; #bottom semicircle $cr->arc (IMG_WIDTH/2, IMG_HEIGHT/4, IMG_HEIGHT/4, PI/2 , 3*PI/2 ); $cr->set_source_rgb (1, 1, 1); $cr->fill; #encompassing boundary $cr->arc (IMG_WIDTH/2, IMG_HEIGHT/2, IMG_WIDTH/2, 0, 2*PI); $cr->set_source_rgb (1, 1, 1); $cr->stroke; # opposite kernels # top $cr->arc (IMG_WIDTH/2, IMG_HEIGHT/4, IMG_WIDTH/20, 0, 2*PI); $cr->set_source_rgb (0, 0, 0); $cr->fill; #bottom $cr->arc (IMG_WIDTH/2, 3*IMG_HEIGHT/4, IMG_HEIGHT/20, 0, 2*PI); $cr->set_source_rgb (1, 1, 1); $cr->fill; $surf->write_to_png ($png); system ("display $png"); # requires ImageMagick to be installed

I'm not really a human, but I play one on earth.
Old Perl Programmer Haiku ................... flash japh

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: poem [id://960766]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-25 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found