本文整理汇总了C++中cairo_stroke函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_stroke函数的具体用法?C++ cairo_stroke怎么用?C++ cairo_stroke使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_stroke函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: process
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result,
gint level)
{
GeglProperties *o = GEGL_PROPERTIES (operation);
gint width = MAX(MAX (o->width, o->x0), o->x1);
gint height = MAX(MAX (o->height, o->y0), o->y1);
{
GeglRectangle extent = {0,0,width,height};
output = gegl_buffer_new (&extent, babl_format ("B'aG'aR'aA u8"));
}
{
guchar *buf = g_new0 (guchar, width * height * 4);
cairo_t *cr;
cairo_surface_t *surface = cairo_image_surface_create_for_data (buf, CAIRO_FORMAT_ARGB32, width, height, width * 4);
cr = cairo_create (surface);
/* cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
cairo_rectangle (cr, 0,0, o->width, o->height);
cairo_fill (cr);*/
#define val2y(val) (o->height - (val - o->min) * o->height / (o->max-o->min))
cairo_set_source_rgba (cr, .0, .0, .8, 0.5);
cairo_move_to (cr, 0, val2y(0.0));
cairo_line_to (cr, o->width, val2y(0.0));
cairo_set_source_rgba (cr, .8, .8, .0, 0.5);
cairo_move_to (cr, 0, val2y(1.0));
cairo_line_to (cr, o->width, val2y(1.0));
cairo_stroke (cr);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
{
gint x;
cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 1.0);
for (x=0;x<o->width;x++)
{
gfloat t = (1.0*x)/o->width;
gint sx = ((1.0-t) * o->x0) + (t * o->x1);
gint sy = ((1.0-t) * o->y0) + (t * o->y1);
cairo_line_to (cr, x, val2y(buffer_sample(input,sx,sy,0)));
}
cairo_stroke (cr);
}
{
gint x;
cairo_set_source_rgba (cr, 0.0, 1.0, 0.0, 1.0);
for (x=0;x<o->width;x++)
{
gfloat t = (1.0*x)/o->width;
gint sx = ((1.0-t) * o->x0) + (t * o->x1);
gint sy = ((1.0-t) * o->y0) + (t * o->y1);
cairo_line_to (cr, x, val2y(buffer_sample(input,sx,sy,1)));
}
cairo_stroke (cr);
}
{
gint x;
cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 1.0);
for (x=0;x<o->width;x++)
{
gfloat t = (1.0*x)/o->width;
gint sx = ((1.0-t) * o->x0) + (t * o->x1);
gint sy = ((1.0-t) * o->y0) + (t * o->y1);
cairo_line_to (cr, x, val2y(buffer_sample(input,sx,sy,2)));
}
cairo_stroke (cr);
}
cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 0.4);
cairo_move_to (cr, o->x0, o->y0);
cairo_line_to (cr, o->x1, o->y1);
cairo_stroke (cr);
gegl_buffer_set (output, NULL, 0, babl_format ("B'aG'aR'aA u8"), buf, GEGL_AUTO_ROWSTRIDE);
}
return TRUE;
}
开发者ID:elEnemigo,项目名称:GEGL-OpenCL,代码行数:85,代码来源:line-profile.c
示例2: _lib_navigation_draw_callback
static gboolean _lib_navigation_draw_callback(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
dt_lib_module_t *self = (dt_lib_module_t *)user_data;
dt_lib_navigation_t *d = (dt_lib_navigation_t *)self->data;
const int inset = DT_NAVIGATION_INSET;
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int width = allocation.width, height = allocation.height;
dt_develop_t *dev = darktable.develop;
/* double buffering of image data: only take new data if valid */
if(dev->preview_pipe->backbuf && dev->preview_status == DT_DEV_PIXELPIPE_VALID)
{
/* re-allocate in case of changed image dimensions */
if(d->buffer == NULL || dev->preview_pipe->backbuf_width != d->wd || dev->preview_pipe->backbuf_height != d->ht)
{
g_free(d->buffer);
d->wd = dev->preview_pipe->backbuf_width;
d->ht = dev->preview_pipe->backbuf_height;
d->buffer = g_malloc0((size_t)d->wd * d->ht * 4 * sizeof(unsigned char));
}
/* update buffer if new data is available */
if(d->buffer && dev->preview_pipe->input_timestamp > d->timestamp)
{
dt_pthread_mutex_t *mutex = &dev->preview_pipe->backbuf_mutex;
dt_pthread_mutex_lock(mutex);
memcpy(d->buffer, dev->preview_pipe->backbuf, (size_t)d->wd * d->ht * 4 * sizeof(unsigned char));
d->timestamp = dev->preview_pipe->input_timestamp;
dt_pthread_mutex_unlock(mutex);
}
}
/* get the current style */
cairo_surface_t *cst = dt_cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr = cairo_create(cst);
GtkStyleContext *context = gtk_widget_get_style_context(widget);
gtk_render_background(context, cr, 0, 0, allocation.width, allocation.height);
width -= 2 * inset;
height -= 2 * inset;
cairo_translate(cr, inset, inset);
/* draw navigation image if available */
if(d->buffer)
{
cairo_save(cr);
const int wd = d->wd;
const int ht = d->ht;
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(d->buffer, 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);
// draw shadow around
float alpha = 1.0f;
for(int k = 0; k < 4; k++)
{
cairo_rectangle(cr, -k / scale, -k / scale, wd + 2 * k / scale, ht + 2 * k / scale);
cairo_set_source_rgba(cr, 0, 0, 0, alpha);
alpha *= 0.6f;
cairo_fill(cr);
}
cairo_rectangle(cr, 0, 0, wd - 2, ht - 1);
cairo_set_source_surface(cr, surface, 0, 0);
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_FAST);
cairo_fill(cr);
cairo_surface_destroy(surface);
// draw box where we are
dt_dev_zoom_t zoom = dt_control_get_dev_zoom();
int closeup = dt_control_get_dev_closeup();
float zoom_x = dt_control_get_dev_zoom_x();
float zoom_y = dt_control_get_dev_zoom_y();
const float min_scale = dt_dev_get_zoom_scale(dev, DT_ZOOM_FIT, closeup ? 2.0 : 1.0, 0);
const float cur_scale = dt_dev_get_zoom_scale(dev, zoom, closeup ? 2.0 : 1.0, 0);
// avoid numerical instability for small resolutions:
double h, w;
if(cur_scale > min_scale)
{
float boxw = 1, boxh = 1;
dt_dev_check_zoom_bounds(darktable.develop, &zoom_x, &zoom_y, zoom, closeup, &boxw, &boxh);
cairo_translate(cr, wd * (.5f + zoom_x), ht * (.5f + zoom_y));
cairo_set_source_rgb(cr, 0., 0., 0.);
cairo_set_line_width(cr, DT_PIXEL_APPLY_DPI(1.f / scale));
boxw *= wd;
boxh *= ht;
cairo_rectangle(cr, -boxw / 2 - 1, -boxh / 2 - 1, boxw + 2, boxh + 2);
cairo_stroke(cr);
cairo_set_source_rgb(cr, 1., 1., 1.);
cairo_rectangle(cr, -boxw / 2, -boxh / 2, boxw, boxh);
cairo_stroke(cr);
//.........这里部分代码省略.........
开发者ID:WhiteSymmetry,项目名称:darktable,代码行数:101,代码来源:navigation.c
示例3: gtk_css_image_builtin_draw_option
static void
gtk_css_image_builtin_draw_option (GtkCssImage *image,
cairo_t *cr,
double width,
double height,
gboolean checked,
gboolean inconsistent)
{
GtkCssImageBuiltin *builtin = GTK_CSS_IMAGE_BUILTIN (image);
gint x, y, exterior_size, interior_size, thickness, pad;
exterior_size = MIN (width, height);
if (exterior_size % 2 == 0) /* Ensure odd */
exterior_size -= 1;
x = - (1 + exterior_size - width) / 2;
y = - (1 + exterior_size - height) / 2;
if (builtin->border_width > 0)
{
cairo_set_line_width (cr, builtin->border_width);
cairo_new_sub_path (cr);
cairo_arc (cr,
x + exterior_size / 2.,
y + exterior_size / 2.,
(exterior_size - 1) / 2.,
0, 2 * G_PI);
gdk_cairo_set_source_rgba (cr, &builtin->bg_color);
cairo_fill_preserve (cr);
gdk_cairo_set_source_rgba (cr, &builtin->border_color);
cairo_stroke (cr);
}
gdk_cairo_set_source_rgba (cr, &builtin->fg_color);
/* FIXME: thickness */
thickness = 1;
if (inconsistent)
{
gint line_thickness;
pad = thickness + MAX (1, (exterior_size - 2 * thickness) / 9);
interior_size = MAX (1, exterior_size - 2 * pad);
if (interior_size < 7)
{
interior_size = 7;
pad = MAX (0, (exterior_size - interior_size) / 2);
}
line_thickness = MAX (1, (3 + interior_size * 2) / 7);
cairo_rectangle (cr,
x + pad,
y + pad + (interior_size - line_thickness) / 2.,
interior_size,
line_thickness);
cairo_fill (cr);
}
if (checked)
{
pad = thickness + MAX (1, 2 * (exterior_size - 2 * thickness) / 9);
interior_size = MAX (1, exterior_size - 2 * pad);
if (interior_size < 5)
{
interior_size = 7;
pad = MAX (0, (exterior_size - interior_size) / 2);
}
cairo_new_sub_path (cr);
cairo_arc (cr,
x + pad + interior_size / 2.,
y + pad + interior_size / 2.,
interior_size / 2.,
0, 2 * G_PI);
cairo_fill (cr);
}
}
开发者ID:Distrotech,项目名称:gtk,代码行数:84,代码来源:gtkcssimagebuiltin.c
示例4: on_expose_event
/*
Set gadget's background
*/
gboolean
on_expose_event (GtkWidget *widget, GdkEventExpose *event, temp_notifier_gadget_s *core)
{
cairo_t *cr;
double x0 = 5.0;
double y0 = 15.0;
double rect_width = core->width - 10;
double rect_height = core->height - 25;
double radius = 40;
double x1,y1;
cr = gdk_cairo_create (widget->window);
/* Set gadget background transparent */
cairo_set_source_rgba (cr, 1.0, 1.0, 1.0, 0.0);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_paint (cr);
x1 = x0 + rect_width;
y1 = y0 + rect_height;
if (!rect_width || !rect_height)
return;
cairo_move_to (cr, x0, (y0 + y1)/2);
cairo_curve_to (cr, x0 ,y0, x0, y0, (x0 + x1)/2, y0);
cairo_curve_to (cr, x1, y0, x1, y0, x1, (y0 + y1)/2);
cairo_curve_to (cr, x1, y1, x1, y1, (x1 + x0)/2, y1);
cairo_curve_to (cr, x0, y1, x0, y1, x0, (y0 + y1)/2);
cairo_close_path (cr);
cairo_set_source_rgba (cr,
(float) core->gadget.red / 65535.0,
(float) core->gadget.green / 65535.0,
(float) core->gadget.blue / 65535.0,
1);
cairo_fill_preserve (cr);
switch (core->border_value)
{
case 1:
gdk_color_parse ("#CC4400", &core->border);
break;
case 2:
gdk_color_parse ("#CC6600", &core->border);
break;
case 3:
gdk_color_parse ("#CCBB00", &core->border);
break;
case 4:
gdk_color_parse ("#CCDD00", &core->border);
break;
case 5:
gdk_color_parse ("#99DD00", &core->border);
break;
case 6:
gdk_color_parse ("#00EE44", &core->border);
break;
case 7: /* Super green */
gdk_color_parse ("#00BB44", &core->border);
break;
case -1: /* Super red */
gdk_color_parse ("#002200", &core->border);
break;
default:
gdk_color_parse ("#CCCCCC", &core->border);
break;
}
cairo_set_source_rgba (cr,
(float) core->border.red / 65535.0,
(float) core->border.green / 65535.0,
(float) core->border.blue / 65535.0,
core->border_transparency);
cairo_set_line_width (cr, 3.0);
cairo_stroke (cr);
cairo_destroy(cr);
return FALSE;
}
开发者ID:andypc,项目名称:Temp-Notifier-Gadget,代码行数:87,代码来源:temp_notifier_gadget_cairo.c
示例5: _lib_navigation_expose_callback
static gboolean _lib_navigation_expose_callback(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
{
dt_lib_module_t *self = (dt_lib_module_t *)user_data;
dt_lib_navigation_t *d = (dt_lib_navigation_t *)self->data;
const int inset = DT_NAVIGATION_INSET;
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
int width = allocation.width, height = allocation.height;
dt_develop_t *dev = darktable.develop;
if (dev->preview_dirty) return FALSE;
/* get the current style */
GtkStyle *style=gtk_rc_get_style_by_paths(gtk_settings_get_default(), NULL,"GtkWidget", GTK_TYPE_WIDGET);
if(!style) style = gtk_rc_get_style(widget);
cairo_surface_t *cst = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height);
cairo_t *cr = cairo_create(cst);
/* fill background */
cairo_set_source_rgb(cr, style->bg[0].red/65535.0, style->bg[0].green/65535.0, style->bg[0].blue/65535.0);
cairo_paint(cr);
width -= 2*inset;
height -= 2*inset;
cairo_translate(cr, inset, inset);
/* draw navigation image if available */
if(dev->preview_pipe->backbuf && !dev->preview_dirty)
{
dt_pthread_mutex_t *mutex = &dev->preview_pipe->backbuf_mutex;
dt_pthread_mutex_lock(mutex);
const int wd = dev->preview_pipe->backbuf_width;
const int ht = dev->preview_pipe->backbuf_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 (dev->preview_pipe->backbuf, 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);
// draw shadow around
float alpha = 1.0f;
for(int k=0; k<4; k++)
{
cairo_rectangle(cr, -k/scale, -k/scale, wd + 2*k/scale, ht + 2*k/scale);
cairo_set_source_rgba(cr, 0, 0, 0, alpha);
alpha *= 0.6f;
cairo_fill(cr);
}
cairo_rectangle(cr, 0, 0, wd-2, ht-1);
cairo_set_source_surface (cr, surface, 0, 0);
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_FAST);
cairo_fill(cr);
cairo_surface_destroy (surface);
dt_pthread_mutex_unlock(mutex);
// draw box where we are
dt_dev_zoom_t zoom;
int closeup;
float zoom_x, zoom_y;
DT_CTL_GET_GLOBAL(zoom, dev_zoom);
DT_CTL_GET_GLOBAL(closeup, dev_closeup);
DT_CTL_GET_GLOBAL(zoom_x, dev_zoom_x);
DT_CTL_GET_GLOBAL(zoom_y, dev_zoom_y);
const float min_scale = dt_dev_get_zoom_scale(dev, DT_ZOOM_FIT, closeup ? 2.0 : 1.0, 0);
const float cur_scale = dt_dev_get_zoom_scale(dev, zoom, closeup ? 2.0 : 1.0, 0);
// avoid numerical instability for small resolutions:
double h,w;
if(cur_scale > min_scale)
{
float boxw = 1, boxh = 1;
dt_dev_check_zoom_bounds(darktable.develop, &zoom_x, &zoom_y, zoom, closeup, &boxw, &boxh);
cairo_translate(cr, wd*(.5f+zoom_x), ht*(.5f+zoom_y));
cairo_set_source_rgb(cr, 0., 0., 0.);
cairo_set_line_width(cr, 1.f/scale);
boxw *= wd;
boxh *= ht;
cairo_rectangle(cr, -boxw/2-1, -boxh/2-1, boxw+2, boxh+2);
cairo_stroke(cr);
cairo_set_source_rgb(cr, 1., 1., 1.);
cairo_rectangle(cr, -boxw/2, -boxh/2, boxw, boxh);
cairo_stroke(cr);
}
if(fabsf(cur_scale - min_scale) > 0.001f)
{
/* Zoom % */
cairo_identity_matrix(cr);
cairo_translate(cr, 0, height);
cairo_set_source_rgba(cr, 1., 1., 1., 0.5);
cairo_select_font_face (cr, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size (cr, 11);
char zoomline[5];
snprintf(zoomline, 5, "%.0f%%", cur_scale*100);
//.........这里部分代码省略.........
开发者ID:EvilBit,项目名称:darktable,代码行数:101,代码来源:navigation.c
示例6: _awn_overlay_progress_circle_render
static void
_awn_overlay_progress_circle_render (AwnOverlay* _overlay,
GtkWidget *widget,
cairo_t * cr,
gint width,
gint height)
{
AwnOverlayProgressCircle * overlay = AWN_OVERLAY_PROGRESS_CIRCLE(_overlay);
AwnOverlayProgressCirclePrivate *priv;
DesktopAgnosticColor * fg_color;
DesktopAgnosticColor * bg_color;
DesktopAgnosticColor * outline_color;
gdouble percent_complete, x_pos, y_pos;
AwnOverlayCoord coord;
priv = AWN_OVERLAY_PROGRESS_CIRCLE_GET_PRIVATE (overlay);
g_object_get (overlay,
"percent-complete",&percent_complete,
NULL);
if (priv->fg_color)
{
fg_color = priv->fg_color;
g_object_ref (fg_color);
}
else
{
fg_color = desktop_agnostic_color_new(&widget->style->bg[GTK_STATE_ACTIVE],
0.7*G_MAXUSHORT);
}
if (priv->bg_color)
{
bg_color = priv->bg_color;
g_object_ref (bg_color);
}
else
{
bg_color = desktop_agnostic_color_new(&widget->style->fg[GTK_STATE_ACTIVE],
0.2 * G_MAXUSHORT);
}
if (priv->outline_color)
{
outline_color = priv->outline_color;
g_object_ref (outline_color);
}
else
{
outline_color = desktop_agnostic_color_new(&widget->style->fg[GTK_STATE_ACTIVE],
G_MAXUSHORT);
}
awn_overlay_move_to (_overlay, cr, width, height,
width * priv->scale, height * priv->scale,
&coord);
x_pos = coord.x / width + priv->scale / 2.0;
y_pos = coord.y / height + priv->scale / 2.0;
cairo_save (cr);
cairo_scale (cr, width, height);
cairo_set_line_width (cr, 2. / (width + height));
awn_cairo_set_source_color (cr,bg_color);
cairo_arc (cr, x_pos, y_pos, priv->scale/2.0, 0, 2 * M_PI);
cairo_fill (cr);
cairo_arc (cr, x_pos, y_pos, priv->scale/2.0, -0.5 * M_PI,
2 * (percent_complete/100.0) * M_PI -0.5 * M_PI );
cairo_line_to (cr, x_pos, y_pos);
cairo_close_path (cr);
awn_cairo_set_source_color (cr,fg_color);
cairo_fill (cr);
if (percent_complete > 0)
{
cairo_arc (cr, x_pos, y_pos, priv->scale/2.0, -0.5 * M_PI,
2 * (percent_complete/100.0) * M_PI -0.5 * M_PI );
if (percent_complete < 100)
{
cairo_line_to (cr, x_pos, y_pos);
cairo_close_path (cr);
}
awn_cairo_set_source_color (cr, outline_color);
cairo_stroke (cr);
}
cairo_restore (cr);
g_object_unref (fg_color);
g_object_unref (bg_color);
g_object_unref (outline_color);
}
开发者ID:Sprezzatech,项目名称:avant-window-navigator,代码行数:91,代码来源:awn-overlay-progress-circle.c
示例7: makeplot
static void makeplot(const char* plotfn, char* bgimgfn, int W, int H,
int Nfield, double* fieldpix, double* fieldsigma2s,
int Nindex, double* indexpix, int besti, int* theta,
double* crpix, int* testperm,
double * qc) {
int i;
plot_args_t pargs;
plotimage_t* img;
cairo_t* cairo;
int ti;
logmsg("Creating plot %s\n", plotfn);
plotstuff_init(&pargs);
pargs.outformat = PLOTSTUFF_FORMAT_PNG;
pargs.outfn = plotfn;
pargs.fontsize = 12;
if (bgimgfn) {
img = plotstuff_get_config(&pargs, "image");
img->format = PLOTSTUFF_FORMAT_JPG;
plot_image_set_filename(img, bgimgfn);
plot_image_setsize(&pargs, img);
plotstuff_run_command(&pargs, "image");
} else {
float rgba[4] = {0, 0, 0.1, 1.0};
plotstuff_set_size(&pargs, W, H);
//plotstuff_init2(&pargs);
plotstuff_set_rgba(&pargs, rgba);
plotstuff_run_command(&pargs, "fill");
}
cairo = pargs.cairo;
// red circles around every field star.
cairo_set_color(cairo, "gray");
for (i=0; i<Nfield; i++) {
cairoutils_draw_marker(cairo, CAIROUTIL_MARKER_CIRCLE,
fieldpix[2*i+0], fieldpix[2*i+1],
2.0 * sqrt(fieldsigma2s[i]));
cairo_stroke(cairo);
}
// green crosshairs at every index star.
cairo_set_color(cairo, "green");
for (i=0; i<Nindex; i++) {
cairoutils_draw_marker(cairo, CAIROUTIL_MARKER_XCROSSHAIR,
indexpix[2*i+0], indexpix[2*i+1], 3);
cairo_stroke(cairo);
}
// thick white circles for corresponding field stars.
cairo_set_line_width(cairo, 2);
for (ti=0; ti<=besti; ti++) {
if (testperm)
i = testperm[ti];
else
i = ti;
//printf("field %i -> index %i\n", i, theta[i]);
if (theta[i] < 0)
continue;
cairo_set_color(cairo, "white");
cairoutils_draw_marker(cairo, CAIROUTIL_MARKER_CIRCLE,
fieldpix[2*i+0], fieldpix[2*i+1],
2.0 * sqrt(fieldsigma2s[i]));
cairo_stroke(cairo);
// thick cyan crosshairs for corresponding index stars.
cairo_set_color(cairo, "cyan");
cairoutils_draw_marker(cairo, CAIROUTIL_MARKER_XCROSSHAIR,
indexpix[2*theta[i]+0],
indexpix[2*theta[i]+1],
3);
cairo_stroke(cairo);
}
cairo_set_line_width(cairo, 2);
//for (i=0; i<=besti; i++) {
for (ti=0; ti<Nfield; ti++) {
anbool mark = TRUE;
if (testperm)
i = testperm[ti];
else
i = ti;
switch (theta[i]) {
case THETA_DISTRACTOR:
cairo_set_color(cairo, "red");
break;
case THETA_CONFLICT:
cairo_set_color(cairo, "yellow");
break;
case THETA_FILTERED:
cairo_set_color(cairo, "orange");
break;
default:
if (theta[i] < 0) {
cairo_set_color(cairo, "gray");
} else {
cairo_set_color(cairo, "white");
}
mark = FALSE;
}
if (mark) {
cairoutils_draw_marker(cairo, CAIROUTIL_MARKER_CIRCLE,
fieldpix[2*i+0], fieldpix[2*i+1],
2.0 * sqrt(fieldsigma2s[i]));
//.........这里部分代码省略.........
开发者ID:rasmi,项目名称:astrometry.net,代码行数:101,代码来源:tweak2.c
示例8: _make_bar_surface
static void _make_bar_surface (ProgressBar *pProgressBar)
{
CairoDataRenderer *pRenderer = CAIRO_DATA_RENDERER (pProgressBar);
int iWidth = pRenderer->iWidth;
if (pProgressBar->cImageGradation != NULL) // an image is provided
{
pProgressBar->pBarSurface = cairo_dock_create_surface_from_image_simple (
pProgressBar->cImageGradation,
iWidth,
pProgressBar->iBarThickness);
}
if (pProgressBar->pBarSurface == NULL) // no image was provided, or it was not valid.
{
// create a surface to bufferize the pattern.
pProgressBar->pBarSurface = cairo_dock_create_blank_surface (iWidth, pProgressBar->iBarThickness);
cairo_t *ctx = cairo_create (pProgressBar->pBarSurface);
cairo_pattern_t *pGradationPattern = NULL;
if (myIndicatorsParam.bBarUseDefaultColors)
{
gldi_style_colors_set_selected_bg_color (ctx);
}
else
{
// create the pattern.
pGradationPattern = cairo_pattern_create_linear (0.,
0.,
iWidth,
0.); // de gauche a droite.
g_return_if_fail (cairo_pattern_status (pGradationPattern) == CAIRO_STATUS_SUCCESS);
cairo_pattern_set_extend (pGradationPattern, CAIRO_EXTEND_NONE);
gdouble *fColorGradation = pProgressBar->fColorGradation;
int iNbColors = 2;
int i;
for (i = 0; i < iNbColors; i ++)
{
cairo_pattern_add_color_stop_rgba (pGradationPattern,
(double)i / (iNbColors-1),
fColorGradation[4*i+0],
fColorGradation[4*i+1],
fColorGradation[4*i+2],
fColorGradation[4*i+3]);
}
cairo_set_source (ctx, pGradationPattern);
}
// draw the pattern on the surface.
cairo_set_operator (ctx, CAIRO_OPERATOR_OVER);
cairo_set_line_width (ctx, pProgressBar->iBarThickness);
double r = .5*pProgressBar->iBarThickness; // radius
cairo_move_to (ctx, 0, r);
cairo_rel_line_to (ctx, iWidth, 0);
cairo_stroke (ctx);
if (pGradationPattern)
cairo_pattern_destroy (pGradationPattern);
cairo_destroy (ctx);
}
pProgressBar->iBarTexture = cairo_dock_create_texture_from_surface (pProgressBar->pBarSurface);
}
开发者ID:363734,项目名称:cairo-dock-core,代码行数:67,代码来源:cairo-dock-progressbar.c
示例9: twin_scaled_font_render_glyph
static cairo_status_t
twin_scaled_font_render_glyph (cairo_scaled_font_t *scaled_font,
unsigned long glyph,
cairo_t *cr,
cairo_text_extents_t *metrics)
{
double x1, y1, x2, y2, x3, y3;
const int8_t *b = _cairo_twin_outlines +
_cairo_twin_charmap[glyph >= ARRAY_LENGTH (_cairo_twin_charmap) ? 0 : glyph];
const int8_t *g = twin_glyph_draw(b);
struct {
cairo_bool_t snap;
int snap_x;
int snap_y;
int n_snap_x;
int n_snap_y;
} info = {FALSE};
cairo_set_line_width (cr, 0.06);
cairo_set_line_join (cr, CAIRO_LINE_JOIN_ROUND);
cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND);
for (;;) {
switch (*g++) {
case 'M':
cairo_close_path (cr);
/* fall through */
case 'm':
x1 = FX(*g++);
y1 = FY(*g++);
if (info.snap)
{
x1 = SNAPX (x1);
y1 = SNAPY (y1);
}
cairo_move_to (cr, x1, y1);
continue;
case 'L':
cairo_close_path (cr);
/* fall through */
case 'l':
x1 = FX(*g++);
y1 = FY(*g++);
if (info.snap)
{
x1 = SNAPX (x1);
y1 = SNAPY (y1);
}
cairo_line_to (cr, x1, y1);
continue;
case 'C':
cairo_close_path (cr);
/* fall through */
case 'c':
x1 = FX(*g++);
y1 = FY(*g++);
x2 = FX(*g++);
y2 = FY(*g++);
x3 = FX(*g++);
y3 = FY(*g++);
if (info.snap)
{
x1 = SNAPX (x1);
y1 = SNAPY (y1);
x2 = SNAPX (x2);
y2 = SNAPY (y2);
x3 = SNAPX (x3);
y3 = SNAPY (y3);
}
cairo_curve_to (cr, x1, y1, x2, y2, x3, y3);
continue;
case 'E':
cairo_close_path (cr);
/* fall through */
case 'e':
cairo_stroke (cr);
break;
case 'X':
/* filler */
continue;
}
break;
}
metrics->x_advance = FX(twin_glyph_right(b)) + cairo_get_line_width (cr);
metrics->x_advance += cairo_get_line_width (cr)/* XXX 2*x.margin */;
if (info.snap)
metrics->x_advance = SNAPI (SNAPX (metrics->x_advance));
return CAIRO_STATUS_SUCCESS;
}
开发者ID:3oyka,项目名称:cairo2,代码行数:93,代码来源:cairo-font-face-twin.c
示例10: active_sensor_update_graph
static void active_sensor_update_graph(ActiveSensor *as, cairo_t *cr) {
GtkAllocation allocation;
gdouble line_height;
gdouble width, height;
gdouble x, y;
cairo_pattern_t *pattern;
gint i;
gtk_widget_get_allocation (as->graph, &allocation);
width = allocation.width;
height = allocation.height;
/* so we can set a clipping area, as well as fill the
* back of the graph black */
cairo_rectangle(cr,
0, 0,
width,
height);
/* clip to rectangle and keep it as a path so can be
* filled below */
cairo_clip_preserve(cr);
/* use black for bg color of graphs */
cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
cairo_fill(cr);
/* determine height to scale line at for each value -
* only do as many as will fit or the number of
* samples that we have */
for (i = 0; i < MIN(as->num_samples, width); i++) {
/* need to remove one more to make it line up
* properly when drawing */
x = width - i - 1;
y = height;
line_height = sensor_value_range_normalised(as->sensor_values[i],
as->sensor_low_value,
as->sensor_high_value) * height;
if (line_height > 0) {
cairo_move_to(cr,
x,
y);
cairo_line_to(cr, x,
y - line_height);
}
}
/* make lines a gradient from slightly darker than
* chosen color at bottom of graph, to slightly
* lighter than chosen color at top of graph */
pattern = cairo_pattern_create_linear(x, y,
x, 0);
cairo_pattern_add_color_stop_rgb(pattern,
0,
as->graph_color.red / 65535.0 - CAIRO_GRAPH_COLOR_GRADIENT,
as->graph_color.green / 65535.0 - CAIRO_GRAPH_COLOR_GRADIENT,
as->graph_color.blue / 65535.0 - CAIRO_GRAPH_COLOR_GRADIENT);
cairo_pattern_add_color_stop_rgb(pattern,
height,
as->graph_color.red / 65535.0 + CAIRO_GRAPH_COLOR_GRADIENT,
as->graph_color.green / 65535.0 + CAIRO_GRAPH_COLOR_GRADIENT,
as->graph_color.blue / 65535.0 + CAIRO_GRAPH_COLOR_GRADIENT);
cairo_set_source(cr, pattern);
cairo_stroke(cr);
cairo_pattern_destroy(pattern);
}
开发者ID:fatman2021,项目名称:mate-sensors-applet,代码行数:72,代码来源:active-sensor.c
示例11: draw_cursor
/**
* Draw the cursor on the canvas at the given position
* insert_control is the last gap from the previous note except when the cursor is on a measure boundary in which case it is +1 or -1 to indicate where next inserted note will go.
* minpixels is width of rectangle to draw indicating an object position (used when not a CHORD
*/
void
draw_cursor (cairo_t * cr, DenemoMovement * si, gint xx, gint y, gint insert_control, gint minpixels, gint dclef)
{
if (!cr)
return;
gint height = calculateheight (si->cursor_y, dclef);
gdouble scale = transition_cursor_scale ();
cairo_save (cr);
cairo_set_source_rgba (cr, 255 * (si->cursoroffend), (!si->cursoroffend) * (!si->cursor_appending) * 255, (!si->cursoroffend) * (si->cursor_appending) * 255, 0.7);
if (si->cursor_appending)
{
cairo_rectangle (cr, xx - (si->cursoroffend ? CURSOR_WIDTH : 0), height + y - CURSOR_HEIGHT, 2 * CURSOR_WIDTH, 2 * CURSOR_HEIGHT);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0, 0, 0,1);
cairo_rectangle (cr, xx - (si->cursoroffend ? CURSOR_WIDTH : 0), height + y - CURSOR_HEIGHT, 2 * CURSOR_WIDTH, 2 * CURSOR_HEIGHT);
cairo_stroke (cr);
}
else if (minpixels)
{
cairo_rectangle (cr, xx - CURSOR_WIDTH / 2, height + y - CURSOR_MINUS - CURSOR_HEIGHT / 2, minpixels, 2 * CURSOR_HEIGHT);
cairo_fill (cr);
cairo_set_line_width (cr, 2);
cairo_set_source_rgba (cr, 0.6, 0.6, 0, 0.60);
cairo_rectangle (cr, xx + - CURSOR_WIDTH / 2, y - CURSOR_HEIGHT * 2 , minpixels, STAFF_HEIGHT + CURSOR_HEIGHT * 4);
cairo_stroke (cr);
}
else
{
cairo_rectangle (cr, xx - CURSOR_WIDTH / 2, height + y - CURSOR_MINUS - CURSOR_HEIGHT / 2, 2 * CURSOR_WIDTH, 2 * CURSOR_HEIGHT);
cairo_fill (cr);
cairo_set_source_rgba (cr, 0, 0, 0,1);
cairo_rectangle (cr, xx - CURSOR_WIDTH / 2, height + y - CURSOR_MINUS - CURSOR_HEIGHT / 2, 2 * CURSOR_WIDTH, 2 * CURSOR_HEIGHT);
cairo_stroke (cr);
}
{
gdouble length = 20 / si->zoom;
gdouble insert_pos = CURSOR_WIDTH * 0.8;
if (!si->cursor_appending)
{
insert_pos = -insert_control / 4;
}
else if (si->cursoroffend)
insert_pos = insert_control * CURSOR_WIDTH;
static gboolean on;
on = !on;//g_print (" %d and %x\n", gtk_widget_has_focus (gtk_widget_get_parent (Denemo.scorearea)), gtk_widget_get_state_flags (Denemo.scorearea));
//g_debug("on is %d %d\n", on, Denemo.prefs.cursor_highlight);
if (((!Denemo.prefs.cursor_highlight) || (on && Denemo.prefs.cursor_highlight)) && (gtk_widget_has_focus (Denemo.scorearea) && gtk_widget_is_focus (Denemo.scorearea)))
{
cairo_set_source_rgb (cr, 0, 0, 255);
cairo_set_line_width (cr, 4);
cairo_move_to (cr, xx + insert_pos, y + 4);
cairo_rel_line_to (cr, 0, STAFF_HEIGHT - 8);
cairo_stroke (cr);
//setcairocolor( cr, paintgc );
if (Denemo.project->view == DENEMO_PAGE_VIEW)
{
cairo_set_line_width (cr, 6.0 / si->zoom);
cairo_set_source_rgba (cr, 0, 1, 0, 0.40);
cairo_arc (cr, xx + CURSOR_WIDTH / 2, height + y, length, 0, 2 * M_PI);
cairo_stroke (cr);
}
if(Denemo.project->audio_recording)
highlight_audio_record();
}
}
cairo_restore (cr);
/* Now draw ledgers if necessary and we're done */
draw_ledgers (cr, height, height, xx, y, CURSOR_WIDTH);
}
开发者ID:denemo,项目名称:denemo,代码行数:92,代码来源:drawcursor.c
示例12: do_glide_draw_arrow
//.........这里部分代码省略.........
x += (width - aw) / 2 ;
y += (height - ah) / 2;
width = aw;
height = ah;
width += width % 2 - 1;
points[0].x = x;
points[1].x = x + width - 1;
points[2].x = x + ((height - 1) - (height - (1 + width / 2)));
points[0].y = points[1].y = y;
points[2].y = y + height - 1;
if (arrow_type == GTK_ARROW_UP)
{
gint flip = points[1].y;
points[0].y = points[1].y = points[2].y;
points[2].y = flip;
}
}
break;
case GTK_ARROW_LEFT:
case GTK_ARROW_RIGHT:
{
gdouble tmp=((ah+1)/2) - ((width%2)?1:0);
if (tmp > aw)
{
ah = 2*aw - 1 - ((width%2)?1:0);
aw = (ah+1)/2;
}
else
{
aw = (gint) tmp;
ah = 2*aw - 1;
}
if ((ah < 5) || (aw < 3))
{
ah = 5;
aw = 3;
}
x += (width - aw) / 2 ;
y += (height - ah) / 2;
width = aw;
height = ah;
height += height % 2 - 1;
points[0].y = y;
points[1].y = y + height - 1;
points[2].y = y + ((width - 1) - (width - (1 + height / 2)));
points[0].x = points[1].x = x;
points[2].x = x + width - 1;
if (arrow_type == GTK_ARROW_LEFT)
{
gint flip = points[0].x;
points[0].x = points[1].x = points[2].x;
points[2].x = flip;
}
}
break;
default:
{
return;
}
}
cairo_save(canvas);
ge_cairo_set_color(canvas, color);
cairo_set_line_width (canvas, 0.5);
cairo_move_to(canvas, points[0].x + 0.5, points[0].y + 0.5);
cairo_line_to(canvas, points[1].x + 0.5, points[1].y + 0.5);
cairo_line_to(canvas, points[2].x + 0.5, points[2].y + 0.5);
cairo_line_to(canvas, points[0].x + 0.5, points[0].y + 0.5);
if (fill)
{
cairo_stroke_preserve(canvas);
cairo_fill(canvas);
}
else
{
cairo_stroke(canvas);
}
cairo_restore(canvas);
}
开发者ID:Distrotech,项目名称:gtk-engines,代码行数:101,代码来源:glide_gtk2_support.c
示例13: do_glide_draw_check
//.........这里部分代码省略.........
* check mark using the passed Color.
*
* It originated in Smooth-Engine.
***********************************************/
void
do_glide_draw_check (cairo_t *canvas,
CairoColor * color,
gint x,
gint y,
gint width,
gint height)
{
/*
EVEN -
0 1 2 3 4 5 6 7 8 9
+---+---+---+---+---+---+---+---+---+---+
0 | | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
1 | | | | | | | | | x | |
+---+---+---+---+---+---+---+---+---+---+
2 | | | | | | | | x | x | |
+---+---+---+---+---+---+---+---+---+---+
3 | | | | | | | x | x | x | |
+---+---+---+---+---+---+---+---+---+---+
4 | | x | | | | x | x | x | | |
+---+---+---+---+---+---+---+---+---+---+
5 | | x | x | | x | x | x | | | |
+---+---+---+---+---+---+---+---+---+---+
6 | | x | x | x | x | x | | | | |
+---+---+---+---+---+---+---+---+---+---+
7 | | | x | x | x | | | | | |
+---+---+---+---+---+---+---+---+---+---+
8 | | | | x | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
9 | | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+---+
ODD -
0 1 2 3 4 5 6 7 8
+---+---+---+---+---+---+---+---+---+
0 | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+
1 | | | | | | | | x | |
+---+---+---+---+---+---+---+---+---+
2 | | | | | | | x | x | |
+---+---+---+---+---+---+---+---+---+
3 | | x | | | | x | x | x | |
+---+---+---+---+---+---+---+---+---+
4 | | x | x | | x | x | x | | |
+---+---+---+---+---+---+---+---+---+
5 | | x | x | x | x | x | | | |
+---+---+---+---+---+---+---+---+---+
6 | | | x | x | x | | | | |
+---+---+---+---+---+---+---+---+---+
7 | | | | x | | | | | |
+---+---+---+---+---+---+---+---+---+
8 | | | | | | | | | |
+---+---+---+---+---+---+---+---+---+
*/
gint odd = 0;
gdouble left, top;
gint scale, factor;
scale = MIN(width, height);
factor = 10;
if ((odd = (scale % 2)))
{
factor -= 1;
}
if (scale <= (factor + 2))
scale = factor;
left = x + floor((width - scale) / 2) + 0.5;
top = y + floor((height - scale) / 2) + 0.5;
cairo_save(canvas);
ge_cairo_set_color(canvas, color);
cairo_set_line_width(canvas, 0.5);
cairo_move_to(canvas, left + floor((1*scale)/factor), top + floor(((4-odd)*scale)/factor)); /*(1,4-odd)*/
cairo_line_to(canvas, left + floor((1*scale)/factor), top + floor(((6-odd)*scale)/factor)); /*(1,6-odd)*/
cairo_line_to(canvas, left + floor((3*scale)/factor), top + floor(((8-odd)*scale)/factor)); /*(3,8-odd)*/
cairo_line_to(canvas, left + floor(((8-odd)*scale)/factor), top + floor((3*scale)/factor)); /*(8-odd,3)*/
cairo_line_to(canvas, left + floor(((8-odd)*scale)/factor), top + floor((1*scale)/factor)); /*(8-odd,1)*/
cairo_line_to(canvas, left + floor((3*scale)/factor), top + floor(((6-odd)*scale)/factor)); /*(3,6-odd)*/
cairo_line_to(canvas, left + floor((1*scale)/factor), top + floor(((4-odd)*scale)/factor)); /*(1,4-odd)*/
cairo_fill_preserve(canvas);
cairo_stroke(canvas);
cairo_restore(canvas);
}
开发者ID:Distrotech,项目名称:gtk-engines,代码行数:101,代码来源:glide_gtk2_support.c
示例14: cairo_save
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
if (paintingDisabled() || strokeStyle() == NoStroke)
return;
int x = rect.x();
int y = rect.y();
float w = rect.width();
float h = rect.height();
float scaleFactor = h / w;
float reverseScaleFactor = w / h;
float hRadius = w / 2;
float vRadius = h / 2;
float fa = startAngle;
float falen = fa + angleSpan;
cairo_t* cr = m_data->cr;
cairo_save(cr);
if (w != h)
cairo_scale(cr, 1., scaleFactor);
cairo_arc_negative(cr, x + hRadius, (y + vRadius) * reverseScaleFactor, hRadius, -fa * M_PI/180, -falen * M_PI/180);
if (w != h)
cairo_scale(cr, 1., reverseScaleFactor);
float width = strokeThickness();
int patWidth = 0;
switch (strokeStyle()) {
case DottedStroke:
patWidth = static_cast<int>(width / 2);
break;
case DashedStroke:
patWidth = 3 * static_cast<int>(width / 2);
break;
default:
break;
}
setColor(cr, strokeColor());
if (patWidth) {
// Example: 80 pixels with a width of 30 pixels.
// Remainder is 20. The maximum pixels of line we could paint
// will be 50 pixels.
int distance;
if (hRadius == vRadius)
distance = static_cast<int>((M_PI * hRadius) / 2.0);
else // We are elliptical and will have to estimate the distance
distance = static_cast<int>((M_PI * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.0)) / 2.0);
int remainder = distance % patWidth;
int coverage = distance - remainder;
int numSegments = coverage / patWidth;
float patternOffset = 0.0;
// Special case 1px dotted borders for speed.
if (patWidth == 1)
patternOffset = 1.0;
else {
bool evenNumberOfSegments = numSegments % 2 == 0;
if (remainder)
evenNumberOfSegments = !evenNumberOfSegments;
if (evenNumberOfSegments) {
if (remainder) {
patternOffset += patWidth - remainder;
patternOffset += remainder / 2.0;
} else
patternOffset = patWidth / 2.0;
} else {
if (remainder)
patternOffset = (patWidth - remainder) / 2.0;
}
}
double dash = patWidth;
cairo_set_dash(cr, &dash, 1, patternOffset);
}
cairo_stroke(cr);
cairo_restore(cr);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:85,代码来源:BCGraphicsContextCairo.cpp
示例15: create_marker
/* The marker is drawn with cairo. It is composed of 1 static filled circle
* and 1 stroked circle animated as an echo.
*/
static ClutterActor *
create_marker ()
{
ClutterActor *marker;
ClutterActor *bg;
ClutterTimeline *timeline;
cairo_t *cr;
/* Create the marker */
marker = champlain_custom_marker_new ();
/* Static filled circle ----------------------------------------------- */
bg = clutter_cairo_texture_new (MARKER_SIZE, MARKER_SIZE);
cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint(cr);
cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
/* Draw the circle */
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_arc (cr, MARKER_SIZE / 2.0, MARKER_SIZE / 2.0, MARKER_SIZE / 2.0, 0, 2 * M_PI);
cairo_close_path (cr);
/* Fill the circle */
cairo_set_source_rgba (cr, 0.1, 0.1, 0.9, 1.0);
cairo_fill (cr);
cairo_destroy (cr);
/* Add the circle to the marker */
clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg);
clutter_actor_set_anchor_point_from_gravity (bg, CLUTTER_GRAVITY_CENTER);
clutter_actor_set_position (bg, 0, 0);
/* Echo circle -------------------------------------------------------- */
bg = clutter_cairo_texture_new (2 * MARKER_SIZE, 2 * MARKER_SIZE);
cr = clutter_cairo_texture_create (CLUTTER_CAIRO_TEXTURE (bg));
/* Draw the circle */
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_arc (cr, MARKER_SIZE, MARKER_SIZE, 0.9 * MARKER_SIZE, 0, 2 * M_PI);
cairo_close_path (cr);
/* Stroke the circle */
cairo_set_line_width (cr, 2.0);
cairo_set_source_rgba (cr, 0.1, 0.1, 0.7, 1.0);
cairo_stroke (cr);
cairo_destroy (cr);
/* Add the circle to the marker */
clutter_container_add_actor (CLUTTER_CONTAINER (marker), bg);
clutter_actor_lower_bottom (bg); /* Ensure it is under the previous circle */
clutter_actor_set_position (bg, 0, 0);
clutter_actor_set_anchor_point_from_gravity (bg, CLUTTER_GRAVITY_CENTER);
/* Animate the echo circle */
timeline = clutter_timeline_new (1000);
clutter_timeline_set_loop (timeline, TRUE);
clutter_actor_set_opacity (CLUTTER_ACTOR (bg), 255);
clutter_actor_set_scale (CLUTTER_ACTOR (bg), 0.5, 0.5);
clutter_actor_animate_with_timeline (CLUTTER_ACTOR (bg),
CLUTTER_EASE_OUT_SINE,
timeline,
"opacity", 0,
"scale-x", 2.0,
"scale-y", 2.0,
NULL);
clutter_timeline_start (timeline);
return marker;
}
开发者ID:PabloCastellano,项目名称:libchamplain,代码行数:77,代码来源:animated-marker.c
示例16: dt_iop_levels_area_draw
|
请发表评论