#!/usr/bin/perl use warnings; use strict; use Cairo; my $size = 400; my $surface = Cairo::ImageSurface->create ('argb32', $size, $size); my $cr = Cairo::Context->create ($surface); $cr->rectangle (0, 0, $size, $size); $cr->set_source_rgb (0.9, 0.9, 0.9); $cr->fill (); $cr->set_source_rgb (0.4, 0.4, 1); $cr->set_line_width (2); my $divisions = 10; for my $i (1..$divisions - 1) { $cr->move_to (($size * $i)/$divisions, 0); $cr->line_to (($size * $i)/$divisions, $size); $cr->move_to (0, ($size * $i)/$divisions); $cr->line_to ($size, ($size * $i)/$divisions); } $cr->stroke (); my $png = 'grid.png'; $surface->write_to_png ($png);