#!/usr/bin/perl use warnings; use strict; use Cairo; my $size = 200; # Create a drawing surface. my $surface = Cairo::ImageSurface->create ('argb32', $size, $size); # Create a drawing context. my $cr = Cairo::Context->create ($surface); # Create a rectangle $cr->rectangle (0, 0, $size, $size); # Black $cr->set_source_rgb (0, 0, 0); # Fill the rectangle. $cr->fill (); # Move to the top left corner. $cr->move_to ($size/5, $size/5); # Draw a line to the bottom right. $cr->line_to ((4*$size)/5, (4*$size)/5); # Set the line width. $cr->set_line_width (20); # White $cr->set_source_rgb (1, 1, 1); # Draw the line. $cr->stroke (); # Write the surface to the png file specified by $png. $surface->write_to_png ('line.png');