#!/home/ben/software/install/bin/perl use warnings; use strict; use Cairo; use Math::Trig; my $size = 500; my $surface = Cairo::ImageSurface->create ('argb32', $size, $size); my $cr = Cairo::Context->create ($surface); $cr->move_to ($size / 2, $size / 2); $cr->set_source_rgb (0, 0, 0); # http://matt.wandel.ca/artwork/math_art.html for (my $theta = 0; $theta < 2 * pi; $theta += .015) { my $rad = -(.5 * sin(5 * $theta)) * (.5 * cos(4 * $theta)) * 1000; my $angle = $theta + sin ($rad / 100); my $xp = $size / 2 + $rad * cos ($angle); my $yp = $size / 2 + $rad * sin ($angle); $cr->line_to ($xp, $yp); } $cr->stroke_preserve (); $cr->set_source_rgba (0.5, 0.5, 0, 0.5); $cr->fill (); $surface->write_to_png ('flower.png');