RE: Gnome Canvas Transparency

#include <gnome.h>

static GnomeCanvasItem *zoom_group;

int timeout (gpointer data)
	static int count=0;
	double total[6],rotate[6],scale[6];

	art_affine_rotate (rotate, 0.5);
	if (count++ > 300)
		art_affine_scale (scale, 1.01, 1.01);
		art_affine_scale (scale, 1.0/1.01, 1.0/1.01);
	if (count > 600)
		count = 0;
	art_affine_multiply (total, rotate, scale);

	/* rotate and scale the zoom_group of objects only */
	gnome_canvas_item_affine_relative (

	return -1;

void setup()
	GtkWidget *window;
	GtkWidget *canvas;
	GnomeCanvasItem *item, *grid;
	GnomeCanvasPathDef *path;

	window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
	gtk_widget_show (window);
	gtk_widget_set_usize (window, 500, 500);
	gtk_signal_connect (GTK_OBJECT (window), "destroy", gtk_main_quit,

	canvas = gnome_canvas_new_aa();
	gtk_widget_show (canvas);
	gtk_container_add (GTK_CONTAINER (window), canvas);

	/* Add grid object to canvas first so that it is the first
	 * object drawn on the canvas, i.e. it is in the background
	grid = gnome_canvas_item_new (
		gnome_canvas_root (GNOME_CANVAS (canvas)),
		"fill_color", "red",
		"x1", -100.0,
		"y1", -100.0,
		"x2", 200.0,
		"y2", 200.0,
	gnome_canvas_item_show (grid);

	/* create zoom_group, this group will be zoomed and rotated
	 * and therefore so will all other objects that are "rooted" to
	 * this group object
	zoom_group = gnome_canvas_item_new (
		gnome_canvas_root (GNOME_CANVAS (canvas)),
	gnome_canvas_item_show (zoom_group);

	path = gnome_canvas_path_def_new();
	gnome_canvas_path_def_moveto (path, 100, 100);
	gnome_canvas_path_def_lineto (path, 200, 100);
	gnome_canvas_path_def_lineto (path, 200, 200);
	gnome_canvas_path_def_curveto (path, 110, 100, 80,130, 100,100);
	gnome_canvas_path_def_closepath_current (path);
	item = gnome_canvas_item_new (
		GNOME_CANVAS_GROUP (zoom_group),
		"fill_color", "blue",
		"outline_color", "purple",
	gnome_canvas_shape_set_path_def (GNOME_CANVAS_SHAPE (item), path);
	gnome_canvas_item_show (item);

	gtk_timeout_add (20, timeout, NULL);

int main(int argc, char *argv[])
	gnome_init("chris garrett","1.0",argc,argv);

	return 0;

-----Original Message-----
From: Chris Garrett [mailto:garrett91 hotmail com]
Sent: Tuesday, 21 January 2003 23:49
To: gnome-devel-list gnome org
Subject: Gnome Canvas Transparency


I have created a gnome canvas and I can display a pixbuf on it.  The pixbuf 
has an alpha channel, which is renders fine.

I would like to know how to put a chequered background on the canvas so that

it can be seen through transparent areas of the image.  I could add another 
pixbuf behind it, but then when the canvas is zoomed, so would the chequered

pixbuf (I want the squares to stay the same size, and to tile all the way 
across the canvas).

Any ideas?


STOP MORE SPAM with the new MSN 8 and get 2 months FREE*

gnome-devel-list mailing list
gnome-devel-list gnome org
"This email (including all attachments) is for the use of the named addressee only. You must not use, disclose, or copy any part of this email if you are not the intended recipient. No rights of privacy, confidentiality, copyright or privilege are waved or lost by any mistransmission. If you receive this email in error, please immediately delete it from your system, destroy all copies, and notify the sender. Emails may be interfered with, may contain computer viruses or other defects, and may cause damage to your system. Raytheon gives no warranty in relation to the effect of this email on your system, or the accuracy or completeness of its contents."

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]