public void paint(GC gc, int width, int height) {
	if (!example.checkAdvancedGraphics()) return;
	Device device = gc.getDevice();
	
	// set line attributes
	gc.setLineWidth(20);
	gc.setLineCap(SWT.CAP_ROUND);	// round line ends
	gc.setAntialias(SWT.ON);	// smooth jagged edges
	
	Pattern pattern = null;
	if (foreground.getBgColor1() != null) {
		gc.setForeground(foreground.getBgColor1());
	} else if (foreground.getBgImage() != null) {
		pattern = new Pattern(device, foreground.getBgImage());
		gc.setForegroundPattern(pattern);
	}

	// draw petals for the spiral
	Transform transform;
	int n = petalSpinner.getSelection();
	for (int i=0; i < n; i++) {
		transform = new Transform(device);
		transform.translate(width/2, height/2);
		transform.rotate(-(angle + 360/n * i));
		gc.setTransform(transform);
		gc.drawArc(0, 0, width/3, height/6, 0, 180);
		transform.dispose();
	}
	
	if (pattern != null) pattern.dispose();
}