using Cairo;
using Posix;
 
const int WH = 320;
 
private void drawstuff (Context c) {
        c.set_source_rgb (1, 0, 0);
        c.move_to (0, 0);
        c.rel_line_to (WH, WH);
        c.rel_line_to (-WH, 0);
        c.rel_line_to (WH, -WH);
        c.close_path ();
	c.fill ();
}
 
void main () {
	var s = new ImageSurface (Format.RGB24, WH, WH);
	var c = new Context (s);
 
	c.save ();
	drawstuff (c);
	c.restore ();
 
	print ("Image rendered to 'foo.png'\n");
	s.write_to_png ("foo.png");
}
