[cairo-commit] cairo-demo/X11 ChangeLog,1.2,1.3 cairo-knockout.c,1.8,1.9
Carl Worth
commit at pdx.freedesktop.org
Wed Nov 19 18:21:59 PST 2003
Committed by: cworth
Update of /cvs/cairo/cairo-demo/X11
In directory pdx:/tmp/cvs-serv10265
Modified Files:
ChangeLog cairo-knockout.c
Log Message:
(oval_path):
(fill_checks):
(draw_3circles):
(draw): Rename cairo_t identifier from r to cr.
(main): Add "cairo" to window title. Fix comments.
Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-demo/X11/ChangeLog,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ChangeLog 20 Nov 2003 02:14:41 -0000 1.2
--- ChangeLog 20 Nov 2003 02:21:57 -0000 1.3
***************
*** 5,8 ****
--- 5,13 ----
window properties so window managers like metacity will decorate
the window.
+ (oval_path):
+ (fill_checks):
+ (draw_3circles):
+ (draw): Rename cairo_t identifier from r to cr.
+ (main): Add "cairo" to window title. Fix comments
2003-11-07 Carl Worth <cworth at isi.edu>
Index: cairo-knockout.c
===================================================================
RCS file: /cvs/cairo/cairo-demo/X11/cairo-knockout.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** cairo-knockout.c 20 Nov 2003 02:14:41 -0000 1.8
--- cairo-knockout.c 20 Nov 2003 02:21:57 -0000 1.9
***************
*** 24,28 ****
*/
static void
! oval_path (cairo_t *r,
double xc, double yc,
double xr, double yr)
--- 24,28 ----
*/
static void
! oval_path (cairo_t *cr,
double xc, double yc,
double xr, double yr)
***************
*** 31,46 ****
matrix = cairo_matrix_create ();
! cairo_current_matrix (r, matrix);
! cairo_translate (r, xc, yc);
! cairo_scale (r, 1.0, yr / xr);
! cairo_move_to (r, xr, 0.0);
! cairo_arc (r,
0, 0,
xr,
0, 2 * M_PI);
! cairo_close_path (r);
! cairo_set_matrix (r, matrix);
cairo_matrix_destroy (matrix);
}
--- 31,46 ----
matrix = cairo_matrix_create ();
! cairo_current_matrix (cr, matrix);
! cairo_translate (cr, xc, yc);
! cairo_scale (cr, 1.0, yr / xr);
! cairo_move_to (cr, xr, 0.0);
! cairo_arc (cr,
0, 0,
xr,
0, 2 * M_PI);
! cairo_close_path (cr);
! cairo_set_matrix (cr, matrix);
cairo_matrix_destroy (matrix);
}
***************
*** 50,54 ****
*/
static void
! fill_checks (cairo_t *r,
int x, int y,
int width, int height)
--- 50,54 ----
*/
static void
! fill_checks (cairo_t *cr,
int x, int y,
int width, int height)
***************
*** 56,64 ****
cairo_surface_t *check;
! cairo_save (r);
#define CHECK_SIZE 32
! check = cairo_surface_create_similar (cairo_current_target_surface (r),
CAIRO_FORMAT_RGB24,
2 * CHECK_SIZE, 2 * CHECK_SIZE);
--- 56,64 ----
cairo_surface_t *check;
! cairo_save (cr);
#define CHECK_SIZE 32
! check = cairo_surface_create_similar (cairo_current_target_surface (cr),
CAIRO_FORMAT_RGB24,
2 * CHECK_SIZE, 2 * CHECK_SIZE);
***************
*** 67,100 ****
/* Draw the check */
{
! cairo_save (r);
! cairo_set_target_surface (r, check);
! cairo_set_operator (r, CAIRO_OPERATOR_SRC);
! cairo_set_rgb_color (r, 0.4, 0.4, 0.4);
! cairo_rectangle (r, 0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
! cairo_fill (r);
! cairo_set_rgb_color (r, 0.7, 0.7, 0.7);
! cairo_rectangle (r, x, y, CHECK_SIZE, CHECK_SIZE);
! cairo_fill (r);
! cairo_rectangle (r, x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE);
! cairo_fill (r);
! cairo_restore (r);
}
/* Fill the whole surface with the check */
! cairo_set_pattern (r, check);
! cairo_rectangle (r, 0, 0, width, height);
! cairo_fill (r);
cairo_surface_destroy (check);
! cairo_restore (r);
}
--- 67,100 ----
/* Draw the check */
{
! cairo_save (cr);
! cairo_set_target_surface (cr, check);
! cairo_set_operator (cr, CAIRO_OPERATOR_SRC);
! cairo_set_rgb_color (cr, 0.4, 0.4, 0.4);
! cairo_rectangle (cr, 0, 0, 2 * CHECK_SIZE, 2 * CHECK_SIZE);
! cairo_fill (cr);
! cairo_set_rgb_color (cr, 0.7, 0.7, 0.7);
! cairo_rectangle (cr, x, y, CHECK_SIZE, CHECK_SIZE);
! cairo_fill (cr);
! cairo_rectangle (cr, x + CHECK_SIZE, y + CHECK_SIZE, CHECK_SIZE, CHECK_SIZE);
! cairo_fill (cr);
! cairo_restore (cr);
}
/* Fill the whole surface with the check */
! cairo_set_pattern (cr, check);
! cairo_rectangle (cr, 0, 0, width, height);
! cairo_fill (cr);
cairo_surface_destroy (check);
! cairo_restore (cr);
}
***************
*** 103,107 ****
*/
static void
! draw_3circles (cairo_t *r,
double xc, double yc,
double radius)
--- 103,107 ----
*/
static void
! draw_3circles (cairo_t *cr,
double xc, double yc,
double radius)
***************
*** 109,136 ****
double subradius = radius * (2 / 3. - 0.1);
! cairo_set_rgb_color (r, 1., 0., 0.);
! oval_path (r,
xc + radius / 3. * cos (M_PI * (0.5)),
yc - radius / 3. * sin (M_PI * (0.5)),
subradius, subradius);
! cairo_fill (r);
! cairo_set_rgb_color (r, 0., 1., 0.);
! oval_path (r,
xc + radius / 3. * cos (M_PI * (0.5 + 2/.3)),
yc - radius / 3. * sin (M_PI * (0.5 + 2/.3)),
subradius, subradius);
! cairo_fill (r);
! cairo_set_rgb_color (r, 0., 0., 1.);
! oval_path (r,
xc + radius / 3. * cos (M_PI * (0.5 + 4/.3)),
yc - radius / 3. * sin (M_PI * (0.5 + 4/.3)),
subradius, subradius);
! cairo_fill (r);
}
static void
! draw (cairo_t *r,
int width,
int height)
--- 109,136 ----
double subradius = radius * (2 / 3. - 0.1);
! cairo_set_rgb_color (cr, 1., 0., 0.);
! oval_path (cr,
xc + radius / 3. * cos (M_PI * (0.5)),
yc - radius / 3. * sin (M_PI * (0.5)),
subradius, subradius);
! cairo_fill (cr);
! cairo_set_rgb_color (cr, 0., 1., 0.);
! oval_path (cr,
xc + radius / 3. * cos (M_PI * (0.5 + 2/.3)),
yc - radius / 3. * sin (M_PI * (0.5 + 2/.3)),
subradius, subradius);
! cairo_fill (cr);
! cairo_set_rgb_color (cr, 0., 0., 1.);
! oval_path (cr,
xc + radius / 3. * cos (M_PI * (0.5 + 4/.3)),
yc - radius / 3. * sin (M_PI * (0.5 + 4/.3)),
subradius, subradius);
! cairo_fill (cr);
}
static void
! draw (cairo_t *cr,
int width,
int height)
***************
*** 143,147 ****
double yc = height / 2.;
! overlay = cairo_surface_create_similar (cairo_current_target_surface (r),
CAIRO_FORMAT_ARGB32,
width, height);
--- 143,147 ----
double yc = height / 2.;
! overlay = cairo_surface_create_similar (cairo_current_target_surface (cr),
CAIRO_FORMAT_ARGB32,
width, height);
***************
*** 149,153 ****
return;
! punch = cairo_surface_create_similar (cairo_current_target_surface (r),
CAIRO_FORMAT_A8,
width, height);
--- 149,153 ----
return;
! punch = cairo_surface_create_similar (cairo_current_target_surface (cr),
CAIRO_FORMAT_A8,
width, height);
***************
*** 155,159 ****
return;
! circles = cairo_surface_create_similar (cairo_current_target_surface (r),
CAIRO_FORMAT_ARGB32,
width, height);
--- 155,159 ----
return;
! circles = cairo_surface_create_similar (cairo_current_target_surface (cr),
CAIRO_FORMAT_ARGB32,
width, height);
***************
*** 161,187 ****
return;
! fill_checks (r, 0, 0, width, height);
! cairo_save (r);
! cairo_set_target_surface (r, overlay);
/* Draw a black circle on the overlay
*/
! cairo_set_rgb_color (r, 0., 0., 0.);
! oval_path (r, xc, yc, radius, radius);
! cairo_fill (r);
! cairo_save (r);
! cairo_set_target_surface (r, punch);
/* Draw 3 circles to the punch surface, then cut
* that out of the main circle in the overlay
*/
! draw_3circles (r, xc, yc, radius);
! cairo_restore (r);
! cairo_set_operator (r, CAIRO_OPERATOR_OUT_REVERSE);
! cairo_show_surface (r, punch, width, height);
/* Now draw the 3 circles in a subgroup again
--- 161,187 ----
return;
! fill_checks (cr, 0, 0, width, height);
! cairo_save (cr);
! cairo_set_target_surface (cr, overlay);
/* Draw a black circle on the overlay
*/
! cairo_set_rgb_color (cr, 0., 0., 0.);
! oval_path (cr, xc, yc, radius, radius);
! cairo_fill (cr);
! cairo_save (cr);
! cairo_set_target_surface (cr, punch);
/* Draw 3 circles to the punch surface, then cut
* that out of the main circle in the overlay
*/
! draw_3circles (cr, xc, yc, radius);
! cairo_restore (cr);
! cairo_set_operator (cr, CAIRO_OPERATOR_OUT_REVERSE);
! cairo_show_surface (cr, punch, width, height);
/* Now draw the 3 circles in a subgroup again
***************
*** 189,207 ****
* without seams.
*/
! cairo_save (r);
! cairo_set_target_surface (r, circles);
! cairo_set_alpha (r, 0.5);
! cairo_set_operator (r, CAIRO_OPERATOR_OVER);
! draw_3circles (r, xc, yc, radius);
! cairo_restore (r);
! cairo_set_operator (r, CAIRO_OPERATOR_ADD);
! cairo_show_surface (r, circles, width, height);
! cairo_restore (r);
! cairo_show_surface (r, overlay, width, height);
cairo_surface_destroy (overlay);
--- 189,207 ----
* without seams.
*/
! cairo_save (cr);
! cairo_set_target_surface (cr, circles);
! cairo_set_alpha (cr, 0.5);
! cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
! draw_3circles (cr, xc, yc, radius);
! cairo_restore (cr);
! cairo_set_operator (cr, CAIRO_OPERATOR_ADD);
! cairo_show_surface (cr, circles, width, height);
! cairo_restore (cr);
! cairo_show_surface (cr, overlay, width, height);
cairo_surface_destroy (overlay);
***************
*** 218,222 ****
Window w;
Pixmap pixmap;
! char *title = "Knockout Groups";
unsigned int quit_keycode;
int needs_redraw;
--- 218,222 ----
Window w;
Pixmap pixmap;
! char *title = "cairo: Knockout Groups";
unsigned int quit_keycode;
int needs_redraw;
***************
*** 270,286 ****
XEvent xev;
! /* We accumulate the area to repaint until the event
! * queue, then repaint. This avoids us getting behind
! * on our repaint or painting the same area over and
! * over needlessly.
*/
if (!XPending (dpy) && needs_redraw) {
! cairo_t *r = cairo_create ();
! cairo_set_target_drawable (r, dpy, pixmap);
! draw (r, width, height);
! cairo_destroy (r);
XCopyArea (dpy, pixmap, w, gc,
--- 270,285 ----
XEvent xev;
! /* Only do the redraw if there are no events pending. This
! * avoids us getting behind doing several redraws for several
! * consecutive resize events for example.
*/
if (!XPending (dpy) && needs_redraw) {
! cairo_t *cr = cairo_create ();
! cairo_set_target_drawable (cr, dpy, pixmap);
! draw (cr, width, height);
! cairo_destroy (cr);
XCopyArea (dpy, pixmap, w, gc,
***************
*** 302,306 ****
goto DONE;
case ConfigureNotify:
! /* Note new size */
width = xev.xconfigure.width;
height = xev.xconfigure.height;
--- 301,305 ----
goto DONE;
case ConfigureNotify:
! /* Note new size and create new pixmap. */
width = xev.xconfigure.width;
height = xev.xconfigure.height;
More information about the cairo-commit
mailing list