<?xml version="1.0" encoding="windows-1252"?>
<node id="960766" title="Taijitu ... the ultimate symbol of power" created="2012-03-21 08:00:23" updated="2012-03-21 08:00:23">
<type id="1584">
poem</type>
<author id="131741">
zentara</author>
<data>
<field name="doctext">
Sometimes a picture is better than 10,000 words. &lt;a href=http://zentara.net/ying-yang.png&gt; screenshot&lt;/a&gt;&lt;p&gt;
P.S.
If anyone knows how to rotate the entire Cairo surface, please show me. $cr-&gt;rotate( PI/6 ); dosn't seem to work.

&lt;c&gt;
#!/usr/bin/perl
use strict;
use warnings;
use Cairo;

use constant {
	IMG_WIDTH =&gt; 480,
	IMG_HEIGHT =&gt; 480,
	PI =&gt; 3.1416
};

die "png backend not supported" unless (Cairo::HAS_PNG_FUNCTIONS);

my $png = "$0.png";

my $surf = Cairo::ImageSurface-&gt;create ('rgb24', IMG_WIDTH, IMG_HEIGHT);
my $cr = Cairo::Context-&gt;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-&gt;arc (IMG_WIDTH/2, IMG_HEIGHT/2, IMG_WIDTH/2, 3*PI/2,  PI/2);
$cr-&gt;set_source_rgb (1, 1, 1);
$cr-&gt;fill;

#right
$cr-&gt;arc (IMG_WIDTH/2, IMG_HEIGHT/2, IMG_WIDTH/2, PI/2, 3*PI/2);
$cr-&gt;set_source_rgb (0, 0, 0);
$cr-&gt;fill;

#top semicircle
$cr-&gt;arc (IMG_WIDTH/2, 3*IMG_HEIGHT/4, IMG_HEIGHT/4, 3*PI/2, PI/2);
$cr-&gt;set_source_rgb (0, 0, 0);
$cr-&gt;fill;

#bottom semicircle
$cr-&gt;arc (IMG_WIDTH/2, IMG_HEIGHT/4, IMG_HEIGHT/4, PI/2 , 3*PI/2 );
$cr-&gt;set_source_rgb (1, 1, 1);
$cr-&gt;fill;

#encompassing boundary
$cr-&gt;arc (IMG_WIDTH/2, IMG_HEIGHT/2, IMG_WIDTH/2, 0,  2*PI);
$cr-&gt;set_source_rgb (1, 1, 1);
$cr-&gt;stroke;

# opposite kernels
# top
$cr-&gt;arc (IMG_WIDTH/2, IMG_HEIGHT/4, IMG_WIDTH/20, 0, 2*PI);
$cr-&gt;set_source_rgb (0, 0, 0);
$cr-&gt;fill;

#bottom
$cr-&gt;arc (IMG_WIDTH/2, 3*IMG_HEIGHT/4, IMG_HEIGHT/20, 0, 2*PI);
$cr-&gt;set_source_rgb (1, 1, 1);
$cr-&gt;fill;

$surf-&gt;write_to_png ($png);

system ("display $png"); # requires ImageMagick to be installed
&lt;/c&gt;


&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-131741"&gt;
&lt;hr /&gt;
I'm not really a human, but I play one on earth.&lt;br&gt;
[id://630805] ................... &lt;a href=http://zentara.net/japh.html&gt; flash japh &lt;/a&gt;

&lt;/div&gt;&lt;/div&gt;</field>
</data>
</node>
