本文整理汇总了C++中cairo_translate函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_translate函数的具体用法?C++ cairo_translate怎么用?C++ cairo_translate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_translate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: dash_box_real_draw
static gboolean dash_box_real_draw (GtkWidget* base, cairo_t* c) {
DashBox * self;
gboolean result = FALSE;
Background* _tmp0_;
gdouble box_r;
gint box_y;
gint box_w = 0;
gint box_h = 0;
gint _tmp11_ = 0;
gint _tmp12_ = 0;
DashBoxMode _tmp13_;
cairo_t* _tmp25_;
cairo_t* _tmp26_;
gint _tmp27_;
gint _tmp28_;
gint _tmp29_;
gdouble _tmp30_;
cairo_t* _tmp31_;
cairo_t* _tmp32_;
cairo_t* _tmp33_;
cairo_t* _tmp34_;
cairo_t* _tmp35_;
cairo_t* _tmp36_;
cairo_t* _tmp37_;
gboolean _tmp38_ = FALSE;
self = (DashBox*) base;
g_return_val_if_fail (c != NULL, FALSE);
_tmp0_ = self->priv->_background;
if (_tmp0_ != NULL) {
gint x = 0;
gint y = 0;
Background* _tmp1_;
gint _tmp2_ = 0;
gint _tmp3_ = 0;
cairo_t* _tmp4_;
cairo_t* _tmp5_;
gint _tmp6_;
gint _tmp7_;
Background* _tmp8_;
cairo_t* _tmp9_;
cairo_t* _tmp10_;
_tmp1_ = self->priv->_background;
gtk_widget_translate_coordinates ((GtkWidget*) _tmp1_, (GtkWidget*) self, 0, 0, &_tmp2_, &_tmp3_);
x = _tmp2_;
y = _tmp3_;
_tmp4_ = c;
cairo_save (_tmp4_);
_tmp5_ = c;
_tmp6_ = x;
_tmp7_ = y;
cairo_translate (_tmp5_, (gdouble) _tmp6_, (gdouble) _tmp7_);
_tmp8_ = self->priv->_background;
_tmp9_ = c;
background_draw_full (_tmp8_, _tmp9_, BACKGROUND_DRAW_FLAGS_NONE);
_tmp10_ = c;
cairo_restore (_tmp10_);
}
box_r = 0.3 * grid_size;
box_y = 0;
gtk_widget_get_preferred_width ((GtkWidget*) self, NULL, &_tmp11_);
box_w = _tmp11_;
gtk_widget_get_preferred_height ((GtkWidget*) self, NULL, &_tmp12_);
box_h = _tmp12_;
_tmp13_ = self->priv->mode;
if (_tmp13_ == DASH_BOX_MODE_PUSH_FADE_OUT) {
gint _tmp14_;
gint _tmp15_;
gint _tmp16_;
gdouble _tmp17_;
gint new_box_h;
gint _tmp18_;
_tmp14_ = box_h;
_tmp15_ = box_h;
_tmp16_ = self->priv->orig_height;
_tmp17_ = self->priv->_base_alpha;
new_box_h = _tmp14_ - ((gint) ((_tmp15_ - _tmp16_) * _tmp17_));
_tmp18_ = new_box_h;
box_h = _tmp18_;
} else {
DashBoxMode _tmp19_;
_tmp19_ = self->priv->mode;
if (_tmp19_ == DASH_BOX_MODE_POP_FADE_IN) {
gint _tmp20_;
gint _tmp21_;
gint _tmp22_;
gdouble _tmp23_;
gint new_box_h;
gint _tmp24_;
_tmp20_ = box_h;
_tmp21_ = box_h;
_tmp22_ = self->priv->orig_height;
_tmp23_ = self->priv->_base_alpha;
new_box_h = _tmp20_ - ((gint) ((_tmp21_ - _tmp22_) * _tmp23_));
_tmp24_ = new_box_h;
box_h = _tmp24_;
}
}
_tmp25_ = c;
cairo_save (_tmp25_);
_tmp26_ = c;
//.........这里部分代码省略.........
开发者ID:wwu-cs-support,项目名称:cswwugreeter,代码行数:101,代码来源:dash-box.c
示例2: draw_line
static void
draw_line(struct clickdot *clickdot, cairo_t *cr,
struct rectangle *allocation)
{
cairo_t *bcr;
cairo_surface_t *tmp_buffer = NULL;
if (clickdot->reset) {
tmp_buffer = clickdot->buffer;
clickdot->buffer = NULL;
clickdot->line.x = -1;
clickdot->line.y = -1;
clickdot->line.old_x = -1;
clickdot->line.old_y = -1;
clickdot->reset = 0;
}
if (clickdot->buffer == NULL) {
clickdot->buffer =
cairo_image_surface_create(CAIRO_FORMAT_ARGB32,
allocation->width,
allocation->height);
bcr = cairo_create(clickdot->buffer);
cairo_set_source_rgba(bcr, 0, 0, 0, 0);
cairo_rectangle(bcr,
0, 0,
allocation->width, allocation->height);
cairo_fill(bcr);
}
else
bcr = cairo_create(clickdot->buffer);
if (tmp_buffer) {
cairo_set_source_surface(bcr, tmp_buffer, 0, 0);
cairo_rectangle(bcr, 0, 0,
allocation->width, allocation->height);
cairo_clip(bcr);
cairo_paint(bcr);
cairo_surface_destroy(tmp_buffer);
}
if (clickdot->line.x != -1 && clickdot->line.y != -1) {
if (clickdot->line.old_x != -1 &&
clickdot->line.old_y != -1) {
cairo_set_line_width(bcr, 2.0);
cairo_set_source_rgb(bcr, 1, 1, 1);
cairo_translate(bcr,
-allocation->x, -allocation->y);
cairo_move_to(bcr,
clickdot->line.old_x,
clickdot->line.old_y);
cairo_line_to(bcr,
clickdot->line.x,
clickdot->line.y);
cairo_stroke(bcr);
}
clickdot->line.old_x = clickdot->line.x;
clickdot->line.old_y = clickdot->line.y;
}
cairo_destroy(bcr);
cairo_set_source_surface(cr, clickdot->buffer,
allocation->x, allocation->y);
cairo_set_operator(cr, CAIRO_OPERATOR_ADD);
cairo_rectangle(cr,
allocation->x, allocation->y,
allocation->width, allocation->height);
cairo_clip(cr);
cairo_paint(cr);
}
开发者ID:Tarnyko,项目名称:weston-ivi-shell,代码行数:74,代码来源:clickdot.c
示例3: expose_filemanager
//.........这里部分代码省略.........
{
if (iir == 1 && row)
continue;
/* set mouse over id if pointer is in current row / col */
if(pi == col && pj == row)
{
mouse_over_id = id;
DT_CTL_SET_GLOBAL(lib_image_mouse_over_id, mouse_over_id);
}
/* handle mouse click on current row / col
this could easily and preferable be moved to button_pressed()
*/
if (clicked1 && (pi == col && pj == row))
{
if ((lib->modifiers & (GDK_SHIFT_MASK|GDK_CONTROL_MASK)) == 0)
dt_selection_select_single(darktable.selection, id);
else if ((lib->modifiers & (GDK_CONTROL_MASK)) == GDK_CONTROL_MASK)
dt_selection_toggle(darktable.selection, id);
else if ((lib->modifiers & (GDK_SHIFT_MASK)) == GDK_SHIFT_MASK)
dt_selection_select_range(darktable.selection, id);
}
cairo_save(cr);
// if(iir == 1) dt_image_prefetch(image, DT_IMAGE_MIPF);
dt_view_image_expose(&(lib->image_over), id, cr, wd, iir == 1 ? height : ht, iir, img_pointerx, img_pointery);
cairo_restore(cr);
}
else
goto failure;
cairo_translate(cr, wd, 0.0f);
}
cairo_translate(cr, -max_cols*wd, ht);
}
cairo_restore(cr);
// and now the group borders
for(int row = 0; row < max_rows; row++)
{
for(int col = 0; col < max_cols; col++)
{
id = query_ids[row*iir+col];
if(id > 0)
{
const dt_image_t *image = dt_image_cache_read_get(darktable.image_cache, id);
int group_id = -1;
if(image)
group_id = image->group_id;
dt_image_cache_read_release(darktable.image_cache, image);
if (iir == 1 && row)
continue;
cairo_save(cr);
gboolean paint_border = FALSE;
// regular highlight border
if(group_id != -1)
{
if(mouse_over_group == group_id && iir > 1 && ((!darktable.gui->grouping && dt_conf_get_bool("plugins/lighttable/draw_group_borders")) || group_id == darktable.gui->expanded_group_id))
{
cairo_set_source_rgb(cr, 1, 0.8, 0);
paint_border = TRUE;
开发者ID:amitkr,项目名称:darktable,代码行数:67,代码来源:lighttable.c
示例4: main
//.........这里部分代码省略.........
yoff=temp;
havey=1;
break;
}
}
break;
case 'r':
if(strstr(optarg,"dpcm")){
dpp=atof(optarg)*.03527777777778;
}else if (strstr(optarg,"dpmm")){
dpp=atof(optarg)*.35277777777778;
}else if (strstr(optarg,"dpp")){
dpp=atof(optarg);
}else{
dpp=atof(optarg)*.01388888888889;
}
break;
case 'f':
fontsize=atof(optarg);
break;
case 't':
text=strdup(optarg);
break;
case 'h':
usage(stdout);
exit(0);
case 'v':
fprintf(stderr,"pngxpdf "VERSION"\n");
default:
usage(stderr);
}
}
/* set up our surface */
cs = cairo_pdf_surface_create_for_stream (pdf_write, NULL, width, height);
if(!cs || cairo_surface_status(cs)!=CAIRO_STATUS_SUCCESS){
fprintf(stderr,"CAIRO ERROR: Unable to create PDF surface.\n\n");
exit(1);
}
ct = cairo_create(cs);
if(fontsize<=0){
fontsize=height*15./792.;
if(fontsize<5)fontsize=5;
}
cairo_set_font_size(ct, fontsize);
if(text){
cairo_text_extents(ct, text, &extents);
if(!havey)
yoff = -extents.height-fontsize*4;
}
/* Iterate through PNG files inline */
while(optind<argc){
int ww, hh;
char *filename = argv[optind];
cairo_pattern_t *pattern;
cairo_surface_t *ps=cairo_image_surface_create_from_png(filename);
cairo_status_t status = cairo_surface_status(ps);
if(!ps || status!=CAIRO_STATUS_SUCCESS){
fprintf(stderr,"CAIRO ERROR: Unable to load PNG file %s: %s\n\n",filename,cairo_status_to_string(status));
exit(1);
}
ww = cairo_image_surface_get_width(ps);
hh = cairo_image_surface_get_height(ps);
cairo_save(ct);
cairo_scale(ct, 1./dpp, 1./dpp);
pattern = cairo_pattern_create_for_surface(ps);
cairo_translate(ct,(width*dpp - (ww-1))*.5,((height+yoff)*dpp - (hh-1))*.5);
cairo_pattern_set_filter(pattern, CAIRO_FILTER_BEST);
cairo_set_source(ct,pattern);
cairo_paint(ct);
cairo_restore(ct);
/* draw comment text */
if(text){
cairo_set_source_rgba(ct, 1,1,1,.75);
cairo_move_to(ct, width-extents.width-fontsize*1.5, height-fontsize*1.5);
cairo_text_path (ct, text);
cairo_set_line_width(ct,3.);
cairo_set_line_join(ct,CAIRO_LINE_JOIN_ROUND);
cairo_stroke(ct);
cairo_set_source_rgb(ct, 0,0,0);
cairo_move_to(ct, width-extents.width-fontsize*1.5, height-fontsize*1.5);
cairo_show_text(ct, text);
}
cairo_surface_show_page(cs);
cairo_surface_destroy(ps);
optind++;
}
cairo_destroy(ct);
cairo_surface_destroy(cs);
}
开发者ID:kazutomi,项目名称:xiphqt,代码行数:101,代码来源:main.c
示例5: draw_page_cairo
static void draw_page_cairo(GtkPrintContext *context, PrintData *data)
{
cairo_t *cr;
GdkPixbuf *pixbuf_to_draw;
cairo_surface_t *surface;
guchar *surface_pixels;
guchar *pixbuf_pixels;
gint stride;
gint pixbuf_stride;
gint pixbuf_n_channels;
gdouble cr_dpi_x;
gdouble cr_dpi_y;
gdouble scale_x;
gdouble scale_y;
gint y;
cr = gtk_print_context_get_cairo_context(context);
pixbuf_to_draw = gdk_pixbuf_get_from_drawable(NULL,
GDK_DRAWABLE(vik_viewport_get_pixmap(data->vvp)),
NULL, 0, 0, 0, 0, data->width, data->height);
surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
data->width, data->height);
cr_dpi_x = gtk_print_context_get_dpi_x (context);
cr_dpi_y = gtk_print_context_get_dpi_y (context);
scale_x = cr_dpi_x / data->xres;
scale_y = cr_dpi_y / data->yres;
cairo_translate (cr,
data->offset_x / cr_dpi_x * 72.0,
data->offset_y / cr_dpi_y * 72.0);
cairo_scale (cr, scale_x, scale_y);
surface_pixels = cairo_image_surface_get_data (surface);
stride = cairo_image_surface_get_stride (surface);
pixbuf_pixels = gdk_pixbuf_get_pixels (pixbuf_to_draw);
pixbuf_stride = gdk_pixbuf_get_rowstride(pixbuf_to_draw);
pixbuf_n_channels = gdk_pixbuf_get_n_channels(pixbuf_to_draw);
// fprintf(stderr, "DEBUG: %s() surface_pixels=%p pixbuf_pixels=%p size=%d surface_width=%d surface_height=%d stride=%d data_height=%d pixmap_stride=%d pixmap_nchannels=%d pixmap_bit_per_Sample=%d\n", __PRETTY_FUNCTION__, surface_pixels, pixbuf_pixels, stride * data->height, cairo_image_surface_get_width(surface), cairo_image_surface_get_height(surface), stride, data->height, gdk_pixbuf_get_rowstride(pixbuf_to_draw), gdk_pixbuf_get_n_channels(pixbuf_to_draw), gdk_pixbuf_get_bits_per_sample(pixbuf_to_draw));
/* Assume the pixbuf has 8 bits per channel */
for (y = 0; y < data->height; y++, surface_pixels += stride, pixbuf_pixels += pixbuf_stride) {
switch (pixbuf_n_channels) {
case 3:
copy_row_from_rgb (surface_pixels, pixbuf_pixels, data->width);
break;
case 4:
copy_row_from_rgba (surface_pixels, pixbuf_pixels, data->width);
break;
}
}
g_object_unref(G_OBJECT(pixbuf_to_draw));
cairo_set_source_surface(cr, surface, 0, 0);
cairo_rectangle(cr, 0, 0, data->width, data->height);
cairo_fill(cr);
cairo_surface_destroy(surface);
}
开发者ID:gdt,项目名称:viking,代码行数:61,代码来源:print.c
示例6: _cairo_render_text
static void
_cairo_render_text (CairoRenderer *renderer,
PinPointPoint *point)
{
PangoLayout *layout;
PangoFontDescription *desc;
PangoRectangle logical_rect = { 0, };
ClutterColor text_color,
shading_color;
float text_x, text_y, text_width, text_height, text_scale;
float shading_x, shading_y, shading_width, shading_height;
if (point == NULL)
return;
layout = pango_cairo_create_layout (renderer->ctx);
desc = pango_font_description_from_string (point->font);
pango_layout_set_font_description (layout, desc);
if (point->use_markup)
pango_layout_set_markup (layout, point->text, -1);
else
pango_layout_set_text (layout, point->text, -1);
pango_layout_set_alignment (layout, point->text_align);
pango_layout_get_extents (layout, NULL, &logical_rect);
text_width = (logical_rect.x + logical_rect.width) / 1024;
text_height = (logical_rect.y + logical_rect.height) / 1024;
if (text_width < 1)
goto out;
pp_get_text_position_scale (point,
renderer->width, renderer->height,
text_width, text_height,
&text_x, &text_y,
&text_scale);
pp_get_shading_position_size (renderer->height, renderer->width, /* XXX: is this right order?? */
text_x, text_y,
text_width, text_height,
text_scale,
&shading_x, &shading_y,
&shading_width, &shading_height);
clutter_color_from_string (&text_color, point->text_color);
clutter_color_from_string (&shading_color, point->shading_color);
cairo_set_source_rgba (renderer->ctx,
shading_color.red / 255.f,
shading_color.green / 255.f,
shading_color.blue / 255.f,
shading_color.alpha / 255.f * point->shading_opacity);
cairo_rectangle (renderer->ctx,
shading_x, shading_y, shading_width, shading_height);
cairo_fill (renderer->ctx);
cairo_save (renderer->ctx);
cairo_translate (renderer->ctx, text_x, text_y);
cairo_scale (renderer->ctx, text_scale, text_scale);
cairo_set_source_rgba (renderer->ctx,
text_color.red / 255.f,
text_color.green / 255.f,
text_color.blue / 255.f,
text_color.alpha / 255.f);
pango_cairo_show_layout (renderer->ctx, layout);
cairo_restore (renderer->ctx);
out:
pango_font_description_free (desc);
g_object_unref (layout);
}
开发者ID:GNOME,项目名称:pinpoint,代码行数:70,代码来源:pp-cairo.c
示例7: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
cairo_pattern_t *gradient, *image;
cairo_set_source_rgb (cr, 1,1,1);
cairo_paint (cr);
cairo_translate (cr, PAD, PAD);
/* clip to the unit size */
cairo_rectangle (cr, 0, 0,
UNIT_SIZE, UNIT_SIZE);
cairo_clip (cr);
cairo_rectangle (cr, 0, 0,
UNIT_SIZE, UNIT_SIZE);
cairo_set_source_rgba (cr, 0, 0, 0, 1);
cairo_set_line_width (cr, 2);
cairo_stroke (cr);
/* start a group */
cairo_push_group_with_content (cr, CAIRO_CONTENT_COLOR);
/* draw a gradient background */
cairo_save (cr);
cairo_translate (cr, INNER_PAD, INNER_PAD);
cairo_new_path (cr);
cairo_rectangle (cr, 0, 0,
UNIT_SIZE - (INNER_PAD*2), UNIT_SIZE - (INNER_PAD*2));
gradient = cairo_pattern_create_linear (UNIT_SIZE - (INNER_PAD*2), 0,
UNIT_SIZE - (INNER_PAD*2), UNIT_SIZE - (INNER_PAD*2));
cairo_pattern_add_color_stop_rgba (gradient, 0.0, 0.3, 0.3, 0.3, 1.0);
cairo_pattern_add_color_stop_rgba (gradient, 1.0, 1.0, 1.0, 1.0, 1.0);
cairo_set_source (cr, gradient);
cairo_pattern_destroy (gradient);
cairo_fill (cr);
cairo_restore (cr);
/* draw diamond */
cairo_move_to (cr, UNIT_SIZE / 2, 0);
cairo_line_to (cr, UNIT_SIZE , UNIT_SIZE / 2);
cairo_line_to (cr, UNIT_SIZE / 2, UNIT_SIZE);
cairo_line_to (cr, 0 , UNIT_SIZE / 2);
cairo_close_path (cr);
cairo_set_source_rgba (cr, 0, 0, 1, 1);
cairo_fill (cr);
/* draw circle */
cairo_arc (cr,
UNIT_SIZE / 2, UNIT_SIZE / 2,
UNIT_SIZE / 3.5,
0, M_PI * 2);
cairo_set_source_rgba (cr, 1, 0, 0, 1);
cairo_fill (cr);
/* and put the image on top */
cairo_translate (cr, UNIT_SIZE/2 - 8, UNIT_SIZE/2 - 8);
image = argb32_source ();
cairo_set_source (cr, image);
cairo_pattern_destroy (image);
cairo_paint (cr);
cairo_pop_group_to_source (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
return CAIRO_TEST_SUCCESS;
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:69,代码来源:push-group-color.c
示例8: gimp_color_bar_expose
static gboolean
gimp_color_bar_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GimpColorBar *bar = GIMP_COLOR_BAR (widget);
cairo_t *cr;
GtkAllocation allocation;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
guchar *src;
guchar *dest;
gint x, y;
gint width, height;
gint i;
cr = gdk_cairo_create (event->window);
gdk_cairo_region (cr, event->region);
cairo_clip (cr);
gtk_widget_get_allocation (widget, &allocation);
x = y = gtk_container_get_border_width (GTK_CONTAINER (bar));
width = allocation.width - 2 * x;
height = allocation.height - 2 * y;
if (width < 1 || height < 1)
return TRUE;
cairo_translate (cr, allocation.x + x, allocation.y + y);
cairo_rectangle (cr, 0, 0, width, height);
cairo_clip (cr);
surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 256, 1);
for (i = 0, src = bar->buf, dest = cairo_image_surface_get_data (surface);
i < 256;
i++, src += 3, dest += 4)
{
GIMP_CAIRO_RGB24_SET_PIXEL(dest, src[0], src[1], src[2]);
}
cairo_surface_mark_dirty (surface);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REFLECT);
cairo_surface_destroy (surface);
if (bar->orientation == GTK_ORIENTATION_HORIZONTAL)
{
cairo_scale (cr, (gdouble) width / 256.0, 1.0);
}
else
{
cairo_translate (cr, 0, height);
cairo_scale (cr, 1.0, (gdouble) height / 256.0);
cairo_rotate (cr, - G_PI / 2);
}
cairo_set_source (cr, pattern);
cairo_pattern_destroy (pattern);
cairo_paint (cr);
cairo_destroy (cr);
return TRUE;
}
开发者ID:AjayRamanathan,项目名称:gimp,代码行数:69,代码来源:gimpcolorbar.c
示例9: dt_iop_zonesystem_bar_expose
static gboolean
dt_iop_zonesystem_bar_expose (GtkWidget *widget, GdkEventExpose *event, dt_iop_module_t *self)
{
dt_iop_zonesystem_gui_data_t *g = (dt_iop_zonesystem_gui_data_t *)self->gui_data;
dt_iop_zonesystem_params_t *p = (dt_iop_zonesystem_params_t *)self->params;
const int inset = DT_ZONESYSTEM_INSET;
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int width = allocation.width, height = allocation.height;
cairo_surface_t *cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr = cairo_create(cst);
/* clear background */
cairo_set_source_rgb (cr, .15, .15, .15);
cairo_paint(cr);
/* translate and scale */
width-=2*inset;
height-=2*inset;
cairo_save(cr);
cairo_translate(cr, inset, inset);
cairo_scale(cr,width,height);
/* render the bars */
float zonemap[MAX_ZONE_SYSTEM_SIZE]= {0};
_iop_zonesystem_calculate_zonemap (p, zonemap);
float s=(1./(p->size-2));
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
for(int i=0; i<p->size-1; i++)
{
/* draw the reference zone */
float z=s*i;
cairo_rectangle (cr,(1./(p->size-1))*i,0,(1./(p->size-1)),DT_ZONESYSTEM_REFERENCE_SPLIT-DT_ZONESYSTEM_BAR_SPLIT_WIDTH);
cairo_set_source_rgb (cr, z, z, z);
cairo_fill (cr);
/* draw zone mappings */
cairo_rectangle (cr,
zonemap[i],DT_ZONESYSTEM_REFERENCE_SPLIT+DT_ZONESYSTEM_BAR_SPLIT_WIDTH,
(zonemap[i+1]-zonemap[i]),1.0-DT_ZONESYSTEM_REFERENCE_SPLIT);
cairo_set_source_rgb (cr, z, z, z);
cairo_fill (cr);
}
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
cairo_restore (cr);
/* render zonebar control lines */
cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
cairo_set_line_width (cr, 1.);
cairo_rectangle (cr,inset,inset,width,height);
cairo_set_source_rgb (cr, .1,.1,.1);
cairo_stroke (cr);
cairo_set_antialias (cr, CAIRO_ANTIALIAS_DEFAULT);
/* render control points handles */
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=1; k<p->size-1; k++)
{
float nzw=zonemap[k+1]-zonemap[k];
float pzw=zonemap[k]-zonemap[k-1];
if (
( ((g->mouse_x/width) > (zonemap[k]-(pzw/2.0))) &&
((g->mouse_x/width) < (zonemap[k]+(nzw/2.0))) ) ||
p->zone[k] != -1)
{
gboolean is_under_mouse = ((width*zonemap[k]) - arrw*.5f < g->mouse_x && (width*zonemap[k]) + arrw*.5f > g->mouse_x);
cairo_move_to(cr, inset+(width*zonemap[k]), height+(2*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 ( is_under_mouse )
cairo_fill(cr);
else
cairo_stroke(cr);
}
}
/* push mem surface into widget */
cairo_destroy (cr);
cairo_t *cr_pixmap = gdk_cairo_create (gtk_widget_get_window (widget));
cairo_set_source_surface (cr_pixmap, cst, 0, 0);
cairo_paint (cr_pixmap);
cairo_destroy (cr_pixmap);
cairo_surface_destroy (cst);
return TRUE;
}
开发者ID:hean01,项目名称:darktable,代码行数:97,代码来源:zonesystem.c
示例10: content_draw_cb
void
content_draw_cb (GtkWidget *widget,
cairo_t *cr,
gpointer user_data)
{
PangoContext *context;
PangoLayout *title_layout;
PangoLayout *sub_layout;
PangoFontDescription *desc;
int width, height;
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
cairo_paint (cr);
width = gdk_window_get_width (gtk_widget_get_window (widget));
height = gdk_window_get_height (gtk_widget_get_window (widget));
cairo_translate (cr, width / 2, height / 2);
context = gdk_pango_context_get_for_screen (gtk_widget_get_screen (widget));
title_layout = pango_layout_new (context);
pango_layout_set_text (title_layout, _("This session is locked."), -1);
desc = pango_font_description_from_string (TITLE_FONT);
pango_layout_set_font_description (title_layout, desc);
pango_font_description_free (desc);
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 1.0);
pango_cairo_update_layout (cr, title_layout);
pango_layout_get_size (title_layout, &width, &height);
cairo_save (cr);
/* Adjust the translation to the middle left of the icon */
cairo_translate (cr, - width / PANGO_SCALE / 2 - height / PANGO_SCALE, - height / PANGO_SCALE / 2);
draw_lock_icon (cr, height / PANGO_SCALE);
cairo_restore (cr);
cairo_move_to (cr, - width / PANGO_SCALE / 2 + height / PANGO_SCALE, - height / PANGO_SCALE);
pango_cairo_show_layout (cr, title_layout);
g_object_unref (title_layout);
sub_layout = pango_layout_new (context);
pango_layout_set_text (sub_layout, _("You'll be redirected to the unlock dialog automatically in a few seconds."), -1);
pango_layout_set_wrap (sub_layout, PANGO_WRAP_WORD_CHAR);
pango_layout_set_width (sub_layout, width + 2 * height);
desc = pango_font_description_from_string (MESSAGE_FONT);
pango_layout_set_font_description (sub_layout, desc);
pango_font_description_free (desc);
cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 1.0);
pango_cairo_update_layout (cr, sub_layout);
pango_layout_get_size (sub_layout, &width, NULL);
cairo_move_to (cr, - width / PANGO_SCALE / 2, height / PANGO_SCALE);
pango_cairo_show_layout (cr, sub_layout);
g_object_unref (sub_layout);
g_object_unref (context);
}
开发者ID:smartboyhw,项目名称:light-locker,代码行数:62,代码来源:gs-content.c
示例11: dt_iop_tonecurve_expose
static gboolean dt_iop_tonecurve_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
dt_iop_module_t *self = (dt_iop_module_t *)user_data;
dt_iop_tonecurve_gui_data_t *c = (dt_iop_tonecurve_gui_data_t *)self->gui_data;
dt_iop_tonecurve_params_t *p = (dt_iop_tonecurve_params_t *)self->params;
const float color_labels_left[3][3] = { { 0.3f, 0.3f, 0.3f },
{ 0.0f, 0.34f, 0.27f },
{ 0.0f, 0.27f, 0.58f }
};
const float color_labels_right[3][3] = {{ 0.3f, 0.3f, 0.3f },
{ 0.53f, 0.08f, 0.28f},
{ 0.81f, 0.66f, 0.0f }
};
int ch = c->channel;
int nodes = p->tonecurve_nodes[ch];
dt_iop_tonecurve_node_t *tonecurve = p->tonecurve[ch];
int autoscale_ab = p->tonecurve_autoscale_ab;
if(c->minmax_curve_type[ch] != p->tonecurve_type[ch] || c->minmax_curve_nodes[ch] != p->tonecurve_nodes[ch])
{
dt_draw_curve_destroy(c->minmax_curve[ch]);
c->minmax_curve[ch] = dt_draw_curve_new(0.0, 1.0, p->tonecurve_type[ch]);
c->minmax_curve_nodes[ch] = p->tonecurve_nodes[ch];
c->minmax_curve_type[ch] = p->tonecurve_type[ch];
for(int k=0; k<p->tonecurve_nodes[ch]; k++)
(void)dt_draw_curve_add_point(c->minmax_curve[ch], p->tonecurve[ch][k].x, p->tonecurve[ch][k].y);
}
else
{
for(int k=0; k<p->tonecurve_nodes[ch]; k++)
dt_draw_curve_set_point(c->minmax_curve[ch], k, p->tonecurve[ch][k].x, p->tonecurve[ch][k].y);
}
dt_draw_curve_t *minmax_curve = c->minmax_curve[ch];
dt_draw_curve_calc_values(minmax_curve, 0.0, 1.0, DT_IOP_TONECURVE_RES, c->draw_xs, c->draw_ys);
const float xm = tonecurve[nodes-1].x;
const float x[4] = {0.7f*xm, 0.8f*xm, 0.9f*xm, 1.0f*xm};
const float y[4] = {c->draw_ys[CLAMP((int)(x[0]*DT_IOP_TONECURVE_RES), 0, DT_IOP_TONECURVE_RES-1)],
c->draw_ys[CLAMP((int)(x[1]*DT_IOP_TONECURVE_RES), 0, DT_IOP_TONECURVE_RES-1)],
c->draw_ys[CLAMP((int)(x[2]*DT_IOP_TONECURVE_RES), 0, DT_IOP_TONECURVE_RES-1)],
c->draw_ys[CLAMP((int)(x[3]*DT_IOP_TONECURVE_RES), 0, DT_IOP_TONECURVE_RES-1)]
};
float unbounded_coeffs[3];
dt_iop_estimate_exp(x, y, 4, unbounded_coeffs);
const int inset = DT_GUI_CURVE_EDITOR_INSET;
int width = widget->allocation.width, height = widget->allocation.height;
cairo_surface_t *cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr = cairo_create(cst);
// clear bg
cairo_set_source_rgb (cr, .2, .2, .2);
cairo_paint(cr);
cairo_translate(cr, inset, inset);
width -= 2*inset;
height -= 2*inset;
#if 0
// draw shadow around
float alpha = 1.0f;
for(int k=0; k<inset; k++)
{
cairo_rectangle(cr, -k, -k, width + 2*k, height + 2*k);
cairo_set_source_rgba(cr, 0, 0, 0, alpha);
alpha *= 0.6f;
cairo_fill(cr);
}
#else
cairo_set_line_width(cr, 1.0);
cairo_set_source_rgb (cr, .1, .1, .1);
cairo_rectangle(cr, 0, 0, width, height);
cairo_stroke(cr);
#endif
cairo_set_source_rgb (cr, .3, .3, .3);
cairo_rectangle(cr, 0, 0, width, height);
cairo_fill(cr);
// draw color labels
const int cells = 8;
for(int j=0; j<cells; j++)
{
for(int i=0; i<cells; i++)
{
const float f = (cells-1-j+i)/(2.0f*cells-2.0f);
cairo_set_source_rgba (cr,
(1.0f-f)*color_labels_left[ch][0] + f*color_labels_right[ch][0],
(1.0f-f)*color_labels_left[ch][1] + f*color_labels_right[ch][1],
(1.0f-f)*color_labels_left[ch][2] + f*color_labels_right[ch][2],
.5f); // blend over to make colors darker, so the overlay is more visible
cairo_rectangle(cr, width*i/(float)cells, height*j/(float)cells, width/(float)cells, height/(float)cells);
cairo_fill(cr);
}
}
// draw grid
cairo_set_line_width(cr, .4);
cairo_set_source_rgb (cr, .1, .1, .1);
//.........这里部分代码省略.........
开发者ID:AntonSh,项目名称:darktable,代码行数:101,代码来源:tonecurve.c
示例12: _kanjipadwindow_draw_candidate_character
//!
//! @brief To be written
//!
static void _kanjipadwindow_draw_candidate_character (GwKanjipadWindow *window, int index, int selected)
{
//Declarations
GwKanjipadWindowPrivate *priv;
PangoLayout *layout;
gchar *string_utf;
gint char_width, char_height;
gint x, y;
int allocated_width;
int width, height;
cairo_t *cr;
GtkStyleContext *context;
GdkRGBA fgcolorn;
GdkRGBA bgcolorn;
GdkRGBA fgcolors;
GdkRGBA bgcolors;
//Initializations
priv = window->priv;
cr = cairo_create (priv->ksurface);
allocated_width = gtk_widget_get_allocated_width (GTK_WIDGET (priv->candidates));
context = gtk_widget_get_style_context (GTK_WIDGET (priv->candidates));
gtk_style_context_get_color (context, GTK_STATE_FLAG_NORMAL, &fgcolorn);
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bgcolorn);
gtk_style_context_get_color (context, GTK_STATE_FLAG_SELECTED, &fgcolors);
gtk_style_context_get_background_color (context, GTK_STATE_FLAG_SELECTED, &bgcolors);
_kanjipadwindow_get_candidate_character_size (window, &char_width, &char_height);
if (selected >= 0)
{
if (selected)
cairo_set_source_rgba (cr, bgcolors.red, bgcolors.green, bgcolors.blue, 1.0);
else
cairo_set_source_rgba (cr, bgcolorn.red, bgcolorn.green, bgcolorn.blue, 1.0);
x = 0;
y = (char_height + 6) * index;
width = allocated_width - 1;
height = char_height + 5;
cairo_rectangle (cr, x, y, width, height);
cairo_fill (cr);
}
x = (allocated_width - char_width) / 2;
y = (char_height + 6) * index + 3;
cairo_translate(cr, x, y);
string_utf = _kanjipadwindow_utf8_for_char (priv->kanji_candidates[index]);
layout = gtk_widget_create_pango_layout (GTK_WIDGET (priv->candidates), string_utf);
g_free (string_utf);
if (selected >= 0 && selected)
cairo_set_source_rgba (cr, fgcolors.red, fgcolors.green, fgcolors.blue, 1.0);
else
cairo_set_source_rgba (cr, fgcolorn.red, fgcolorn.green, fgcolorn.blue, 1.0);
pango_cairo_update_layout (cr, layout);
pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
cairo_destroy (cr);
}
开发者ID:kyoushuu,项目名称:gwaei,代码行数:69,代码来源:kanjipad-candidatearea.c
示例13: ReadPANGOImage
//.........这里部分代码省略.........
else
{
image->columns-=2*page.x;
pango_layout_set_width(layout,(int) ((PANGO_SCALE*image->columns*
(image->resolution.x == 0.0 ? 90.0 : image->resolution.x)+45.0)/90.0+
0.5));
}
if (image->rows == 0)
{
pango_layout_get_extents(layout,NULL,&extent);
image->rows=(extent.y+extent.height+PANGO_SCALE/2)/PANGO_SCALE+2*page.y;
}
else
{
image->rows-=2*page.y;
pango_layout_set_height(layout,(int) ((PANGO_SCALE*image->rows*
(image->resolution.y == 0.0 ? 90.0 : image->resolution.y)+45.0)/90.0+
0.5));
}
/*
Render markup.
*/
stride=(size_t) cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32,
image->columns);
pixels=(unsigned char *) AcquireQuantumMemory(image->rows,stride*
sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
{
draw_info=DestroyDrawInfo(draw_info);
caption=DestroyString(caption);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
surface=cairo_image_surface_create_for_data(pixels,CAIRO_FORMAT_ARGB32,
image->columns,image->rows,stride);
cairo_image=cairo_create(surface);
cairo_set_operator(cairo_image,CAIRO_OPERATOR_CLEAR);
cairo_paint(cairo_image);
cairo_set_operator(cairo_image,CAIRO_OPERATOR_OVER);
cairo_translate(cairo_image,page.x,page.y);
pango_cairo_show_layout(cairo_image,layout);
cairo_destroy(cairo_image);
cairo_surface_destroy(surface);
g_object_unref(layout);
g_object_unref(fontmap);
/*
Convert surface to image.
*/
(void) SetImageBackgroundColor(image,exception);
p=pixels;
GetPixelInfo(image,&fill_color);
for (y=0; y < (ssize_t) image->rows; y++)
{
register Quantum
*q;
register ssize_t
x;
q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
double
gamma;
fill_color.blue=(double) ScaleCharToQuantum(*p++);
fill_color.green=(double) ScaleCharToQuantum(*p++);
fill_color.red=(double) ScaleCharToQuantum(*p++);
fill_color.alpha=(double) ScaleCharToQuantum(*p++);
/*
Disassociate alpha.
*/
gamma=1.0-QuantumScale*fill_color.alpha;
gamma=PerceptibleReciprocal(gamma);
fill_color.blue*=gamma;
fill_color.green*=gamma;
fill_color.red*=gamma;
CompositePixelOver(image,&fill_color,fill_color.alpha,q,(double)
GetPixelAlpha(image,q),q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
/*
Relinquish resources.
*/
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
draw_info=DestroyDrawInfo(draw_info);
caption=DestroyString(caption);
return(GetFirstImageInList(image));
}
开发者ID:epu,项目名称:ImageMagick,代码行数:101,代码来源:pango.c
示例14: gtk_css_image_radial_draw
//.........这里部分代码省略.........
double hradius, vradius;
switch (radial->size)
{
case GTK_CSS_EXPLICIT_SIZE:
hradius = _gtk_css_number_value_get (radial->sizes[0], width);
vradius = _gtk_css_number_value_get (radial->sizes[1], height);
break;
case GTK_CSS_CLOSEST_SIDE:
hradius = MIN (x, width - x);
vradius = MIN (y, height - y);
break;
case GTK_CSS_FARTHEST_SIDE:
hradius = MAX (x, width - x);
vradius = MAX (y, height - y);
break;
case GTK_CSS_CLOSEST_CORNER:
hradius = M_SQRT2 * MIN (x, width - x);
vradius = M_SQRT2 * MIN (y, height - y);
break;
case GTK_CSS_FARTHEST_CORNER:
hradius = M_SQRT2 * MAX (x, width - x);
vradius = M_SQRT2 * MAX (y, height - y);
break;
default:
g_assert_not_reached ();
}
hradius = MAX (1.0, hradius);
vradius = MAX (1.0, vradius);
radius = hradius;
yscale = vradius / hradius;
}
gtk_css_image_radial_get_start_end (radial, radius, &start, &end);
pattern = cairo_pattern_create_radial (0, 0, 0, 0, 0, radius);
if (yscale != 1.0)
{
cairo_matrix_init_scale (&matrix, 1.0, 1.0 / yscale);
cairo_pattern_set_matrix (pattern, &matrix);
}
if (radial->repeating)
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
else
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_PAD);
offset = start;
last = -1;
for (i = 0; i < radial->stops->len; i++)
{
GtkCssImageRadialColorStop *stop;
double pos, step;
stop = &g_array_index (radial->stops, GtkCssImageRadialColorStop, i);
if (stop->offset == NULL)
{
if (i == 0)
pos = 0.0;
else if (i + 1 == radial->stops->len)
pos = 1.0;
else
continue;
}
else
pos = _gtk_css_number_value_get (stop->offset, radius) / radius;
pos = MAX (pos, 0);
step = pos / (i - last);
for (last = last + 1; last <= i; last++)
{
const GdkRGBA *rgba;
stop = &g_array_index (radial->stops, GtkCssImageRadialColorStop, last);
rgba = _gtk_css_rgba_value_get_rgba (stop->color);
offset += step;
cairo_pattern_add_color_stop_rgba (pattern,
(offset - start) / (end - start),
rgba->red,
rgba->green,
rgba->blue,
rgba->alpha);
}
offset = pos;
last = i;
}
cairo_rectangle (cr, 0, 0, width, height);
cairo_translate (cr, x, y);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
}
开发者ID:Premangshu2010,项目名称:gtk,代码行数:101,代码来源:gtkcssimageradial.c
示例15: dt_iop_zonesystem_preview_expose
static gboolean
dt_iop_zonesystem_preview_expose (GtkWidget *widget, GdkEventExpose *event, dt_iop_module_t *self)
{
const int inset = 2;
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int width = allocation.width, height = allocation.height;
dt_iop_zonesystem_gui_data_t *g = (dt_iop_zonesystem_gui_data_t *)self->gui_data;
dt_iop_zonesystem_params_t *p = (dt_iop_zonesystem_params_t *)self->params;
cairo_surface_t *cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr = cairo_create(cst);
/* clear background */
GtkStateType state = gtk_widget_get_state(self->expander);
GtkStyle *style = gtk_widget_get_style(self->expander);
cairo_set_source_rgb (cr, style->bg[state].red/65535.0, style->bg[state].green/65535.0, style->bg[state].blue/65535.0);
cairo_paint (cr);
width -= 2*inset;
height -= 2*inset;
cairo_translate(cr, inset, inset);
dt_pthread_mutex_lock(&g->lock);
if( g->in_preview_buffer && g->out_preview_buffer && self->enabled)
{
/* calculate the zonemap */
float zonemap[MAX_ZONE_SYSTEM_SIZE]= {-1};
_iop_zonesystem_calculate_zonemap (p,zonemap);
/* let's generate a pixbuf from pixel zone buffer */
guchar *image = g_malloc ((g->preview_width*g->preview_height)*4);
guchar *buffer = g->mouse_over_output_zones ? g->out_preview_buffer : g->in_preview_buffer;
for (int k=0; k<g->preview_width*g->preview_height; k++)
{
int zone = 255*CLIP (((1.0/(p->size-1))*buffer[k]));
image[4*k+2] = (g->hilite_zone && buffer[k]==g->zone_under_mouse)?255:zone;
image[4*k+1] = (g->hilite_zone && buffer[k]==g->zone_under_mouse)?255:zone;
image[4*k+0] = (g->hilite_zone && buffer[k]==g->zone_under_mouse)?0:zone;
}
dt_pthread_mutex_unlock(&g->lock);
const int wd = g->preview_width, ht = g->preview_height;
const float scale = fminf(width/(float)wd, height/(float)ht);
const int stride = cairo_format_stride_for_width (CAIRO_FORMAT_RGB24, wd);
cairo_surface_t *surface = cairo_image_surface_create_for_data (image, CAIRO_FORMAT_RGB24, wd, ht, stride);
cairo_translate(cr, width/2.0, height/2.0f);
cairo_scale(cr, scale, scale);
cairo_translate(cr, -.5f*wd, -.5f*ht);
cairo_rectangle(cr, 1, 1, wd-2, ht-2);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_GOOD);
cairo_fill_preserve(cr);
cairo_surface_destroy (surface);
cairo_set_line_width(cr, 1.0);
cairo_set_source_rgb(cr, .1, .1, .1);
cairo_stroke(cr);
g_free(image);
}
else
dt_pthread_mutex_unlock(&g->lock);
cairo_destroy(cr);
cairo_t *cr_pixmap = gdk_cairo_create(gtk_widget_get_window(widget));
cairo_set_source_surface (cr_pixmap, cst, 0, 0);
cairo_paint(cr_pixmap);
cairo_destroy(cr_pixmap);
cairo_surface_destroy(cst);
return TRUE;
}
开发者ID:hean01,项目名称:darktable,代码行数:75,代码来源:zonesystem.c
示例16: _cairo_render_background
static void
_cairo_render_background (CairoRenderer *renderer,
PinPointPoint *point)
{
char *full_path = NULL;
const char *file;
if (point == NULL)
return;
file = point->bg;
if (point->bg_type != PP_BG_COLOR && renderer->path && file)
{
char *dir = g_path_get_dirname (renderer->path);
full_path = g_build_filename (dir, file, NULL);
g_free (dir);
file = full_path;
}
if (point->stage_color)
{
ClutterColor color;
clutter_color_from_string (&color, point->stage_color);
cairo_set_source_rgba (renderer->ctx,
color.red / 255.f,
color.green / 255.f,
color.blue / 255.f,
color.alpha / 255.f);
cairo_paint (renderer->ctx);
}
switch (point->bg_type)
{
case PP_BG_NONE:
break;
case PP_BG_COLOR:
{
ClutterColor color;
clutter_color_from_string (&color, point->bg);
cairo_set_source_rgba (renderer->ctx,
color.red / 255.f,
color.green / 255.f,
color.blue / 255.f,
color.alpha / 255.f);
cairo_paint (renderer->ctx);
}
break;
case PP_BG_IMAGE:
{
cairo_surface_t *surface;
float bg_x, bg_y, bg_width, bg_height, bg_scale_x, bg_scale_y;
surface = _cairo_get_surface (renderer, file);
|
请发表评论