. .

tutorial

Cairo Graphics: Getting Started

February 5, 2010 13:54:43.463

Next week I'll be redoing some of the Cairo screencasts - they are all outdated, simply due to the fact that you can load cairo much more easily now:

On Windows and OS X, you'll have the shared libraries installed as well (assuming you picked those when you ran the installer. If you didn't, re-run the installer and do so). For Linux or Unix platforms, you'll have to get Cairo installed yourself.

Once you have it loaded, try this as a simple "Is Cairo Working" test:


| win component |
win := ApplicationWindow new.
win
	component: (VisualBlock block: 
					[:gc :box |
					gc newCairoContextWhile: 
						[:cr |
						cr
							source: ColorValue red;
							rectangle: (box insetBy: 20);
							fillPreserve;
							source: ColorValue blue;
							strokeWidth: 20;
							stroke]]).
win open.

If it worked, you should get this (make the window bigger to see it:

Technorati Tags: , ,

posted by James Robertson

 Share Tweet This