void Taskbar::Draw(cairo_t *cr) { static double start_colour = 0.8; static double end_colour = 0.7; int m_colour = 0xf0f0f0; cairo_pattern_t *pattern; double red = ((m_colour >> 16) & 0xff) / 255.0; double green = ((m_colour >> 8) & 0xff) / 255.0; double blue = ((m_colour) & 0xff) / 255.0; cairo_rectangle(cr, 0.5, 0.5, m_draw_size.m_width-1.0, m_draw_size.m_height-1.0); pattern = cairo_pattern_create_linear(0, 0, 0, m_draw_size.m_height); cairo_pattern_add_color_stop_rgb(pattern, 0.0, start_colour*red, start_colour*green, start_colour*blue); cairo_pattern_add_color_stop_rgb(pattern, 1.0, end_colour*red, end_colour*green, end_colour*blue); /* Fill with our pattern */ cairo_set_source(cr, pattern); cairo_fill(cr); /* Destroy the pattern */ cairo_pattern_destroy(pattern); // Now draw a line at the bottom const double bound_colour = 0.5; cairo_set_source_rgb(cr, bound_colour, bound_colour, bound_colour); cairo_set_line_width(cr, 1.0); cairo_move_to(cr, 0.5, m_draw_size.m_height-0.5); cairo_line_to(cr, m_draw_size.m_width-0.5, m_draw_size.m_height-0.5); cairo_stroke(cr); drawChild(cr); }
void copy_cell_glyph(cairo_t *cr, int rotation) { static cairo_pattern_t *pat = 0; if(pat == 0) { pat = cairo_pattern_create_radial (0.27, 0.3, 0.08, 0.2, 0.35, 0.6); cairo_pattern_add_color_stop_rgb (pat, 0, 0.9, 0.9, 0.9); cairo_pattern_add_color_stop_rgb (pat, 1, 0.2, 0.9, 0.3); } cairo_save(cr); cairo_scale(cr,0.8,0.8); cairo_new_path(cr); cairo_arc(cr,0.5,0.5,0.5,(rotation*2-5)*M_PI/4,(rotation*2+5)*M_PI/4); cairo_line_to(cr,0.5,0.5); cairo_close_path(cr); cairo_set_source (cr, pat); cairo_fill_preserve (cr); cairo_set_source_rgb(cr,0.0,0.0,0.0); cairo_set_line_width(cr,0.07); cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND); cairo_stroke(cr); cairo_restore(cr); }
static void clearlooks_draw_glossy_gradient (cairo_t *cr, double x, double y, int width, int height, const CairoColor *color, gboolean disabled, gboolean radius, CairoCorners corners) { CairoColor a, b, c, d; cairo_pattern_t *pt; ge_shade_color (color, disabled? 1.06 : 1.16, &a); ge_shade_color (color, disabled? 1.02 : 1.08, &b); ge_shade_color (color, disabled? 0.98 : 1.00, &c); ge_shade_color (color, disabled? 1.02 : 1.08, &d); pt = cairo_pattern_create_linear (x, y, x, y+height); cairo_pattern_add_color_stop_rgb (pt, 0.0, a.r, a.g, a.b); cairo_pattern_add_color_stop_rgb (pt, 0.5, b.r, b.g, b.b); cairo_pattern_add_color_stop_rgb (pt, 0.5, c.r, c.g, c.b); cairo_pattern_add_color_stop_rgb (pt, 1.0, d.r, d.g, d.b); cairo_set_source (cr, pt); ge_cairo_rounded_rectangle (cr, x, y, width, height, radius, corners); cairo_fill (cr); cairo_pattern_destroy (pt); }
void or_gate_glyph(cairo_t *cr) { static cairo_pattern_t *pat = 0; cairo_save(cr); cairo_scale(cr,0.8,0.8); if(pat == 0) { pat = cairo_pattern_create_radial (0.35, 0.3, 0.08, 0.2, 0.35, 0.6); cairo_pattern_add_color_stop_rgb (pat, 0, 0.9, 0.9, 0.9); cairo_pattern_add_color_stop_rgb (pat, 1, 0.68, 1.0, 0.68); } cairo_new_path(cr); cairo_move_to(cr,0,0); cairo_arc(cr,-0.5,0.5,sqrt(2.0)/2,-M_PI/4,M_PI/4); cairo_line_to(cr,0.5,1.0); cairo_save(cr); cairo_scale(cr,0.9,2.0); double angle = asin(3.0/4); cairo_arc_negative(cr,0.5,-0.5,1.0,M_PI/2,angle); cairo_arc_negative(cr,0.5,1.0,1.0,-angle,-M_PI/2); cairo_restore(cr); cairo_close_path(cr); cairo_set_source (cr, pat); cairo_fill_preserve (cr); cairo_set_source_rgb(cr,0.0,0.0,0.0); cairo_set_line_width(cr,0.07); cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND); cairo_stroke(cr); cairo_restore(cr); }
static void terranova_draw_candy_icon_view_item (cairo_t *cr, const terranovaColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { const CairoColor *fill = &colors->bg[GTK_STATE_SELECTED]; cairo_save (cr); cairo_translate (cr, x, y); cairo_pattern_t *pattern; CairoColor shade1, shade2; tn_shade_color (fill, 0.94, &shade1); tn_shade_color (fill, 1.00, &shade2); pattern = cairo_pattern_create_linear (0, 1, 0, height); cairo_pattern_add_color_stop_rgb (pattern, 0.00, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.35, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.65, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 1.00, shade2.r, shade2.g, shade2.b); cairo_set_source (cr, pattern); tn_cairo_rounded_rectangle (cr, 0, 0, width, height, params->radius, CR_CORNER_ALL); cairo_fill (cr); cairo_pattern_destroy (pattern); cairo_restore (cr); }
static void terranova_draw_candy_list_view_header (cairo_t *cr, const terranovaColors *colors, const WidgetParameters *params, const ListViewHeaderParameters *header, int x, int y, int width, int height) { const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL]; cairo_pattern_t *pattern; cairo_translate (cr, x, y); CairoColor shade1, shade2; tn_shade_color (fill, 0.96, &shade1); tn_shade_color (fill, 1.10, &shade2); pattern = cairo_pattern_create_linear (0, 0, 0, height); cairo_pattern_add_color_stop_rgb (pattern, 0.00, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.35, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.65, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 1.00, shade2.r, shade2.g, shade2.b); cairo_set_source (cr, pattern); cairo_rectangle (cr, 0, 0, width, height); cairo_fill (cr); cairo_pattern_destroy (pattern); }
static void terranova_draw_candy_selected_cell (cairo_t *cr, const terranovaColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { cairo_save (cr); cairo_translate (cr, x, y); cairo_pattern_t *pattern; CairoColor fill = colors->bg[params->state_type]; CairoColor shade1, shade2; tn_shade_color (&fill, 0.96, &shade1); tn_shade_color (&fill, 1.10, &shade2); pattern = cairo_pattern_create_linear (0, 0, 0, height); cairo_pattern_add_color_stop_rgb (pattern, 0.00, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.35, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.65, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 1.00, shade2.r, shade2.g, shade2.b); cairo_set_source (cr, pattern); cairo_rectangle (cr, 0, 0, width, height); cairo_fill (cr); cairo_pattern_destroy (pattern); cairo_restore (cr); }
static void terranova_draw_candy_menubaritem (cairo_t *cr, const terranovaColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { const CairoColor *fill = &colors->bg[GTK_STATE_SELECTED]; CairoColor border = colors->spot[2]; cairo_pattern_t *pattern; tn_shade_color (&border, 1.00, &border); CairoColor shade1, shade2; tn_shade_color (fill, 0.96, &shade1); tn_shade_color (fill, 1.10, &shade2); pattern = cairo_pattern_create_linear (x, y, x, y + height); cairo_pattern_add_color_stop_rgb (pattern, 0.00, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.35, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.65, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 1.00, shade2.r, shade2.g, shade2.b); cairo_set_source (cr, pattern); tn_cairo_rounded_rectangle (cr, x+0.75, y+0.75, width - 1, height - 1, params->radius, params->corners); cairo_fill_preserve (cr); cairo_pattern_destroy (pattern); tn_cairo_set_color (cr, &border); cairo_stroke_preserve (cr); }
static cairo_test_status_t draw (cairo_t *cr, int width, int height) { cairo_pattern_t *pattern; cairo_set_source_rgb (cr, 0, 0, 0); cairo_paint (cr); /* with alpha */ pattern = cairo_pattern_create_linear (0, 0, 0, height); cairo_pattern_add_color_stop_rgba (pattern, 0, 1, 1, 1, .5); cairo_pattern_add_color_stop_rgba (pattern, 1, 1, 1, 1, .5); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); cairo_rectangle (cr, 0, 0, width/2, height); cairo_fill (cr); /* without alpha */ pattern = cairo_pattern_create_linear (0, 0, 0, height); cairo_pattern_add_color_stop_rgb (pattern, 0, 1, 1, 1); cairo_pattern_add_color_stop_rgb (pattern, 1, 1, 1, 1); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); cairo_rectangle (cr, width/2, 0, width/2, height); cairo_fill (cr); return CAIRO_TEST_SUCCESS; }
static void clearlooks_glossy_draw_menubaritem (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { const CairoColor *fill = &colors->spot[1]; const CairoColor *border = &colors->spot[2]; CairoColor shade1, shade2, shade3; cairo_pattern_t *pattern; ge_shade_color (fill, 1.16, &shade1); ge_shade_color (fill, 1.08, &shade2); ge_shade_color (fill, 1.08, &shade3); cairo_set_line_width (cr, 1.0); ge_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width - 1, height - 1, params->radius, params->corners); pattern = cairo_pattern_create_linear (x, y, x, y + height); cairo_pattern_add_color_stop_rgb (pattern, 0, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b); cairo_pattern_add_color_stop_rgb (pattern, 1, shade3.r, shade3.g, shade3.b); cairo_set_source (cr, pattern); cairo_fill_preserve (cr); cairo_pattern_destroy (pattern); ge_cairo_set_color (cr, border); cairo_stroke (cr); }
static gboolean ghid_trackball_expose (GtkWidget * widget, GdkEventExpose * ev) { cairo_t *cr; cairo_pattern_t *pattern; GtkAllocation allocation; GdkColor color; double radius; cr = gdk_cairo_create (gtk_widget_get_window (widget)); /* set a clip region for the expose event */ cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height); cairo_clip (cr); gtk_widget_get_allocation (widget, &allocation); radius = (MIN (allocation.width, allocation.height) - 5) / 2.; pattern = cairo_pattern_create_radial (2 * radius * 0.8, 2 * radius * 0.3, 0., 2 * radius * 0.50, 2 * radius * 0.50, 2 * radius * 0.71); color = widget->style->fg[GTK_WIDGET_STATE (widget)]; cairo_pattern_add_color_stop_rgb (pattern, 0.0, (color.red / 65535. * 0.5 + 4.5) / 5., (color.green / 65535. * 0.5 + 4.5) / 5., (color.blue / 65535. * 0.5 + 4.5) / 5.); cairo_pattern_add_color_stop_rgb (pattern, 0.2, (color.red / 65535. * 1.5 + 3.7) / 5., (color.green / 65535. * 1.5 + 3.7) / 5., (color.blue / 65535. * 1.5 + 3.7) / 5.); cairo_pattern_add_color_stop_rgb (pattern, 1.0, (color.red / 65535. * 5. + 0.) / 5., (color.green / 65535. * 5. + 0.) / 5., (color.blue / 65535. * 5. + 0.) / 5.); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); cairo_save (cr); cairo_translate (cr, allocation.width / 2., allocation.height / 2.); cairo_scale (cr, radius, radius); cairo_arc (cr, 0., 0., 1., 0., 2 * M_PI); cairo_restore (cr); cairo_fill_preserve (cr); gdk_cairo_set_source_color (cr, &widget->style->bg[GTK_WIDGET_STATE (widget)]); cairo_set_line_width (cr, 0.4); cairo_stroke (cr); cairo_destroy (cr); return FALSE; }
static void clearlooks_inverted_draw_menubaritem (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *widget, int x, int y, int width, int height) { CairoColor *fill = (CairoColor*)&colors->spot[1]; CairoColor fill_shade; CairoColor border = colors->spot[2]; cairo_pattern_t *pattern; ge_shade_color (&border, 1.05, &border); ge_shade_color (fill, 0.85, &fill_shade); cairo_set_line_width (cr, 1.0); ge_cairo_rounded_rectangle (cr, x + 0.5, y + 0.5, width - 1, height, widget->radius, widget->corners); pattern = cairo_pattern_create_linear (x, y, x, y + height); cairo_pattern_add_color_stop_rgb (pattern, 0, fill_shade.r, fill_shade.g, fill_shade.b); cairo_pattern_add_color_stop_rgb (pattern, 1.0, fill->r, fill->g, fill->b); cairo_set_source (cr, pattern); cairo_fill_preserve (cr); cairo_pattern_destroy (pattern); ge_cairo_set_color (cr, &border); cairo_stroke_preserve (cr); }
void and_gate_glyph(cairo_t *cr) { static cairo_pattern_t *pat = 0; cairo_save(cr); cairo_scale(cr,0.8,0.8); if(pat == 0) { pat = cairo_pattern_create_radial (0.27, 0.3, 0.08, 0.2, 0.35, 0.6); cairo_pattern_add_color_stop_rgb (pat, 0, 0.9, 0.9, 0.9); cairo_pattern_add_color_stop_rgb (pat, 1, 1.0, 0.68, 0.68); } cairo_new_path(cr); cairo_move_to(cr,0.0,0.0); cairo_line_to(cr,0.0,1.0); cairo_line_to(cr,0.5,1.0); cairo_arc_negative(cr,0.5,0.5,0.5,M_PI/2.0,-M_PI/2.0); cairo_close_path(cr); cairo_set_source (cr, pat); cairo_fill_preserve (cr); cairo_set_source_rgb(cr,0.0,0.0,0.0); cairo_set_line_width(cr,0.07); cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND); cairo_stroke(cr); cairo_restore(cr); }
static cairo_test_status_t draw (cairo_t *cr, int width, int height) { cairo_pattern_t *pattern; cairo_set_source_rgb (cr, 0.5, 0.5, 0.5); cairo_paint (cr); cairo_save (cr); pattern = cairo_pattern_create_linear (0, 0, 10.0, 0); cairo_pattern_add_color_stop_rgb (pattern, 0.0, 0.0, 0.0, 1.0); cairo_pattern_add_color_stop_rgb (pattern, 1.0, 1.0, 0.0, 0.0); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REFLECT); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); cairo_rectangle (cr, 0.0, 0.0, WIDTH, HEIGHT); cairo_fill (cr); cairo_restore (cr); return CAIRO_TEST_SUCCESS; }
static void br_cairo_draw_section(duc_graph *g, double a1, double a2, double r1, double r2, double H, double S, double V, double line) { struct cairo_backend_data *bd = g->backend_data; cairo_t *cr = bd->cr; double R, G, B; hsv2rgb(H, S, V, &R, &G, &B); cairo_new_path(cr); cairo_arc(cr, g->cx, g->cy, r1, ang(a1), ang(a2)); cairo_arc_negative(cr, g->cx, g->cy, r2, ang(a2), ang(a1)); cairo_close_path(cr); if(R != 1.0 || G != 1.0 || B != 1.0) { cairo_pattern_t *pat; pat = cairo_pattern_create_radial(g->cx, g->cy, 0, g->cx, g->cy, g->cx-50); double off1 = r2 / g->cx; double off2 = r1 / g->cx; cairo_pattern_add_color_stop_rgb(pat, off1, R, G, B); cairo_pattern_add_color_stop_rgb(pat, off2, R * 0.6, G * 0.6, B * 0.6); cairo_set_source(cr, pat); cairo_fill_preserve(cr); cairo_pattern_destroy(pat); } if(line) { cairo_set_line_width(cr, 0.5); cairo_set_source_rgba(cr, 0, 0, 0, 0.9); cairo_stroke(cr); } }
static void clearlooks_glossy_draw_toolbar (cairo_t *cr, const ClearlooksColors *colors, const WidgetParameters *widget, const ToolbarParameters *toolbar, int x, int y, int width, int height) { const CairoColor *fill = &colors->bg[GTK_STATE_NORMAL]; const CairoColor *dark = &colors->shade[3]; CairoColor light; ge_shade_color (fill, 1.1, &light); cairo_set_line_width (cr, 1.0); cairo_translate (cr, x, y); if (toolbar->style == 1) /* Enable Extra features */ { cairo_pattern_t *pattern; CairoColor shade1, shade2, shade3; ge_shade_color (fill, 1.08, &shade1); ge_shade_color (fill, 1.04, &shade2); ge_shade_color (fill, 1.04, &shade3); /* Draw the fill */ pattern = cairo_pattern_create_linear (0, 0, 0, height); cairo_pattern_add_color_stop_rgb (pattern, 0.0, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 0.5, fill->r, fill->g, fill->b); cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade3.r, shade3.g, shade3.b); cairo_set_source (cr, pattern); cairo_rectangle (cr, 0, 0, width, height); cairo_fill (cr); cairo_pattern_destroy (pattern); } else /* Flat */ { ge_cairo_set_color (cr, fill); cairo_paint (cr); if (!toolbar->topmost) { /* Draw highlight */ cairo_move_to (cr, 0, 0.5); cairo_line_to (cr, width-1, 0.5); ge_cairo_set_color (cr, &light); cairo_stroke (cr); } } /* Draw shadow */ cairo_move_to (cr, 0, height-0.5); cairo_line_to (cr, width-1, height-0.5); ge_cairo_set_color (cr, dark); cairo_stroke (cr); }
static void add_line(CrItem *group) { int i, total; double angle, dist, cx, cy, x, y; GArray *array; CrItem *line; guint color; cairo_pattern_t *pattern; array = g_array_new(FALSE, FALSE, sizeof(double)); total = g_random_int_range(3, 30); cx = g_random_double_range(40, 360); cy = g_random_double_range(40, 360); for (i = 0, angle = 0; i < total; angle += 2. * M_PI/total, i++) { dist = g_random_double_range(10, 40); x = cx + dist * sin(angle); y = cy + dist * cos(angle); g_array_append_val(array, x); g_array_append_val(array, y); } line = cr_line_new(group, "array", array, "outline_color_rgba", 0x000000ff, "line_scaleable", TRUE, "line_width", 3.0, NULL); if (g_random_boolean()) { color = g_random_int_range(0,255) << 24 | g_random_int_range(0,255) << 16 | g_random_int_range(0,255) << 8 | 0xff; g_object_set(line, "fill_color_rgba", color, NULL); } else { pattern = cairo_pattern_create_linear(0, 0, g_random_double_range(5, 20), g_random_double_range(5, 20)); cairo_pattern_add_color_stop_rgb(pattern, 0, g_random_double(), g_random_double(), g_random_double()); cairo_pattern_add_color_stop_rgb(pattern, 10, g_random_double(), g_random_double(), g_random_double()); cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT); g_object_set(line, "pattern", pattern, NULL); cairo_pattern_destroy(pattern); } g_signal_connect(line, "event", (GCallback) item_event, NULL); }
static cairo_pattern_t * create_node_pattern(double r, double g, double b) { cairo_pattern_t *retval = cairo_pattern_create_radial(0.0, -0.33, 0.0, 0.0, 0.0, 1.0); cairo_pattern_add_color_stop_rgb(retval, 0.0, MAX(1.0, r * 1.5), MAX(1.0, g * 1.5), MAX(1.0, b * 1.5)); cairo_pattern_add_color_stop_rgb(retval, 0.5, r, g, b); cairo_pattern_add_color_stop_rgb(retval, 0.75, r * 0.5, g * 0.5, b * 0.5); cairo_pattern_add_color_stop_rgb(retval, 1.0, r, g, b); return retval; }
static void terranova_draw_candy_progressbar_trough (cairo_t *cr, const terranovaColors *colors, const WidgetParameters *params, int x, int y, int width, int height) { const CairoColor *border = &colors->shade[6]; cairo_pattern_t *pattern; const CairoColor *fill = &colors->bg[params->state_type]; double radius = MIN (params->radius, MIN ((width - 4.0) / 2.0, (height - 4.0) / 2.0)); cairo_save (cr); cairo_set_line_width (cr, 1.0); /* Create trough box */ tn_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners); tn_cairo_set_color (cr, &colors->shade[1]); cairo_fill (cr); /* Draw border */ tn_cairo_rounded_rectangle (cr, x+0.5, y+0.5, width-1, height-1, radius, params->corners); tn_cairo_set_color (cr, border); cairo_stroke (cr); /* clip the corners of the shadows */ tn_cairo_rounded_rectangle (cr, x+1, y+1, width-2, height-2, radius, params->corners); cairo_clip (cr); if (height > width) { int tmp = height; height = width; width = tmp; terranova_mirror_rotate (cr, G_PI/2, x, y, FALSE, FALSE); } CairoColor shade1, shade2; tn_shade_color (fill, 0.96, &shade1); tn_shade_color (fill, 1.10, &shade2); pattern = cairo_pattern_create_linear (x, y + 1, x, y + height); cairo_pattern_add_color_stop_rgb (pattern, 0.00, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.35, shade1.r, shade1.g, shade1.b); cairo_pattern_add_color_stop_rgb (pattern, 0.65, shade2.r, shade2.g, shade2.b); cairo_pattern_add_color_stop_rgb (pattern, 1.00, shade2.r, shade2.g, shade2.b); cairo_set_source (cr, pattern); tn_cairo_rounded_rectangle (cr, 0, 0, width - 1, height - 1, params->radius, params->corners); cairo_fill (cr); cairo_pattern_destroy (pattern); }
static void towel_window_set_background_color(towel_window_t *win, cairo_t *cr) { cairo_pattern_t* pat = cairo_pattern_create_linear(win->width/2, 0, win->width/2, win->height); cairo_pattern_add_color_stop_rgb(pat, 0, .1, .1, .1); cairo_pattern_add_color_stop_rgb(pat, 1, .2, .2, .2); cairo_set_source(cr, pat); cairo_rectangle(cr, 0, 0, win->width, win->height); cairo_fill(cr); cairo_pattern_destroy(pat); }
void arrow_1_glyph(cairo_t *cr) { static cairo_pattern_t *pat_in, *pat_out = 0; if(pat_in == 0) { pat_in = cairo_pattern_create_radial (ARROW_HEAD_START-0.1, 0.25, 0.01, ARROW_HEAD_START-0.1, 0.25, 1.0); cairo_pattern_add_color_stop_rgb (pat_in, 0, 1.0, 0.9, 0.88); cairo_pattern_add_color_stop_rgb (pat_in, ARROW_BODY_RADIUS*(0.7), 1.0, 0.35, 0.35); cairo_pattern_add_color_stop_rgb (pat_in, 1, 0.7, 0.0, 0.0); } if(pat_out == 0) { pat_out = cairo_pattern_create_radial (0, 0, ARROW_BODY_RADIUS, 0.03, 0, 0.3); cairo_pattern_add_color_stop_rgba(pat_out, 0, 1.0, 0.3, 0.3, 0.6); cairo_pattern_add_color_stop_rgba(pat_out, 1, 1.0, 0.1, 0.1, 0.0); } cairo_save(cr); cairo_translate(cr,ARROW_POS_X,ARROW_POS_Y); cairo_new_path(cr); cairo_move_to(cr,0.0,0.0); cairo_line_to(cr,0.0,0.5); cairo_line_to(cr,1.0,0.5); cairo_line_to(cr,1.0,0.0); cairo_close_path(cr); cairo_save(cr); cairo_translate(cr,ARROW_HEAD_START-0.1, 0.25); cairo_scale(cr,1.7,0.9); cairo_set_source(cr,pat_out); cairo_fill(cr); cairo_restore(cr); cairo_new_path(cr); cairo_move_to(cr,ARROW_BODY_START,0.25-ARROW_BODY_RADIUS); cairo_line_to(cr,ARROW_BODY_START,0.25+ARROW_BODY_RADIUS); cairo_line_to(cr,ARROW_HEAD_START,0.25+ARROW_BODY_RADIUS); cairo_line_to(cr,ARROW_HEAD_START,0.25+ARROW_HEAD_RADIUS); cairo_line_to(cr,ARROW_HEAD_END,0.25); cairo_line_to(cr,ARROW_HEAD_START,0.25-ARROW_HEAD_RADIUS); cairo_line_to(cr,ARROW_HEAD_START,0.25-ARROW_BODY_RADIUS); cairo_close_path(cr); cairo_set_source(cr,pat_in); cairo_fill_preserve(cr); cairo_set_source_rgb(cr,0,0,0); cairo_set_line_width(cr,0.03); cairo_clip_preserve(cr); cairo_stroke(cr); cairo_restore(cr); }
void TaskbarButton::Draw(cairo_t *cr) { // We only draw the button if it's pressed if (m_pressed) { double start_colour; double end_colour; double bound_colour; double percent; start_colour = START_COLOUR * 0.90; end_colour = END_COLOUR * 0.90; bound_colour = end_colour * 0.5; percent = 0.3; cairo_pattern_t *pattern; double x, y, w, h, r; x = 1.5; y = 1.5; w = m_draw_size.m_width - 3.0; h = m_draw_size.m_height - 1.5; r = 3.0; /* Create the path around the button */ cairo_new_sub_path (cr); cairo_arc (cr, x + r, y + r, r, M_PI, 3*M_PI/2); cairo_arc (cr, x + w - r, y + r, r, 3*M_PI/2, 0 ); cairo_arc (cr, x + w - r, y + h - r, r, 0, M_PI/2 ); cairo_arc (cr, x + r, y + h - r, r, M_PI/2, M_PI ); cairo_close_path (cr); /* Create the fill pattern - varying vertically */ pattern = cairo_pattern_create_linear(x, y, x, y + h); cairo_pattern_add_color_stop_rgb(pattern, 0.0, start_colour*m_colour.redf(), start_colour*m_colour.greenf(), start_colour*m_colour.bluef()); cairo_pattern_add_color_stop_rgb(pattern, 1.0, end_colour*m_colour.redf(), end_colour*m_colour.greenf(), end_colour*m_colour.bluef()); /* Fill with our pattern */ cairo_set_source(cr, pattern); cairo_fill_preserve (cr); /* Destroy the pattern */ cairo_pattern_destroy(pattern); /* Draw the outline */ cairo_set_source_rgb (cr, bound_colour, bound_colour, bound_colour); cairo_set_line_width (cr, 1.0); cairo_stroke (cr); } drawChild(cr); }
/* Draw the gradient rectangle for the greyramp tool */ static void drawGradient(GdkDrawable *drawable, GtkWidget *greyramp) { GreyrampProperties *properties = greyrampGetProperties(greyramp); GdkRectangle *rect = &properties->gradientRect; /* Create a gradient */ cairo_pattern_t *pattern = cairo_pattern_create_linear(rect->x, rect->y, rect->x + rect->width, rect->y); /* If the positions are the same, make the black pos slightly smaller (to emulate historic behaviour) */ int whitePoint = properties->whitePoint; int blackPoint = properties->blackPoint; if (whitePoint == blackPoint) { if (blackPoint <= 1) { whitePoint += 1; } else { blackPoint -= 1; } } /* Get the white and black points as fractions of 1.0 */ gdouble blackPos = blackPoint / ((gdouble)GREYRAMP_MAX); gdouble whitePos = whitePoint / ((gdouble)GREYRAMP_MAX); /* Add a stop at the start and end. The start is white if the whitePos is less than blackPos */ const int whiteEnd = whitePos < blackPos ? 0 : 1; const int blackEnd = whitePos < blackPos ? 1 : 0; cairo_pattern_add_color_stop_rgb(pattern, whiteEnd, 1.0, 1.0, 1.0); cairo_pattern_add_color_stop_rgb(pattern, blackEnd, 0.0, 0.0, 0.0); /* Add stop points at the black/white positions */ cairo_pattern_add_color_stop_rgb(pattern, whitePos, 1.0, 1.0, 1.0); cairo_pattern_add_color_stop_rgb(pattern, blackPos, 0.0, 0.0, 0.0); if (cairo_pattern_status(pattern) == CAIRO_STATUS_SUCCESS) { cairo_t *cr = gdk_cairo_create(drawable); gdk_cairo_rectangle(cr, rect); cairo_set_source(cr, pattern); cairo_fill(cr); cairo_destroy(cr); } cairo_pattern_destroy(pattern); }
static cairo_test_status_t draw (cairo_t *cr, int width, int height) { cairo_pattern_t *pattern; unsigned int i, j; cairo_extend_t extend[NUM_EXTEND] = { CAIRO_EXTEND_NONE, CAIRO_EXTEND_REPEAT, CAIRO_EXTEND_REFLECT, CAIRO_EXTEND_PAD }; cairo_test_paint_checkered (cr); pattern = cairo_pattern_create_linear (0, 2*PAD, 0, HEIGHT - 2*PAD); cairo_pattern_add_color_stop_rgb (pattern, 0, 0, 0, 1); cairo_pattern_add_color_stop_rgb (pattern, 1, 0, 0, 1); cairo_translate (cr, PAD, PAD); for (i = 0; i < 2; i++) { cairo_save (cr); for (j = 0; j < NUM_EXTEND; j++) { cairo_pattern_set_extend (pattern, extend[j]); cairo_reset_clip (cr); cairo_rectangle (cr, 0, 0, WIDTH, HEIGHT); cairo_clip (cr); if (i & 1) { cairo_set_source_rgb (cr, 0, 1, 0); cairo_mask (cr, pattern); } else { cairo_set_source (cr, pattern); cairo_paint (cr); } cairo_translate (cr, WIDTH+PAD, 0); } cairo_restore (cr); cairo_translate (cr, 0, HEIGHT+PAD); } cairo_pattern_destroy (pattern); return CAIRO_TEST_SUCCESS; }
static cairo_test_status_t draw (cairo_t *cr, int width, int height) { const double alpha = 1./3; cairo_pattern_t *pattern; int n; /* draw a simple pattern behind */ pattern = cairo_pattern_create_linear (0, 0, width, height); cairo_pattern_add_color_stop_rgb (pattern, 0, 1, 1, 0); cairo_pattern_add_color_stop_rgb (pattern, 1, 1, 1, 1); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); cairo_paint (cr); /* square */ cairo_rectangle (cr, PAD, PAD, SIZE, SIZE); cairo_set_source_rgba (cr, 1, 0, 0, alpha); cairo_fill (cr); /* circle */ cairo_translate (cr, SIZE + 2 * PAD, 0); cairo_arc (cr, PAD + SIZE / 2., PAD + SIZE / 2., SIZE / 2., 0, 2 * M_PI); cairo_set_source_rgba (cr, 0, 1, 0, alpha); cairo_fill (cr); /* triangle */ cairo_translate (cr, 0, SIZE + 2 * PAD); cairo_move_to (cr, PAD + SIZE / 2, PAD); cairo_line_to (cr, PAD + SIZE, PAD + SIZE); cairo_line_to (cr, PAD, PAD + SIZE); cairo_set_source_rgba (cr, 0, 0, 1, alpha); cairo_fill (cr); /* star */ cairo_translate (cr, -(SIZE + 2 * PAD) + SIZE/2., SIZE/2.); for (n = 0; n < 5; n++) { cairo_line_to (cr, SIZE/2 * cos (2*n * 2*M_PI / 10), SIZE/2 * sin (2*n * 2*M_PI / 10)); cairo_line_to (cr, SIZE/4 * cos ((2*n+1)*2*M_PI / 10), SIZE/4 * sin ((2*n+1)*2*M_PI / 10)); } cairo_set_source_rgba (cr, 0, 0, 0, alpha); cairo_fill (cr); return CAIRO_TEST_SUCCESS; }
int main (int argc, char *argv[]) { GtkWidget *window; GtkWidget *darea; GError *error; int i; rgba_t bgcolor1, bgcolor2; error = NULL; gtk_init_with_args (&argc, &argv, "circlesaver", options, NULL, &error); window = gs_theme_window_new(); darea = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER (window), darea); g_signal_connect(darea, "expose-event", G_CALLBACK (on_expose_event), NULL); g_signal_connect(window, "destroy", G_CALLBACK (gtk_main_quit), NULL); for (i = 0; i < NUM_CIRCLES; ++i) { circles[i] = gen_circle(i); } bgcolor1 = color(0xFF000000); bgcolor2 = color(0xFF705391); bgpattern = cairo_pattern_create_linear(100.5, 0.0, 100.5, 500.0); cairo_pattern_add_color_stop_rgb(bgpattern, 0.0, bgcolor1.r, bgcolor1.g, bgcolor1.b); cairo_pattern_add_color_stop_rgb(bgpattern, 1.0, bgcolor2.r, bgcolor2.g, bgcolor2.b); g_timeout_add_full (G_PRIORITY_HIGH, UPDATE_FREQ, timeout_callback, darea, NULL); //g_timeout_add (UPDATE_FREQ, timeout_callback, darea); if ((geometry == NULL) || !gtk_window_parse_geometry (GTK_WINDOW (window), geometry)) gtk_window_set_default_size (GTK_WINDOW (window), 640, 480); gtk_widget_show_all(window); gtk_main(); cairo_pattern_destroy(bgpattern); return 0; }
void draw_mask(cairo_t *cr) { cairo_pattern_t *linpat, *radpat; linpat = cairo_pattern_create_linear (0, 1, 1, 1); cairo_pattern_add_color_stop_rgb (linpat, 1, 0, 0, 0); //offset ,r,g,b cairo_pattern_add_color_stop_rgb (linpat, 1, 0, 0, 0); radpat = cairo_pattern_create_radial (300,200, 100, 300,200, 400); cairo_pattern_add_color_stop_rgba (radpat, 1, 0, 0, 0, 0.5); cairo_pattern_add_color_stop_rgba (radpat, 1, 0, 0, 0, 0.5); cairo_set_source (cr, linpat); cairo_mask (cr, radpat); }
static void gradientFill(cairo_t* cairo, double yStart, double yLength, bool inverted = false) { double gradStartColor = BGColor1; double gradEndColor = BGColor2; if (inverted) std::swap(gradStartColor, gradEndColor); cairo_pattern_t* gradient = cairo_pattern_create_linear(0, yStart, 0, yStart + yLength); cairo_pattern_add_color_stop_rgb(gradient, 0, gradStartColor, gradStartColor, gradStartColor); cairo_pattern_add_color_stop_rgb(gradient, 1, gradEndColor, gradEndColor, gradEndColor); cairo_set_source(cairo, gradient); cairo_fill(cairo); cairo_pattern_destroy(gradient); }
static void clearlooks_set_border_gradient (cairo_t *cr, const CairoColor *color, double hilight, int width, int height) { cairo_pattern_t *pattern; CairoColor bottom_shade; ge_shade_color (color, hilight, &bottom_shade); pattern = cairo_pattern_create_linear (0, 0, width, height); cairo_pattern_add_color_stop_rgb (pattern, 0, color->r, color->g, color->b); cairo_pattern_add_color_stop_rgb (pattern, 1, bottom_shade.r, bottom_shade.g, bottom_shade.b); cairo_set_source (cr, pattern); cairo_pattern_destroy (pattern); }
static void set_source_linear_rgb (cairo_t *cr, int width, int height) { cairo_pattern_t *linear; linear = cairo_pattern_create_linear (0.0, 0.0, width, height); cairo_pattern_add_color_stop_rgb (linear, 0.0, 1, 0, 0); /* red */ cairo_pattern_add_color_stop_rgb (linear, 1.0, 0, 0, 1); /* blue */ cairo_set_source (cr, linear); cairo_pattern_destroy (linear); }