本文整理汇总了C++中cairo_set_source_rgba函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_set_source_rgba函数的具体用法?C++ cairo_set_source_rgba怎么用?C++ cairo_set_source_rgba使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_set_source_rgba函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: locate_pointer_paint
static void
locate_pointer_paint (GsdLocatePointerData *data,
cairo_t *cr,
gboolean composite)
{
GdkRGBA color;
gdouble progress, circle_progress;
gint width, height, i;
GtkStyleContext *context;
progress = data->progress;
width = gdk_window_get_width (data->window);
height = gdk_window_get_height (data->window);
context = gtk_widget_get_style_context (data->widget);
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &color);
cairo_set_source_rgba (cr, 1., 1., 1., 0.);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
for (i = 0; i <= N_CIRCLES; i++)
{
if (progress < 0.)
break;
circle_progress = MIN (1., (progress * 2));
progress -= CIRCLES_PROGRESS_INTERVAL;
if (circle_progress >= 1.)
continue;
if (composite)
{
cairo_set_source_rgba (cr,
color.red,
color.green,
color.blue,
1 - circle_progress);
cairo_arc (cr,
width / 2,
height / 2,
circle_progress * width / 2,
0, 2 * G_PI);
cairo_fill (cr);
}
else
{
cairo_set_source_rgb (cr, 0., 0., 0.);
cairo_set_line_width (cr, 3.);
cairo_arc (cr,
width / 2,
height / 2,
circle_progress * width / 2,
0, 2 * G_PI);
cairo_stroke (cr);
cairo_set_source_rgb (cr, 1., 1., 1.);
cairo_set_line_width (cr, 1.);
cairo_arc (cr,
width / 2,
height / 2,
circle_progress * width / 2,
0, 2 * G_PI);
cairo_stroke (cr);
}
}
}
开发者ID:martyr-deepin,项目名称:deepin-settings-daemon,代码行数:69,代码来源:gsd-locate-pointer.c
示例2: clearlooks_glossy_draw_progressbar_fill
static void
clearlooks_glossy_draw_progressbar_fill (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *params,
const ProgressBarParameters *progressbar,
int x, int y, int width, int height,
gint offset)
{
boolean is_horizontal = progressbar->orientation < 2;
double tile_pos = 0;
double stroke_width;
double radius;
int x_step;
cairo_pattern_t *pattern;
CairoColor a;
CairoColor b;
CairoColor e;
CairoColor border;
CairoColor shadow;
radius = MAX (0, params->radius - params->xthickness);
cairo_save (cr);
if (!is_horizontal)
ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
if ((progressbar->orientation == CL_ORIENTATION_RIGHT_TO_LEFT) || (progressbar->orientation == CL_ORIENTATION_BOTTOM_TO_TOP))
ge_cairo_mirror (cr, CR_MIRROR_HORIZONTAL, &x, &y, &width, &height);
/* Clamp the radius so that the _height_ fits ... */
radius = MIN (radius, height / 2.0);
stroke_width = height*2;
x_step = (((float)stroke_width/10)*offset); /* This looks weird ... */
cairo_translate (cr, x, y);
cairo_save (cr);
/* This is kind of nasty ... Clip twice from each side in case the length
* of the fill is smaller than twice the radius. */
ge_cairo_rounded_rectangle (cr, 0, 0, width + radius, height, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
cairo_clip (cr);
ge_cairo_rounded_rectangle (cr, -radius, 0, width + radius, height, radius, CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT);
cairo_clip (cr);
/* Draw the background gradient */
ge_shade_color (&colors->spot[1], 1.16, &a);
ge_shade_color (&colors->spot[1], 1.08, &b);
ge_shade_color (&colors->spot[1], 1.08, &e);
pattern = cairo_pattern_create_linear (0, 0, 0, height);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, a.r, a.g, a.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.5, b.r, b.g, b.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.5, colors->spot[1].r, colors->spot[1].g, colors->spot[1].b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, e.r, e.g, e.b);
cairo_set_source (cr, pattern);
cairo_paint (cr);
cairo_pattern_destroy (pattern);
/* Draw the Strokes */
while (stroke_width > 0 && tile_pos <= width+x_step)
{
cairo_move_to (cr, stroke_width/2-x_step, 0);
cairo_line_to (cr, stroke_width-x_step, 0);
cairo_line_to (cr, stroke_width/2-x_step, height);
cairo_line_to (cr, -x_step, height);
cairo_translate (cr, stroke_width, 0);
tile_pos += stroke_width;
}
cairo_set_source_rgba (cr, colors->spot[2].r,
colors->spot[2].g,
colors->spot[2].b,
0.15);
cairo_fill (cr);
cairo_restore (cr); /* rounded clip region */
/* inner highlight border
* This is again kinda ugly. Draw once from each side, clipping away the other. */
cairo_set_source_rgba (cr, colors->spot[0].r, colors->spot[0].g, colors->spot[0].b, 0.3);
/* left side */
cairo_save (cr);
cairo_rectangle (cr, 0, 0, width / 2, height);
cairo_clip (cr);
if (progressbar->pulsing)
ge_cairo_rounded_rectangle (cr, 1.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
else
ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width + radius, height - 1, radius, CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT);
cairo_stroke (cr);
cairo_restore (cr); /* clip */
/* right side */
cairo_save (cr);
cairo_rectangle (cr, width / 2, 0, (width+1) / 2, height);
//.........这里部分代码省略.........
开发者ID:GNOME,项目名称:gtk-theme-engine-clearlooks,代码行数:101,代码来源:clearlooks_draw_glossy.c
示例3: cairo_save
void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer,
int from, int numGlyphs, const FloatPoint& point) const
{
cairo_t* cr = context->platformContext();
cairo_save(cr);
cairo_set_scaled_font(cr, font->platformData().scaledFont());
GlyphBufferGlyph* glyphs = (GlyphBufferGlyph*)glyphBuffer.glyphs(from);
float offset = 0.0f;
for (int i = 0; i < numGlyphs; i++) {
glyphs[i].x = offset;
glyphs[i].y = 0.0f;
offset += glyphBuffer.advanceAt(from + i);
}
Color fillColor = context->fillColor();
// Synthetic Oblique
if(font->platformData().syntheticOblique()) {
cairo_matrix_t mat = {1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, point.x(), point.y()};
cairo_transform(cr, &mat);
} else {
cairo_translate(cr, point.x(), point.y());
}
// Text shadow, inspired by FontMac
IntSize shadowSize;
int shadowBlur = 0;
Color shadowColor;
bool hasShadow = context->textDrawingMode() == cTextFill &&
context->getShadow(shadowSize, shadowBlur, shadowColor);
// TODO: Blur support
if (hasShadow) {
// Disable graphics context shadows (not yet implemented) and paint them manually
context->clearShadow();
Color shadowFillColor(shadowColor.red(), shadowColor.green(), shadowColor.blue(), shadowColor.alpha() * fillColor.alpha() / 255);
cairo_save(cr);
float red, green, blue, alpha;
shadowFillColor.getRGBA(red, green, blue, alpha);
cairo_set_source_rgba(cr, red, green, blue, alpha);
#if ENABLE(FILTERS)
cairo_text_extents_t extents;
cairo_scaled_font_glyph_extents(font->platformData().scaledFont(), glyphs, numGlyphs, &extents);
FloatRect rect(FloatPoint(), FloatSize(extents.width, extents.height));
IntSize shadowBufferSize;
FloatRect shadowRect;
float kernelSize = 0.f;
GraphicsContext::calculateShadowBufferDimensions(shadowBufferSize, shadowRect, kernelSize, rect, shadowSize, shadowBlur);
// Draw shadow into a new ImageBuffer
OwnPtr<ImageBuffer> shadowBuffer = ImageBuffer::create(shadowBufferSize);
GraphicsContext* shadowContext = shadowBuffer->context();
cairo_t* shadowCr = shadowContext->platformContext();
cairo_translate(shadowCr, kernelSize, extents.height + kernelSize);
cairo_set_scaled_font(shadowCr, font->platformData().scaledFont());
cairo_show_glyphs(shadowCr, glyphs, numGlyphs);
if (font->syntheticBoldOffset()) {
cairo_save(shadowCr);
cairo_translate(shadowCr, font->syntheticBoldOffset(), 0);
cairo_show_glyphs(shadowCr, glyphs, numGlyphs);
cairo_restore(shadowCr);
}
cairo_translate(cr, 0.0, -extents.height);
context->createPlatformShadow(shadowBuffer.release(), shadowColor, shadowRect, kernelSize);
#else
cairo_translate(cr, shadowSize.width(), shadowSize.height());
cairo_show_glyphs(cr, glyphs, numGlyphs);
if (font->syntheticBoldOffset()) {
cairo_save(cr);
cairo_translate(cr, font->syntheticBoldOffset(), 0);
cairo_show_glyphs(cr, glyphs, numGlyphs);
cairo_restore(cr);
}
#endif
cairo_restore(cr);
}
if (context->textDrawingMode() & cTextFill) {
if (context->fillGradient()) {
cairo_set_source(cr, context->fillGradient()->platformGradient());
if (context->getAlpha() < 1.0f) {
cairo_push_group(cr);
cairo_paint_with_alpha(cr, context->getAlpha());
cairo_pop_group_to_source(cr);
}
} else if (context->fillPattern()) {
AffineTransform affine;
cairo_set_source(cr, context->fillPattern()->createPlatformPattern(affine));
if (context->getAlpha() < 1.0f) {
cairo_push_group(cr);
cairo_paint_with_alpha(cr, context->getAlpha());
//.........这里部分代码省略.........
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:101,代码来源:FontCairo.cpp
示例4: expose_filemanager
static void
expose_filemanager (dt_view_t *self, cairo_t *cr, int32_t width, int32_t height, int32_t pointerx, int32_t pointery)
{
dt_library_t *lib = (dt_library_t *)self->data;
gboolean offset_changed = FALSE;
/* query new collection count */
lib->collection_count = dt_collection_get_count (darktable.collection);
if(darktable.gui->center_tooltip == 1)
darktable.gui->center_tooltip = 2;
/* get grid stride */
const int iir = dt_conf_get_int("plugins/lighttable/images_in_row");
/* get image over id */
lib->image_over = DT_VIEW_DESERT;
int32_t mouse_over_id, mouse_over_group = -1;
DT_CTL_GET_GLOBAL(mouse_over_id, lib_image_mouse_over_id);
/* fill background */
cairo_set_source_rgb (cr, .2, .2, .2);
cairo_paint(cr);
if(lib->first_visible_zoomable >= 0)
{
lib->offset = lib->first_visible_zoomable;
}
lib->first_visible_zoomable = -1;
/* check if offset has been changed */
if(lib->track > 2) lib->offset += iir;
if(lib->track < -2) lib->offset -= iir;
lib->track = 0;
if(lib->center) lib->offset = 0;
lib->center = 0;
int offset = lib->offset;
/* if offset differs then flag as changed */
if (offset != lib->first_visible_filemanager)
offset_changed = TRUE;
lib->first_visible_filemanager = offset;
static int oldpan = 0;
const int pan = lib->pan;
const float wd = width/(float)iir;
const float ht = width/(float)iir;
int pi = pointerx / (float)wd;
int pj = pointery / (float)ht;
if(pointerx < 0 || pointery < 0) pi = pj = -1;
//const int pidx = grid_to_index(pj, pi, iir, offset);
const int img_pointerx = iir == 1 ? pointerx : fmodf(pointerx, wd);
const int img_pointery = iir == 1 ? pointery : fmodf(pointery, ht);
const int max_rows = 1 + (int)((height)/ht + .5);
const int max_cols = iir;
int id;
int clicked1 = (oldpan == 0 && pan == 1 && lib->button == 1);
/* get the count of current collection */
if(lib->collection_count == 0)
{
const float fs = 15.0f;
const float ls = 1.5f*fs;
const float offy = height*0.2f;
const float offx = 60;
const float at = 0.3f;
cairo_set_font_size(cr, fs);
cairo_set_source_rgba(cr, .7, .7, .7, 1.0f);
cairo_select_font_face (cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
cairo_move_to(cr, offx, offy);
cairo_show_text(cr, _("there are no images in this collection"));
cairo_move_to(cr, offx, offy + 2*ls);
cairo_show_text(cr, _("if you have not imported any images yet"));
cairo_move_to(cr, offx, offy + 3*ls);
cairo_show_text(cr, _("you can do so in the import module"));
cairo_move_to(cr, offx - 10.0f, offy + 3*ls - ls*.25f);
cairo_line_to(cr, 0.0f, 10.0f);
cairo_set_source_rgba(cr, .7, .7, .7, at);
cairo_stroke(cr);
cairo_move_to(cr, offx, offy + 5*ls);
cairo_set_source_rgba(cr, .7, .7, .7, 1.0f);
cairo_show_text(cr, _("try to relax the filter settings in the top panel"));
cairo_rel_move_to(cr, 10.0f, -ls*.25f);
cairo_line_to(cr, width*0.5f, 0.0f);
cairo_set_source_rgba(cr, .7, .7, .7, at);
cairo_stroke(cr);
cairo_move_to(cr, offx, offy + 6*ls);
cairo_set_source_rgba(cr, .7, .7, .7, 1.0f);
cairo_show_text(cr, _("or add images in the collection module in the left panel"));
cairo_move_to(cr, offx - 10.0f, offy + 6*ls - ls*0.25f);
cairo_rel_line_to(cr, - offx + 10.0f, 0.0f);
cairo_set_source_rgba(cr, .7, .7, .7, at);
cairo_stroke(cr);
//.........这里部分代码省略.........
开发者ID:fgrollier,项目名称:darktable,代码行数:101,代码来源:lighttable.c
示例5: clearlooks_glossy_draw_list_view_header
static void
clearlooks_glossy_draw_list_view_header (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *params,
const ListViewHeaderParameters *header,
int x, int y, int width, int height)
{
/*
CairoColor *border = !params->prelight? (CairoColor*)&colors->shade[4] : (CairoColor*)&colors->spot[1];
*/
const CairoColor *border = &colors->shade[4];
const CairoColor *fill = &colors->bg[params->state_type];
CairoColor hilight;
CairoColor shade1, shade2, shade3;
cairo_pattern_t *pattern;
ge_shade_color (fill, 1.2, &hilight);
ge_shade_color (fill, 1.08, &shade1);
ge_shade_color (fill, 1.04, &shade2);
ge_shade_color (fill, 1.04, &shade3);
cairo_translate (cr, x, y);
cairo_set_line_width (cr, 1.0);
/* 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-1.0/height, shade3.r, shade3.g, shade3.b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0-1.0/height, border->r, border->g, border->b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, border->r, border->g, border->b);
cairo_set_source (cr, pattern);
cairo_rectangle (cr, 0, 0, width, height);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
/* Draw highlight */
if (header->order & CL_ORDER_FIRST)
{
cairo_move_to (cr, 0.5, height-1);
cairo_line_to (cr, 0.5, 0.5);
}
else
cairo_move_to (cr, 0.0, 0.5);
cairo_line_to (cr, width, 0.5);
cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
cairo_stroke (cr);
/* Draw resize grip */
if ((params->ltr && !(header->order & CL_ORDER_LAST)) ||
(!params->ltr && !(header->order & CL_ORDER_FIRST)) || header->resizable)
{
SeparatorParameters separator;
separator.horizontal = FALSE;
if (params->ltr)
params->style_functions->draw_separator (cr, colors, params, &separator,
width-1.5, 4.0, 2, height-8.0);
else
params->style_functions->draw_separator (cr, colors, params, &separator,
1.5, 4.0, 2, height-8.0);
}
}
开发者ID:GNOME,项目名称:gtk-theme-engine-clearlooks,代码行数:69,代码来源:clearlooks_draw_glossy.c
示例6: createImageCairo
imageObj* createImageCairo(int width, int height, outputFormatObj *format,colorObj* bg)
{
imageObj *image = NULL;
cairo_renderer *r=NULL;
if (format->imagemode != MS_IMAGEMODE_RGB && format->imagemode!= MS_IMAGEMODE_RGBA) {
msSetError(MS_MISCERR,
"Cairo driver only supports RGB or RGBA pixel models.","msImageCreateCairo()");
return image;
}
if (width > 0 && height > 0) {
image = (imageObj *) calloc(1, sizeof(imageObj));
r = (cairo_renderer*)calloc(1,sizeof(cairo_renderer));
if(!strcasecmp(format->driver,"cairo/pdf")) {
r->outputStream = (bufferObj*)malloc(sizeof(bufferObj));
msBufferInit(r->outputStream);
r->surface = cairo_pdf_surface_create_for_stream(
_stream_write_fn,
r->outputStream,
width,height);
} else if(!strcasecmp(format->driver,"cairo/svg")) {
r->outputStream = (bufferObj*)malloc(sizeof(bufferObj));
msBufferInit(r->outputStream);
r->surface = cairo_svg_surface_create_for_stream(
_stream_write_fn,
r->outputStream,
width,height);
} else if(!strcasecmp(format->driver,"cairo/winGDI") && format->device) {
#if CAIRO_HAS_WIN32_SURFACE
r->outputStream = NULL;
r->surface = cairo_win32_surface_create(format->device);
#else
msSetError(MS_RENDERERERR, "Cannot create cairo image. Cairo was not compiled with support for the win32 backend.",
"msImageCreateCairo()");
#endif
} else if(!strcasecmp(format->driver,"cairo/winGDIPrint") && format->device) {
#if CAIRO_HAS_WIN32_SURFACE
r->outputStream = NULL;
r->surface = cairo_win32_printing_surface_create(format->device);
#else
msSetError(MS_RENDERERERR, "Cannot create cairo image. Cairo was not compiled with support for the win32 backend.",
"msImageCreateCairo()");
#endif
} else {
r->outputStream = NULL;
r->surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
}
r->cr = cairo_create(r->surface);
if(format->transparent || !bg || !MS_VALID_COLOR(*bg)) {
r->use_alpha = 1;
cairo_set_source_rgba (r->cr, 0,0,0,0);
} else {
r->use_alpha = 0;
msCairoSetSourceColor(r->cr,bg);
}
cairo_save (r->cr);
cairo_set_operator (r->cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (r->cr);
cairo_restore (r->cr);
cairo_set_line_cap (r->cr,CAIRO_LINE_CAP_ROUND);
cairo_set_line_join(r->cr,CAIRO_LINE_JOIN_ROUND);
image->img.plugin = (void*)r;
} else {
msSetError(MS_RENDERERERR, "Cannot create cairo image of size %dx%d.",
"msImageCreateCairo()", width, height);
}
return image;
}
开发者ID:KaiJancke,项目名称:mapserver,代码行数:68,代码来源:mapcairo.c
示例7: cairo_set_source_rgba
void cairo_context::set_color(double r, double g, double b, double opacity)
{
// http://lists.cairographics.org/archives/cairo/2008-August/014759.html
cairo_set_source_rgba(cairo_.get(), r, g, b, opacity);
check_object_status_and_throw_exception(*this);
}
开发者ID:MMyhub,项目名称:mapnik,代码行数:6,代码来源:cairo_context.cpp
示例8: set_translucent_pattern
static void
set_translucent_pattern (cairo_t *cr, int x, int y)
{
cairo_set_source_rgba (cr, 1, 0, 0, 0.5);
}
开发者ID:3oyka,项目名称:cairo2,代码行数:5,代码来源:operator-source.c
示例9: draw_image
//.........这里部分代码省略.........
(strtol(strgroupst[3], NULL, 16))};
char strgroupsk[4][3] = {{keyhlcolor[0], textcolor[1], '\0'},
{keyhlcolor[2], textcolor[3], '\0'},
{keyhlcolor[4], textcolor[5], '\0'},
{keyhlcolor[6], textcolor[7], '\0'}};
uint32_t keyhl16[4] = {(strtol(strgroupsk[0], NULL, 16)),
(strtol(strgroupsk[1], NULL, 16)),
(strtol(strgroupsk[2], NULL, 16)),
(strtol(strgroupsk[3], NULL, 16))};
char strgroupsb[4][3] = {{bshlcolor[0], textcolor[1], '\0'},
{bshlcolor[2], textcolor[3], '\0'},
{bshlcolor[4], textcolor[5], '\0'},
{bshlcolor[6], textcolor[7], '\0'}};
uint32_t bshl16[4] = {(strtol(strgroupsb[0], NULL, 16)),
(strtol(strgroupsb[1], NULL, 16)),
(strtol(strgroupsb[2], NULL, 16)),
(strtol(strgroupsb[3], NULL, 16))};
#endif
if (unlock_state >= STATE_KEY_PRESSED && unlock_indicator) {
/* Draw a (centered) circle with transparent background. */
cairo_set_line_width(ctx, 10.0);
cairo_arc(ctx,
BUTTON_CENTER /* x */,
BUTTON_CENTER /* y */,
BUTTON_RADIUS /* radius */,
0 /* start */,
2 * M_PI /* end */);
/* Use the appropriate color for the different PAM states
* (currently verifying, wrong password, or default) */
switch (pam_state) {
case STATE_PAM_VERIFY:
cairo_set_source_rgba(ctx, (double)insidever16[0]/255, (double)insidever16[1]/255, (double)insidever16[2]/255, (double)insidever16[3]/255);
break;
case STATE_PAM_WRONG:
cairo_set_source_rgba(ctx, (double)insidewrong16[0]/255, (double)insidewrong16[1]/255, (double)insidewrong16[2]/255, (double)insidewrong16[3]/255);
break;
default:
cairo_set_source_rgba(ctx, (double)inside16[0]/255, (double)inside16[1]/255, (double)inside16[2]/255, (double)inside16[3]/255);
break;
}
cairo_fill_preserve(ctx);
switch (pam_state) {
case STATE_PAM_VERIFY:
cairo_set_source_rgba(ctx, (double)ringver16[0]/255, (double)ringver16[1]/255, (double)ringver16[2]/255, (double)ringver16[3]/255);
break;
case STATE_PAM_WRONG:
cairo_set_source_rgba(ctx, (double)ringwrong16[0]/255, (double)ringwrong16[1]/255, (double)ringwrong16[2]/255, (double)ringwrong16[3]/255);
break;
case STATE_PAM_IDLE:
cairo_set_source_rgba(ctx, (double)ring16[0]/255, (double)ring16[1]/255, (double)ring16[2]/255, (double)ring16[3]/255);
break;
}
cairo_stroke(ctx);
/* Draw an inner seperator line. */
cairo_set_source_rgba(ctx, (double)line16[0]/255, (double)line16[1]/255, (double)line16[2]/255, (double)line16[3]/255);
cairo_set_line_width(ctx, 2.0);
cairo_arc(ctx,
BUTTON_CENTER /* x */,
BUTTON_CENTER /* y */,
BUTTON_RADIUS - 5 /* radius */,
0,
2 * M_PI);
开发者ID:jeffc,项目名称:i3lock-color,代码行数:67,代码来源:unlock_indicator.c
示例10: flush
void flush()
{
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_A8, _totalWidth, _maxHeight);
cairo_t *cr = cairo_create(surface);
int pos = 0;
cairo_set_source_rgba (cr, 0., 0., 0., 0);
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_font_options_t *fontOptions = cairo_font_options_create();
cairo_get_font_options(cr, fontOptions);
cairo_font_options_set_hint_style(fontOptions, CAIRO_HINT_STYLE_FULL);
cairo_font_options_set_antialias(fontOptions, CAIRO_ANTIALIAS_GRAY);
cairo_set_font_options(cr, fontOptions);
cairo_font_options_destroy(fontOptions);
cairo_set_source_rgba(cr, 1, 1, 1, 1);
for(std::vector<element>::iterator it = _elements.begin(); it != _elements.end(); ++it) {
cairo_move_to(cr, pos - it->xBearing, -it->yBearing);
cairo_set_font_size(cr, it->fontSize);
cairo_set_font_face(cr, it->fontFace);
cairo_show_text(cr, it->text.c_str());
cairo_font_face_destroy(it->fontFace);
pos += it->width;
}
cairo_destroy(cr);
//setup matrices
GLint matrixMode;
GLuint textureId;
glGetIntegerv (GL_MATRIX_MODE, &matrixMode);
glMatrixMode (GL_PROJECTION);
glPushMatrix();
glLoadIdentity ();
glMatrixMode (GL_MODELVIEW);
glPushMatrix();
glLoadIdentity ();
float winw = Fl_Window::current()->w();
float winh = Fl_Window::current()->h();
glScalef (2.0f / winw, 2.0f / winh, 1.0f);
glTranslatef (-winw / 2.0f, -winh / 2.0f, 0.0f);
//write the texture on screen
glEnable(GL_TEXTURE_RECTANGLE_ARB);
glPushAttrib(GL_ENABLE_BIT | GL_TEXTURE_BIT | GL_COLOR_BUFFER_BIT);
glDisable(GL_LIGHTING);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glGenTextures(1, &textureId);
glBindTexture(GL_TEXTURE_RECTANGLE_ARB, textureId);
glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_ALPHA,
cairo_image_surface_get_width(surface),
cairo_image_surface_get_height(surface), 0,
GL_ALPHA, GL_UNSIGNED_BYTE, cairo_image_surface_get_data(surface));
//glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_SRC0_ALPHA);
//printf("error %i %s\n", __LINE__, gluErrorString(glGetError()));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
pos = 0;
for(std::vector<element>::iterator it = _elements.begin(); it != _elements.end(); ++it) {
glTranslatef(it->x, it->y, it->z);
glColor4f(it->r, it->g, it->b, it->alpha);
int Lx = it->width;
int Ly = it->height;
glBegin (GL_QUADS);
glTexCoord2f (pos, 0);
glVertex2f (0.0f, Ly);
glTexCoord2f (pos + Lx, 0);
glVertex2f (Lx, Ly);
glTexCoord2f (pos + Lx, Ly);
glVertex2f (Lx, 0.0f);
glTexCoord2f (pos, Ly);
glVertex2f (0.0f, 0.0f);
glEnd ();
pos += Lx;
glTranslatef(-it->x, -it->y, -it->z);
}
glDeleteTextures(1, &textureId);
glPopAttrib();
// reset original matrices
glPopMatrix(); // GL_MODELVIEW
glMatrixMode (GL_PROJECTION);
glPopMatrix();
glMatrixMode (matrixMode);
_elements.clear();
_maxHeight = 0;
_totalWidth = 0;
cairo_surface_destroy(surface);
}
开发者ID:feelpp,项目名称:debian-gmsh,代码行数:91,代码来源:drawContextFltkCairo.cpp
示例11: lowlight_draw
static gboolean lowlight_draw(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
dt_iop_module_t *self = (dt_iop_module_t *)user_data;
dt_iop_lowlight_gui_data_t *c = (dt_iop_lowlight_gui_data_t *)self->gui_data;
dt_iop_lowlight_params_t p = *(dt_iop_lowlight_params_t *)self->params;
dt_draw_curve_set_point(c->transition_curve, 0, p.transition_x[DT_IOP_LOWLIGHT_BANDS - 2] - 1.0,
p.transition_y[0]);
for(int k = 0; k < DT_IOP_LOWLIGHT_BANDS; k++)
dt_draw_curve_set_point(c->transition_curve, k + 1, p.transition_x[k], p.transition_y[k]);
dt_draw_curve_set_point(c->transition_curve, DT_IOP_LOWLIGHT_BANDS + 1, p.transition_x[1] + 1.0,
p.transition_y[DT_IOP_LOWLIGHT_BANDS - 1]);
const int inset = DT_IOP_LOWLIGHT_INSET;
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int width = allocation.width, height = allocation.height;
cairo_surface_t *cst = dt_cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr = cairo_create(cst);
cairo_set_source_rgb(cr, .2, .2, .2);
cairo_paint(cr);
cairo_translate(cr, inset, inset);
width -= 2 * inset;
height -= 2 * inset;
cairo_set_line_width(cr, DT_PIXEL_APPLY_DPI(1.0));
cairo_set_source_rgb(cr, .1, .1, .1);
cairo_rectangle(cr, 0, 0, width, height);
cairo_stroke(cr);
cairo_set_source_rgb(cr, .3, .3, .3);
cairo_rectangle(cr, 0, 0, width, height);
cairo_fill(cr);
// draw grid
cairo_set_line_width(cr, DT_PIXEL_APPLY_DPI(.4));
cairo_set_source_rgb(cr, .1, .1, .1);
dt_draw_grid(cr, 8, 0, 0, width, height);
if(c->mouse_y > 0 || c->dragging)
{
// draw min/max curves:
dt_iop_lowlight_get_params(&p, c->mouse_x, 1., c->mouse_radius);
dt_draw_curve_set_point(c->transition_curve, 0, p.transition_x[DT_IOP_LOWLIGHT_BANDS - 2] - 1.0,
p.transition_y[0]);
for(int k = 0; k < DT_IOP_LOWLIGHT_BANDS; k++)
dt_draw_curve_set_point(c->transition_curve, k + 1, p.transition_x[k], p.transition_y[k]);
dt_draw_curve_set_point(c->transition_curve, DT_IOP_LOWLIGHT_BANDS + 1, p.transition_x[1] + 1.0,
p.transition_y[DT_IOP_LOWLIGHT_BANDS - 1]);
dt_draw_curve_calc_values(c->transition_curve, 0.0, 1.0, DT_IOP_LOWLIGHT_RES, c->draw_min_xs,
c->draw_min_ys);
p = *(dt_iop_lowlight_params_t *)self->params;
dt_iop_lowlight_get_params(&p, c->mouse_x, .0, c->mouse_radius);
dt_draw_curve_set_point(c->transition_curve, 0, p.transition_x[DT_IOP_LOWLIGHT_BANDS - 2] - 1.0,
p.transition_y[0]);
for(int k = 0; k < DT_IOP_LOWLIGHT_BANDS; k++)
dt_draw_curve_set_point(c->transition_curve, k + 1, p.transition_x[k], p.transition_y[k]);
dt_draw_curve_set_point(c->transition_curve, DT_IOP_LOWLIGHT_BANDS + 1, p.transition_x[1] + 1.0,
p.transition_y[DT_IOP_LOWLIGHT_BANDS - 1]);
dt_draw_curve_calc_values(c->transition_curve, 0.0, 1.0, DT_IOP_LOWLIGHT_RES, c->draw_max_xs,
c->draw_max_ys);
}
cairo_save(cr);
// draw x positions
cairo_set_source_rgb(cr, 0.6, 0.6, 0.6);
cairo_set_line_width(cr, DT_PIXEL_APPLY_DPI(1.));
const float arrw = DT_PIXEL_APPLY_DPI(7.0f);
for(int k = 0; k < DT_IOP_LOWLIGHT_BANDS; k++)
{
cairo_move_to(cr, width * p.transition_x[k], height + inset - DT_PIXEL_APPLY_DPI(1));
cairo_rel_line_to(cr, -arrw * .5f, 0);
cairo_rel_line_to(cr, arrw * .5f, -arrw);
cairo_rel_line_to(cr, arrw * .5f, arrw);
cairo_close_path(cr);
if(c->x_move == k)
cairo_fill(cr);
else
cairo_stroke(cr);
}
// draw selected cursor
cairo_translate(cr, 0, height);
// cairo_set_operator(cr, CAIRO_OPERATOR_ADD);
// cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
cairo_set_line_width(cr, DT_PIXEL_APPLY_DPI(2.));
cairo_set_source_rgba(cr, .7, .7, .7, 1.0);
p = *(dt_iop_lowlight_params_t *)self->params;
dt_draw_curve_set_point(c->transition_curve, 0, p.transition_x[DT_IOP_LOWLIGHT_BANDS - 2] - 1.0,
p.transition_y[0]);
for(int k = 0; k < DT_IOP_LOWLIGHT_BANDS; k++)
dt_draw_curve_set_point(c->transition_curve, k + 1, p.transition_x[k], p.transition_y[k]);
dt_draw_curve_set_point(c->transition_curve, DT_IOP_LOWLIGHT_BANDS + 1, p.transition_x[1] + 1.0,
//.........这里部分代码省略.........
开发者ID:CoreyChen922,项目名称:darktable,代码行数:101,代码来源:lowlight.c
示例12: on_expose_event
static gboolean
on_expose_event (GtkWidget *widget,
GdkEventExpose *event,
GsdMediaKeysWindow *window)
{
cairo_t *context;
cairo_t *cr;
cairo_surface_t *surface;
int width;
int height;
GtkStyle *style;
GdkColor color;
double r, g, b;
context = gdk_cairo_create (gtk_widget_get_window (widget));
style = gtk_widget_get_style (widget);
cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
surface = cairo_surface_create_similar (cairo_get_target (context),
CAIRO_CONTENT_COLOR_ALPHA,
width,
height);
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
goto done;
}
cr = cairo_create (surface);
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
goto done;
}
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_paint (cr);
/* draw a box */
rounded_rectangle (cr, 1.0, 0.5, 0.5, height / 10, width-1, height-1);
color_reverse (&style->bg[GTK_STATE_NORMAL], &color);
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
cairo_set_source_rgba (cr, r, g, b, BG_ALPHA);
cairo_fill_preserve (cr);
color_reverse (&style->text_aa[GTK_STATE_NORMAL], &color);
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
cairo_set_source_rgba (cr, r, g, b, BG_ALPHA / 2);
cairo_set_line_width (cr, 1);
cairo_stroke (cr);
/* draw action */
draw_action (window, cr);
cairo_destroy (cr);
/* Make sure we have a transparent background */
cairo_rectangle (context, 0, 0, width, height);
cairo_set_source_rgba (context, 0.0, 0.0, 0.0, 0.0);
cairo_fill (context);
cairo_set_source_surface (context, surface, 0, 0);
cairo_paint_with_alpha (context, window->priv->fade_out_alpha);
done:
if (surface != NULL) {
cairo_surface_destroy (surface);
}
cairo_destroy (context);
return FALSE;
}
开发者ID:gfunkmonk2,项目名称:mate-movie-player,代码行数:75,代码来源:gsd-media-keys-window.c
示例13: expose_when_composited
/* This is our expose-event handler when the window is in a compositing manager.
* We draw everything by hand, using Cairo, so that we can have a nice
* transparent/rounded look.
*/
static void
expose_when_composited (GtkWidget *widget, GdkEventExpose *event)
{
MsdOsdWindow *window;
cairo_t *context;
cairo_t *cr;
cairo_surface_t *surface;
int width;
int height;
GtkStyle *style;
GdkColor color;
double r, g, b;
window = MSD_OSD_WINDOW (widget);
context = gdk_cairo_create (gtk_widget_get_window (widget));
style = gtk_widget_get_style (widget);
cairo_set_operator (context, CAIRO_OPERATOR_SOURCE);
gtk_window_get_size (GTK_WINDOW (widget), &width, &height);
surface = cairo_surface_create_similar (cairo_get_target (context),
CAIRO_CONTENT_COLOR_ALPHA,
width,
height);
if (cairo_surface_status (surface) != CAIRO_STATUS_SUCCESS) {
goto done;
}
cr = cairo_create (surface);
if (cairo_status (cr) != CAIRO_STATUS_SUCCESS) {
goto done;
}
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_paint (cr);
/* draw a box */
msd_osd_window_draw_rounded_rectangle (cr, 1.0, 0.5, 0.5, height / 10, width-1, height-1);
msd_osd_window_color_reverse (&style->bg[GTK_STATE_NORMAL], &color);
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
cairo_set_source_rgba (cr, r, g, b, BG_ALPHA);
cairo_fill_preserve (cr);
msd_osd_window_color_reverse (&style->text_aa[GTK_STATE_NORMAL], &color);
r = (float)color.red / 65535.0;
g = (float)color.green / 65535.0;
b = (float)color.blue / 65535.0;
cairo_set_source_rgba (cr, r, g, b, BG_ALPHA / 2);
cairo_set_line_width (cr, 1);
cairo_stroke (cr);
g_signal_emit (window, signals[EXPOSE_WHEN_COMPOSITED], 0, cr);
cairo_destroy (cr);
/* Make sure we have a transparent background */
cairo_rectangle (context, 0, 0, width, height);
cairo_set_source_rgba (context, 0.0, 0.0, 0.0, 0.0);
cairo_fill (context);
cairo_set_source_surface (context, surface, 0, 0);
cairo_paint_with_alpha (context, window->priv->fade_out_alpha);
done:
if (surface != NULL) {
cairo_surface_destroy (surface);
}
cairo_destroy (context);
}
开发者ID:JaM0N,项目名称:mate-settings-daemon,代码行数:77,代码来源:msd-osd-window.c
示例14: cairo_set_source_rgba
void CanvasCairo::pathFillStroke(const Color4B &fill, const Color4B &stroke) {
cairo_set_source_rgba(_context, fill.r / 255.0, fill.g / 255.0, fill.b / 255.0, fill.a / 255.0);
cairo_fill_preserve(_context);
cairo_set_source_rgba(_context, stroke.r / 255.0, stroke.g / 255.0, stroke.b / 255.0, stroke.a / 255.0);
cairo_stroke(_context);
}
开发者ID:SBKarr,项目名称:stappler,代码行数:6,代码来源:SPDrawCanvasCairo.cpp
示例15: dt_ellipse_events_post_expose
static void dt_ellipse_events_post_expose(cairo_t *cr, float zoom_scale, dt_masks_form_gui_t *gui, int index)
{
double dashed[] = { 4.0, 4.0 };
dashed[0] /= zoom_scale;
dashed[1] /= zoom_scale;
int len = sizeof(dashed) / sizeof(dashed[0]);
dt_masks_form_gui_points_t *gpt = (dt_masks_form_gui_points_t *)g_list_nth_data(gui->points, index);
if(!gpt) return;
const float r = atan2(gpt->points[3] - gpt->points[1], gpt->points[2] - gpt->points[0]);
const float sinr = sin(r);
const float cosr = cos(r);
float dx = 0.0f, dy = 0.0f, xref = gpt->points[0], yref = gpt->points[1];
float dxs = 0.0f, dys = 0.0f, xrefs = 0.0f, yrefs = 0.0f;
float sinv = 0.0f, cosv = 1.0f;
float scalea = 1.0f, scaleb = 1.0f, scaleab = 1.0f, scalebb = 1.0f;
if(gpt->source_count > 10)
{
xrefs = gpt->source[0];
yrefs = gpt->source[1];
}
if((gui->group_selected == index) && gui->form_dragging)
{
dx = gui->posx + gui->dx - xref;
dy = gui->posy + gui->dy - yref;
}
else if((gui->group_selected == index) && gui->source_dragging)
{
xrefs = gpt->source[0], yrefs = gpt->source[1];
dxs = gui->posx + gui->dx - xrefs;
dys = gui->posy + gui->dy - yrefs;
}
else if((gui->group_selected == index) && gui->form_rotating)
{
const float v = atan2(gui->posy - yref, gui->posx - xref) - atan2(-gui->dy, -gui->dx);
sinv = sin(v);
cosv = cos(v);
}
else if((gui->group_selected == index) && (gui->point_dragging >= 1))
{
const int k = gui->point_dragging;
const float rx = gpt->points[k * 2] - xref;
const float ry = gpt->points[k * 2 + 1] - yref;
const float bx = gpt->border[k * 2] - xref;
const float by = gpt->border[k * 2 + 1] - yref;
const float deltax = gui->posx + gui->dx - xref;
const float deltay = gui->posy + gui->dy - yref;
const float r = sqrtf(rx * rx + ry * ry);
const float b = sqrtf(bx * bx + by * by);
float d = (rx * deltax + ry * deltay) / r;
if(r + d < 0) d = -r;
if(k == 1 || k == 2)
{
scalea = r > 0 ? (r + d) / r : 0;
scaleab = b > 0 ? (b + d) / b : 0;
}
else
{
scaleb = r > 0 ? (r + d) / r : 0;
scalebb = b > 0 ? (b + d) / b : 0;
}
}
float x, y;
// draw shape
if(gpt->points_count > 10)
{
cairo_set_dash(cr, dashed, 0, 0);
if((gui->group_selected == index) && (gui->form_selected || gui->form_dragging))
cairo_set_line_width(cr, 5.0 / zoom_scale);
else
cairo_set_line_width(cr, 3.0 / zoom_scale);
cairo_set_source_rgba(cr, .3, .3, .3, .8);
_ellipse_point_transform(xref, yref, gpt->points[10] + dx, gpt->points[11] + dy, sinr, cosr, scalea,
scaleb, sinv, cosv, &x, &y);
cairo_move_to(cr, x, y);
for(int i = 6; i < gpt->points_count; i++)
{
_ellipse_point_transform(xref, yref, gpt->points[i * 2] + dx, gpt->points[i * 2 + 1] + dy, sinr, cosr,
scalea, scaleb, sinv, cosv, &x, &y);
cairo_line_to(cr, x, y);
}
_ellipse_point_transform(xref, yref, gpt->points[10] + dx, gpt->points[11] + dy, sinr, cosr, scalea,
scaleb, sinv, cosv, &x, &y);
cairo_line_to(cr, x, y);
cairo_stroke_preserve(cr);
if((gui->group_selected == index) && (gui->form_selected || gui->form_dragging))
cairo_set_line_width(cr, 2.0 / zoom_scale);
else
cairo_set_line_width(cr, 1.0 / zoom_scale);
cairo_set_source_rgba(cr, .8, .8, .8, .8);
cairo_stroke(cr);
}
//.........这里部分代码省略.........
开发者ID:CarVac,项目名称:darktable,代码行数:101,代码来源:ellipse.c
示例16: colorzones_expose
//.........这里部分代码省略.........
case DT_IOP_COLORZONES_C:
picked_i = pickC / 128.0;
break;
default: // case DT_IOP_COLORZONES_h:
picked_i = fmodf(atan2f(self->picked_color[2], self->picked_color[1]) + 2.0*M_PI, 2.0*M_PI)/(2.0*M_PI);
break;
}
cairo_save(cr);
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_set_operator(cr, CAIRO_OPERATOR_XOR);
cairo_set_line_width(cr, 2.);
cairo_move_to(cr, width*picked_i, 0.0);
cairo_line_to(cr, width*picked_i, height);
cairo_stroke(cr);
cairo_restore(cr);
// draw x positions
cairo_set_source_rgb(cr, 0.6, 0.6, 0.6);
cairo_set_line_width(cr, 1.);
const float arrw = 7.0f;
for(int k=0; k<DT_IOP_COLORZONES_BANDS; k++)
{
cairo_move_to(cr, width*p.equalizer_x[c->channel][k], height+inset-1);
cairo_rel_line_to(cr, -arrw*.5f, 0);
cairo_rel_line_to(cr, arrw*.5f, -arrw);
cairo_rel_line_to(cr, arrw*.5f, arrw);
cairo_close_path(cr);
if(c->x_move == k) cairo_fill(cr);
else cairo_stroke(
|
请发表评论