static PyObject * solid_pattern_get_rgba (PycairoSolidPattern *o) { double red, green, blue, alpha; cairo_pattern_get_rgba (o->pattern, &red, &green, &blue, &alpha); return Py_BuildValue("(dddd)", red, green, blue, alpha); }
void CairoDevice::PushPenColor( const VGColor & color) { double r, g, b, a; cairo_pattern_get_rgba (cairo_get_source(fNativeDevice), &r, &g, &b, &a); fPenColorStack.push (VGColor(cc2c(r), cc2c(g), cc2c(b), cc2c(a))); SelectPenColor (color); }
void CairoRenderer::Stroke(void) { double r, g, b, a; cairo_pattern_get_rgba(cairo_get_source(m_pCairo), &r, &g, &b, &a); cairo_set_source_rgba(m_pCairo, m_pStrokeColor[0], m_pStrokeColor[1], m_pStrokeColor[2], 1.0); cairo_stroke(m_pCairo); cairo_set_source_rgba(m_pCairo, r, g, b, 1.0); }
bool gfxContext::GetDeviceColor(gfxRGBA& c) { return cairo_pattern_get_rgba(cairo_get_source(mCairo), &c.r, &c.g, &c.b, &c.a) == CAIRO_STATUS_SUCCESS; }
static VALUE cr_solid_pattern_get_rgba (VALUE self) { double red, green, blue, alpha; rb_cairo_check_status (cairo_pattern_get_rgba (_SELF (self), &red, &green, &blue, &alpha)); return rb_ary_new3 (4, rb_float_new (red), rb_float_new (green), rb_float_new (blue), rb_float_new (alpha)); }
static int cairo_pattern_get_rgba_l( lua_State* L ) { double red = 0.0; double green = 0.0; double blue = 0.0; double alpha = 0.0; lua_cairo_pattern_t* lcp = lua_cairo_pattern_check( L, 1 ); if ( cairo_pattern_get_rgba( lcp->pattern, &red, &green, &blue, &alpha ) ) { luaL_argerror( L, 1, "pattern is not a solid color pattern" ); } lua_pushnumber( L, red ); lua_pushnumber( L, green ); lua_pushnumber( L, blue ); lua_pushnumber( L, alpha ); return( 4 ); }
static void _gtk_pixel_cache_create_surface_if_needed (GtkPixelCache *cache, GdkWindow *window, cairo_rectangle_int_t *view_rect, cairo_rectangle_int_t *canvas_rect) { cairo_rectangle_int_t rect; int surface_w, surface_h; cairo_content_t content; cairo_pattern_t *bg; double red, green, blue, alpha; content = CAIRO_CONTENT_COLOR_ALPHA; bg = gdk_window_get_background_pattern (window); if (bg != NULL && cairo_pattern_get_type (bg) == CAIRO_PATTERN_TYPE_SOLID && cairo_pattern_get_rgba (bg, &red, &green, &blue, &alpha) == CAIRO_STATUS_SUCCESS && alpha == 1.0) content = CAIRO_CONTENT_COLOR; surface_w = view_rect->width; if (canvas_rect->width > surface_w) surface_w = MIN (surface_w + EXTRA_SIZE, canvas_rect->width); surface_h = view_rect->height; if (canvas_rect->height > surface_h) surface_h = MIN (surface_h + EXTRA_SIZE, canvas_rect->height); /* If current surface can't fit view_rect or is too large, kill it */ if (cache->surface != NULL && (cairo_surface_get_content (cache->surface) != content || cache->surface_w < view_rect->width || cache->surface_w > surface_w + ALLOW_LARGER_SIZE || cache->surface_h < view_rect->height || cache->surface_h > surface_h + ALLOW_LARGER_SIZE || cache->surface_scale != gdk_window_get_scale_factor (window))) { cairo_surface_destroy (cache->surface); cache->surface = NULL; if (cache->surface_dirty) cairo_region_destroy (cache->surface_dirty); cache->surface_dirty = NULL; } /* Don't allocate a surface if view >= canvas, as we won't be scrolling then anyway */ if (cache->surface == NULL && (view_rect->width < canvas_rect->width || view_rect->height < canvas_rect->height)) { cache->surface_x = -canvas_rect->x; cache->surface_y = -canvas_rect->y; cache->surface_w = surface_w; cache->surface_h = surface_h; cache->surface_scale = gdk_window_get_scale_factor (window); cache->surface = gdk_window_create_similar_surface (window, content, surface_w, surface_h); rect.x = 0; rect.y = 0; rect.width = surface_w; rect.height = surface_h; cache->surface_dirty = cairo_region_create_rectangle (&rect); } }
static cairo_test_status_t draw (cairo_t *cr, int width, int height) { const cairo_test_context_t *ctx = cairo_test_get_context (cr); cairo_status_t status; cairo_pattern_t *pat; /* Test pattern_get_rgba */ { double r, g, b, a; pat = cairo_pattern_create_rgba (0.2, 0.3, 0.4, 0.5); status = cairo_pattern_get_rgba (pat, &r, &g, &b, &a); CHECK_SUCCESS; if (!CAIRO_TEST_DOUBLE_EQUALS(r,0.2) || !CAIRO_TEST_DOUBLE_EQUALS(g,0.3) || !CAIRO_TEST_DOUBLE_EQUALS(b,0.4) || !CAIRO_TEST_DOUBLE_EQUALS(a,0.5)) { cairo_test_log (ctx, "Error: cairo_pattern_get_rgba returned unexepcted results: %g, %g, %g, %g\n", r, g, b, a); return CAIRO_TEST_FAILURE; } cairo_pattern_destroy (pat); } /* Test pattern_get_surface */ { cairo_surface_t *surf; pat = cairo_pattern_create_for_surface (cairo_get_target (cr)); status = cairo_pattern_get_surface (pat, &surf); CHECK_SUCCESS; if (surf != cairo_get_target (cr)) { cairo_test_log (ctx, "Error: cairo_pattern_get_resurface returned wrong surface\n"); return CAIRO_TEST_FAILURE; } cairo_pattern_destroy (pat); } /* Test get_color_stops & linear_get_points */ { int i; double x0, y0, x1, y1; double expected_values[15] = { 0.0, 0.2, 0.4, 0.2, 1.0, 0.5, 0.4, 0.5, 0.2, 0.5, 1.0, 0.2, 0.4, 0.5, 0.2 }; double new_buf[15]; pat = cairo_pattern_create_linear (1.0, 2.0, 3.0, 4.0); for (i = 0; i < 3; i++) { cairo_pattern_add_color_stop_rgba (pat, expected_values[i*5+0], expected_values[i*5+1], expected_values[i*5+2], expected_values[i*5+3], expected_values[i*5+4]); } status = cairo_pattern_get_linear_points (pat, &x0, &y0, &x1, &y1); CHECK_SUCCESS; if (!CAIRO_TEST_DOUBLE_EQUALS(x0,1.0) || !CAIRO_TEST_DOUBLE_EQUALS(y0,2.0) || !CAIRO_TEST_DOUBLE_EQUALS(x1,3.0) || !CAIRO_TEST_DOUBLE_EQUALS(y1,4.0)) return CAIRO_TEST_FAILURE; status = cairo_pattern_get_color_stop_count (pat, &i); CHECK_SUCCESS; if (i != 3) return CAIRO_TEST_FAILURE; for (i = 0; i < 3; i++) { status = cairo_pattern_get_color_stop_rgba (pat, i, &new_buf[i*5+0], &new_buf[i*5+1], &new_buf[i*5+2], &new_buf[i*5+3], &new_buf[i*5+4]); CHECK_SUCCESS; } status = cairo_pattern_get_color_stop_rgba (pat, 5, NULL, NULL, NULL, NULL, NULL); if (status != CAIRO_STATUS_INVALID_INDEX) return CAIRO_TEST_FAILURE; if (!double_buf_equal (ctx, new_buf, expected_values, sizeof(expected_values)/sizeof(double)) != 0) return CAIRO_TEST_FAILURE; cairo_pattern_destroy (pat); } /* Test radial_get_circles */ { double a, b, c, d, e, f; pat = cairo_pattern_create_radial (1, 2, 3, 4, 5, 6); status = cairo_pattern_get_radial_circles (pat, &a, &b, &c, &d, &e, &f); CHECK_SUCCESS; if (!CAIRO_TEST_DOUBLE_EQUALS(a,1.0) || !CAIRO_TEST_DOUBLE_EQUALS(b,2.0) || !CAIRO_TEST_DOUBLE_EQUALS(c,3.0) || !CAIRO_TEST_DOUBLE_EQUALS(d,4.0) || !CAIRO_TEST_DOUBLE_EQUALS(e,5.0) || !CAIRO_TEST_DOUBLE_EQUALS(f,6.0)) return CAIRO_TEST_FAILURE; cairo_pattern_destroy (pat); } cairo_set_source_rgb (cr, 0, 1, 0); cairo_paint (cr); return CAIRO_TEST_SUCCESS; }