Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: 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

In reply to Taijitu ... the ultimate symbol of power by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others chanting in the Monastery: (5)
    As of 2014-04-20 14:29 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (485 votes), past polls