本文整理汇总了C++中cairo_set_line_width函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_set_line_width函数的具体用法?C++ cairo_set_line_width怎么用?C++ cairo_set_line_width使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_set_line_width函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: polygon_view_draw
static void
polygon_view_draw (PolygonView *self, cairo_t *cr)
{
polygon_t *polygon;
gdouble sf_x, sf_y, sf;
gdouble mid, dim;
gdouble x0, y0;
box_t extents;
extents = self->extents;
mid = (extents.p2.x + extents.p1.x) / 2.;
dim = (extents.p2.x - extents.p1.x) / 2. * 1.25;
sf_x = self->widget.allocation.width / dim / 2;
mid = (extents.p2.y + extents.p1.y) / 2.;
dim = (extents.p2.y - extents.p1.y) / 2. * 1.25;
sf_y = self->widget.allocation.height / dim / 2;
sf = MIN (sf_x, sf_y);
mid = (extents.p2.x + extents.p1.x) / 2.;
dim = sf_x / sf * (extents.p2.x - extents.p1.x) / 2. * 1.25;
x0 = mid - dim;
mid = (extents.p2.y + extents.p1.y) / 2.;
dim = sf_y / sf * (extents.p2.y - extents.p1.y) / 2. * 1.25;
y0 = mid - dim;
if (self->pixmap_width != self->widget.allocation.width ||
self->pixmap_height != self->widget.allocation.height)
{
cairo_surface_destroy (self->pixmap);
self->pixmap = pixmap_create (self, cairo_get_target (cr));
self->pixmap_width = self->widget.allocation.width;
self->pixmap_height = self->widget.allocation.height;
}
cairo_set_source_surface (cr, self->pixmap, 0, 0);
cairo_paint (cr);
if (self->polygons == NULL)
return;
/* draw a zoom view of the area around the mouse */
if (1) {
double zoom = self->mag_zoom;
int size = self->mag_size;
int mag_x = self->mag_x;
int mag_y = self->mag_y;
if (1) {
if (self->px + size < self->widget.allocation.width/2)
mag_x = self->px + size/4;
else
mag_x = self->px - size/4 - size;
mag_y = self->py - size/2;
if (mag_y < 0)
mag_y = 0;
if (mag_y + size > self->widget.allocation.height)
mag_y = self->widget.allocation.height - size;
}
cairo_save (cr); {
/* bottom right */
cairo_rectangle (cr, mag_x, mag_y, size, size);
cairo_stroke_preserve (cr);
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_fill_preserve (cr);
cairo_clip (cr);
/* compute roi in extents */
cairo_translate (cr, mag_x + size/2, mag_y + size/2);
cairo_save (cr); {
cairo_scale (cr, zoom, zoom);
cairo_translate (cr, -(self->px / sf + x0), -(self->py /sf + y0));
for (polygon = self->polygons; polygon; polygon = polygon->next) {
if (polygon->num_edges == 0)
continue;
draw_polygon (cr, polygon, zoom);
}
if (highlight != -1) {
cairo_move_to (cr, extents.p1.x, highlight);
cairo_line_to (cr, extents.p2.x, highlight);
cairo_set_source_rgb (cr, 0, .7, 0);
cairo_save (cr);
cairo_identity_matrix (cr);
cairo_set_line_width (cr, 1.);
cairo_stroke (cr);
cairo_restore (cr);
}
} cairo_restore (cr);
/* grid */
cairo_save (cr); {
int i;
cairo_translate (cr,
//.........这里部分代码省略.........
开发者ID:AZed,项目名称:cairo,代码行数:101,代码来源:show-polygon.c
示例2: XOJ_CHECK_TYPE
bool PageView::paintPage(cairo_t* cr, GdkRectangle* rect)
{
XOJ_CHECK_TYPE(PageView);
static const char* txtLoading = _("Loading...");
double zoom = xournal->getZoom();
g_mutex_lock(this->drawingMutex);
int dispWidth = getDisplayWidth();
int dispHeight = getDisplayHeight();
if (this->crBuffer == NULL)
{
this->crBuffer = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, dispWidth,
dispHeight);
cairo_t* cr2 = cairo_create(this->crBuffer);
cairo_set_source_rgb(cr2, 1, 1, 1);
cairo_rectangle(cr2, 0, 0, dispWidth, dispHeight);
cairo_fill(cr2);
cairo_scale(cr2, zoom, zoom);
cairo_text_extents_t ex;
cairo_set_source_rgb(cr2, 0.5, 0.5, 0.5);
cairo_select_font_face(cr2, "Sans", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr2, 32.0);
cairo_text_extents(cr2, txtLoading, &ex);
cairo_move_to(cr2, (page->getWidth() - ex.width) / 2 - ex.x_bearing,
(page->getHeight() - ex.height) / 2 - ex.y_bearing);
cairo_show_text(cr2, txtLoading);
cairo_destroy(cr2);
rerenderPage();
}
cairo_save(cr);
double width = cairo_image_surface_get_width(this->crBuffer);
if (width != dispWidth)
{
double scale = ((double) dispWidth) / ((double) width);
// Scale current image to fit the zoom level
cairo_scale(cr, scale, scale);
cairo_pattern_set_filter(cairo_get_source(cr), CAIRO_FILTER_FAST);
cairo_set_source_surface(cr, this->crBuffer, 0, 0);
rerenderPage();
rect = NULL;
}
else
{
cairo_set_source_surface(cr, this->crBuffer, 0, 0);
}
if (rect)
{
cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
cairo_fill(cr);
#ifdef SHOW_PAINT_BOUNDS
cairo_set_source_rgb(cr, 1.0, 0.5, 1.0);
cairo_set_line_width(cr, 1. / zoom);
cairo_rectangle(cr, rect->x, rect->y, rect->width, rect->height);
cairo_stroke(cr);
#endif
}
else
{
cairo_paint(cr);
}
cairo_restore(cr);
// don't paint this with scale, because it needs a 1:1 zoom
if (this->verticalSpace)
{
this->verticalSpace->paint(cr, rect, zoom);
}
cairo_scale(cr, zoom, zoom);
if (this->textEditor)
{
this->textEditor->paint(cr, rect, zoom);
}
if (this->selection)
{
this->selection->paint(cr, rect, zoom);
}
if (this->search)
{
this->search->paint(cr, rect, zoom, getSelectionColor());
}
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:xournalpp,代码行数:101,代码来源:PageView.cpp
示例3: dataset_draw
/**
* Function: dataset_draw
*
* Draws the dataset's trajectories into a PNG image highlighting different
* groups with different colors.
*
* Parameters:
*
* config - pointer to a <visualize_config_t> structure containing
* information about the size of the image to generate and to what
* file it should be saved to
*
* dataset - pointer to a dataset
*
* groups - pointer to a groups list
*/
void dataset_draw(visualize_config_t* config, dataset_t* dataset, group_list_t* groups)
{
unsigned char* imgbuf;
cairo_surface_t* surface;
cairo_t* cr;
double scale_x;
double scale_y;
int g;
int t;
int s;
int n_groups;
group_t* gl;
double* c;
char filename_buf[256];
/* allocate memory for image buffer -- the area Cairo will draw in */
if((imgbuf = malloc(sizeof(unsigned char) * config->width * config->height * 4)) == NULL)
{
printf("Cannot allocate memory for image buffer.\n");
return;
}
/* create a drawing surface */
surface = cairo_image_surface_create_for_data(
imgbuf,
CAIRO_FORMAT_ARGB32,
config->width,
config->height,
config->width * 4
);
/* create a cairo context on the surface */
cr = cairo_create(surface);
/* compute the scaling factor based on the size of the dataset grid and the
* size of the image */
scale_x = (double)config->width / (double)dataset->grid_size;
scale_y = (double)config->height / (double)dataset->grid_size;
/* set the line width */
cairo_set_line_width(cr, config->line_width);
/* a dataset can define its own groups, use those as default if there are
* any */
n_groups = dataset->n_groups;
gl = dataset->groups;
/* if there is an explicitly defined set of groups, use those instead */
if(groups && (groups->n_groups > 0))
{
n_groups = groups->n_groups;
gl = groups->groups;
}
/* if there are no groups defined or we only draw one image, fill the
* surface with white background */
if(!config->split || n_groups == 0)
{
cairo_rectangle(cr, 0, 0, (double)config->width, (double)config->height);
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_fill(cr);
}
/* FIXME: don't know what happens here, I think this draws the entire
* dataset */
dataset_draw_help( config, dataset, groups, cr );
/* If there are groups defined draw each group individually. */
if(n_groups > 0)
{
/* for each group */
for(g = 0; g < n_groups; g++)
{
/* If we split up the group into individual images, we need to
* clear the current surface with a white background. */
if(config->split)
{
cairo_rectangle(cr, 0, 0, (double)config->width, (double)config->height);
cairo_set_source_rgb(cr, 1.0, 1.0, 1.0);
cairo_fill(cr);
dataset_draw_help( config, dataset, groups, cr ); // inserted ~~ wih fray
}
/* for each trajectory in the group */
//.........这里部分代码省略.........
开发者ID:obaltzer,项目名称:group-movement,代码行数:101,代码来源:visualize.c
示例4: draw_page
static void
draw_page (GtkPrintOperation *operation,
GtkPrintContext *context,
gint page_number,
gpointer user_data)
{
GdictPrintData *data = user_data;
cairo_t *cr;
PangoLayout *layout;
gint text_width, text_height;
gdouble width;
gint line, i;
PangoFontDescription *desc;
gchar *page_str;
cr = gtk_print_context_get_cairo_context (context);
width = gtk_print_context_get_width (context);
cairo_rectangle (cr, 0, 0, width, HEADER_HEIGHT (10));
cairo_set_source_rgb (cr, 0.8, 0.8, 0.8);
cairo_fill_preserve (cr);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_set_line_width (cr, 1);
cairo_stroke (cr);
/* header */
layout = gtk_print_context_create_pango_layout (context);
desc = pango_font_description_from_string ("sans 14");
pango_layout_set_font_description (layout, desc);
pango_font_description_free (desc);
pango_layout_set_text (layout, data->word, -1);
pango_layout_get_pixel_size (layout, &text_width, &text_height);
if (text_width > width)
{
pango_layout_set_width (layout, width);
pango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_START);
pango_layout_get_pixel_size (layout, &text_width, &text_height);
}
cairo_move_to (cr, (width - text_width) / 2,
(HEADER_HEIGHT (10) - text_height) / 2);
pango_cairo_show_layout (cr, layout);
page_str = g_strdup_printf ("%d/%d", page_number + 1, data->n_pages);
pango_layout_set_text (layout, page_str, -1);
g_free (page_str);
pango_layout_set_width (layout, -1);
pango_layout_get_pixel_size (layout, &text_width, &text_height);
cairo_move_to (cr, width - text_width - 4,
(HEADER_HEIGHT (10) - text_height) / 2);
pango_cairo_show_layout (cr, layout);
g_object_unref (layout);
/* text */
layout = gtk_print_context_create_pango_layout (context);
pango_font_description_set_size (data->font_desc,
data->font_size * PANGO_SCALE);
pango_layout_set_font_description (layout, data->font_desc);
cairo_move_to (cr, 0, HEADER_HEIGHT (10) + HEADER_GAP (3));
line = page_number * data->lines_per_page;
for (i = 0; i < data->lines_per_page && line < data->n_lines; i++)
{
pango_layout_set_text (layout, data->lines[line], -1);
pango_cairo_show_layout (cr, layout);
cairo_rel_move_to (cr, 0, data->font_size);
line++;
}
g_object_unref (layout);
}
开发者ID:kenvandine,项目名称:gnome-utils,代码行数:79,代码来源:gdict-print.c
示例5: paint_selection
/*
* function to draw the rectangular selection
*/
static void
paint_selection (cairo_t *ci, Detect * d)
{
double t = microtime();
int w = cairo_image_surface_get_width (surface);
int h = cairo_image_surface_get_height (surface);
/** draw brush */ /*
cairo_surface_t* test;
cairo_t *cb;
double brush_w = 70, brush_h = 70;
int w = cairo_image_surface_get_width (image);
int h = cairo_image_surface_get_height (image);
test = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, w, h );
cb = cairo_create(test);
cairo_scale (cb, brush_w/w, brush_h/h);
cairo_set_source_surface (cb, image, 0, 0);
cairo_mask_surface(cb, test, 0, 0);
cairo_paint(cb);
cairo_destroy (cb);
// cairo_set_source_rgb (ci, 0.5,0.5,0.5);
cairo_paint(ci);
cairo_set_source_surface (ci, test, mouse->x-(brush_w/2),mouse->y-(brush_h/2));
cairo_paint(ci);
*/
d_events * events;
d_events::iterator it_events;
events = d->GetEvents();
MousePosition mouse;
/* mouse->x = 100;
mouse->y = 100;
mouse->prev_x = 250;
mouse->prev_y = 100;*/
//cairo_save (ci);
//printf("size %d \n",events->size());
for(it_events = events->begin(); it_events!= events->end(); it_events++){
if(it_events->second.live ){
mouse.x = (gint) (w*(1-it_events->second.x));
mouse.y = (gint) (h*it_events->second.y);
mouse.prev_x = (gint) (w*(1-it_events->second.last[1].x));
mouse.prev_y = (gint) (h*(it_events->second.last[1].y));
mouse.bold = it_events->second.size;
// printf("mouse: %d %d %d | ", mouse.x, mouse.y, mouse.bold);
//printf("mouse: %d %d %d | ", mouse.prev_x, mouse.prev_y, mouse.bold);
//printf("mouse: %f %f | %f %f \n", it_events->second.x, it_events->second.y, it_events->second.last[1].x, it_events->second.last[1].y);
/*cairo_set_source_rgba (ci, 255,0,0, 1.);
cairo_arc (ci, mouse.x,mouse.y, 20, 0, 2 * M_PI);
cairo_fill_preserve (ci);
cairo_stroke (ci);*/
//printf("%f %f\n",mouse->f_x,mouse->f_y);
//if(!(mouse->f_x>0 && mouse->f_y > 0)) return;
//mouse->x = (int) (w-mouse->f_x*w);
//mouse->y = (int) (mouse->f_y*h);
//printf("(%d %d) %d %d < %f %f\n",w,h,mouse->x,mouse->y,mouse->f_x,mouse->f_y);
/* proložení vykreslování */
float test_t = sqrt(pow(mouse.x-mouse.prev_x,2) + pow(mouse.y-mouse.prev_y,2));
int size_brush;
//omezení pokud jsou velké skoky
if(test_t==0 || test_t > 100) break;
if(brush_type == 0 || brush_type==3){
size_brush = (mouse.bold / 2) - 5;
if(size_brush < 5) size_brush = 5;
if(size_brush > 20) size_brush = 20;
cairo_set_line_width (ci, 0.);
} else {
size_brush = mouse.bold / 10;
if(size_brush > 5) size_brush = 5;
if(size_brush < 1) size_brush = 1;
}
// printf("brush %d \n", size_brush);
int step = int (test_t/size_brush);
int rate_rand = 10;
//printf("%d %d\n",size_brush, mouse->bold);
//délka jednoho tahu
double step_x = (mouse.x - mouse.prev_x)/(double) step;
//.........这里部分代码省略.........
开发者ID:Varhoo,项目名称:Fingerpaint,代码行数:101,代码来源:main.cpp
示例6: _draw_mode_toggle
static void _draw_mode_toggle(cairo_t *cr, float x, float y, float width, float height, int type)
{
cairo_save(cr);
cairo_translate(cr, x, y);
// border
float border = MIN(width * .1, height * .1);
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.4);
cairo_rectangle(cr, border, border, width - 2.0 * border, height - 2.0 * border);
cairo_fill_preserve(cr);
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 0.5);
cairo_set_line_width(cr, border);
cairo_stroke(cr);
// icon
cairo_set_source_rgba(cr, 1.0, 1.0, 1.0, 0.5);
cairo_move_to(cr, 2.0 * border, height - 2.0 * border);
switch(type)
{
case DT_DEV_HISTOGRAM_LINEAR:
cairo_line_to(cr, width - 2.0 * border, 2.0 * border);
cairo_stroke(cr);
break;
case DT_DEV_HISTOGRAM_LOGARITHMIC:
cairo_curve_to(cr, 2.0 * border, 0.33 * height, 0.66 * width, 2.0 * border, width - 2.0 * border,
2.0 * border);
cairo_stroke(cr);
break;
case DT_DEV_HISTOGRAM_WAVEFORM:
{
cairo_pattern_t *pattern;
pattern = cairo_pattern_create_linear(0.0, 1.5 * border, 0.0, height - 3.0 * border);
cairo_pattern_add_color_stop_rgba(pattern, 0.0, 0.0, 0.0, 0.0, 0.5);
cairo_pattern_add_color_stop_rgba(pattern, 0.2, 0.2, 0.2, 0.2, 0.5);
cairo_pattern_add_color_stop_rgba(pattern, 0.5, 1.0, 1.0, 1.0, 0.5);
cairo_pattern_add_color_stop_rgba(pattern, 0.6, 1.0, 1.0, 1.0, 0.5);
cairo_pattern_add_color_stop_rgba(pattern, 1.0, 0.2, 0.2, 0.2, 0.5);
cairo_rectangle(cr, 1.5 * border, 1.5 * border, (width - 3.0 * border) * 0.3, height - 3.0 * border);
cairo_set_source(cr, pattern);
cairo_fill(cr);
cairo_save(cr);
cairo_scale(cr, 1, -1);
cairo_translate(cr, 0, -height);
cairo_rectangle(cr, 1.5 * border + (width - 3.0 * border) * 0.2, 1.5 * border,
(width - 3.0 * border) * 0.6, height - 3.0 * border);
cairo_set_source(cr, pattern);
cairo_fill(cr);
cairo_restore(cr);
cairo_rectangle(cr, 1.5 * border + (width - 3.0 * border) * 0.7, 1.5 * border,
(width - 3.0 * border) * 0.3, height - 3.0 * border);
cairo_set_source(cr, pattern);
cairo_fill(cr);
cairo_pattern_destroy(pattern);
break;
}
}
cairo_restore(cr);
}
开发者ID:WhiteSymmetry,项目名称:darktable,代码行数:63,代码来源:histogram.c
示例7: cairo_set_source_rgb
void Viewport::prepareContext(const Object* obj){
const GdkRGBA color = obj->getColor();
cairo_set_source_rgb(m_cairo, color.red, color.green, color.blue);
cairo_set_line_width(m_cairo, ((obj==m_border) ? 3 : 1) );//Pequena gambiarra...
}
开发者ID:nogenem,项目名称:Computacao-Grafica-2015-2,代码行数:5,代码来源:Viewport.hpp
示例8: clearlooks_inverted_draw_list_view_header
static void
clearlooks_inverted_draw_list_view_header (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *params,
const ListViewHeaderParameters *header,
int x, int y, int width, int height)
{
const CairoColor *fill = &colors->bg[params->state_type];
const CairoColor *border = &colors->shade[4];
cairo_pattern_t *pattern;
CairoColor hilight_header;
CairoColor hilight;
CairoColor shadow;
ge_shade_color (border, 1.5, &hilight);
ge_shade_color (fill, 1.05, &hilight_header);
ge_shade_color (fill, 0.95, &shadow);
cairo_translate (cr, x, y);
cairo_set_line_width (cr, 1.0);
/* 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);
ge_cairo_set_color (cr, &hilight);
cairo_stroke (cr);
/* Draw bottom border */
cairo_move_to (cr, 0.0, height-0.5);
cairo_line_to (cr, width, height-0.5);
ge_cairo_set_color (cr, border);
cairo_stroke (cr);
/* Draw bottom shade */
pattern = cairo_pattern_create_linear (0.0, 0, 0.0, height-1.0);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, shadow.r, shadow.g, shadow.b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, hilight_header.r, hilight_header.g, hilight_header.b);
cairo_rectangle (cr, 0, 1, width, height-2);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
/* 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:TALAPCH1,项目名称:LXDE-configuration,代码行数:66,代码来源:clearlooks_draw_inverted.c
示例9: clearlooks_inverted_draw_scrollbar_stepper
static void
clearlooks_inverted_draw_scrollbar_stepper (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ScrollBarParameters *scrollbar,
const ScrollBarStepperParameters *stepper,
int x, int y, int width, int height)
{
CairoCorners corners = CR_CORNER_NONE;
CairoColor border;
CairoColor s1, s2, s3;
cairo_pattern_t *pattern;
double radius = MIN (widget->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
ge_shade_color(&colors->shade[6], 1.05, &border);
if (scrollbar->horizontal)
{
if (stepper->stepper == CL_STEPPER_A)
corners = CR_CORNER_TOPLEFT | CR_CORNER_BOTTOMLEFT;
else if (stepper->stepper == CL_STEPPER_D)
corners = CR_CORNER_TOPRIGHT | CR_CORNER_BOTTOMRIGHT;
if (stepper->stepper == CL_STEPPER_B)
{
x -= 1;
width += 1;
}
else if (stepper->stepper == CL_STEPPER_C)
{
width += 1;
}
}
else
{
if (stepper->stepper == CL_STEPPER_A)
corners = CR_CORNER_TOPLEFT | CR_CORNER_TOPRIGHT;
else if (stepper->stepper == CL_STEPPER_D)
corners = CR_CORNER_BOTTOMLEFT | CR_CORNER_BOTTOMRIGHT;
if (stepper->stepper == CL_STEPPER_B)
{
y -= 1;
height += 1;
}
else if (stepper->stepper == CL_STEPPER_C)
{
height += 1;
}
}
cairo_translate (cr, x, y);
cairo_set_line_width (cr, 1);
ge_cairo_rounded_rectangle (cr, 1, 1, width-2, height-2, radius, corners);
if (scrollbar->horizontal)
pattern = cairo_pattern_create_linear (0, 0, 0, height);
else
pattern = cairo_pattern_create_linear (0, 0, width, 0);
s1 = colors->bg[widget->state_type];
ge_shade_color(&s1, 0.95, &s2);
ge_shade_color(&s1, 1.05, &s3);
cairo_pattern_add_color_stop_rgb(pattern, 0, s2.r, s2.g, s2.b);
cairo_pattern_add_color_stop_rgb(pattern, 1.0, s3.r, s3.g, s3.b);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
widget->style_functions->draw_top_left_highlight (cr, &s1, widget, 1, 1, width-2, height-2, radius, corners);
ge_cairo_rounded_rectangle (cr, 0.5, 0.5, width-1, height-1, radius, corners);
clearlooks_set_border_gradient (cr, &border, 1.2, (scrollbar->horizontal ? 0 : width), (scrollbar->horizontal ? height: 0));
cairo_stroke (cr);
}
开发者ID:TALAPCH1,项目名称:LXDE-configuration,代码行数:77,代码来源:clearlooks_draw_inverted.c
示例10: clearlooks_inverted_draw_button
static void
clearlooks_inverted_draw_button (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *params,
int x, int y, int width, int height)
{
double xoffset = 0, yoffset = 0;
double radius = params->radius;
const CairoColor *fill = &colors->bg[params->state_type];
const CairoColor *border_disabled = &colors->shade[4];
CairoColor border_normal;
CairoColor shadow;
ge_shade_color(&colors->shade[6], 1.05, &border_normal);
ge_shade_color (&border_normal, 0.925, &shadow);
cairo_save (cr);
cairo_translate (cr, x, y);
cairo_set_line_width (cr, 1.0);
if (params->xthickness == 3 || params->ythickness == 3)
{
if (params->xthickness == 3)
xoffset = 1;
if (params->ythickness == 3)
yoffset = 1;
}
radius = MIN (radius, MIN ((width - 2.0 - xoffset * 2.0) / 2.0, (height - 2.0 - yoffset * 2) / 2.0));
if (params->xthickness == 3 || params->ythickness == 3)
{
params->style_functions->draw_inset (cr, ¶ms->parentbg, 0, 0, width, height, radius+1, params->corners);
}
ge_cairo_rounded_rectangle (cr, xoffset+1, yoffset+1,
width-(xoffset*2)-2,
height-(yoffset*2)-2,
radius, params->corners);
if (!params->active)
{
cairo_pattern_t *pattern;
CairoColor top_shade, bottom_shade;
ge_shade_color (fill, 0.95, &top_shade);
ge_shade_color (fill, 1.05, &bottom_shade);
pattern = cairo_pattern_create_linear (0, 0, 0, height);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, top_shade.r, top_shade.g, top_shade.b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, bottom_shade.r, bottom_shade.g, bottom_shade.b);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
}
else
{
cairo_pattern_t *pattern;
ge_cairo_set_color (cr, fill);
cairo_fill_preserve (cr);
pattern = cairo_pattern_create_linear (0, 0, 0, height);
cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, 0.0);
cairo_pattern_add_color_stop_rgba (pattern, 0.4, shadow.r, shadow.g, shadow.b, 0.0);
cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.2);
cairo_set_source (cr, pattern);
cairo_fill_preserve (cr);
cairo_pattern_destroy (pattern);
pattern = cairo_pattern_create_linear (0, yoffset+1, 0, 3+yoffset);
cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.3);
cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
cairo_set_source (cr, pattern);
cairo_fill_preserve (cr);
cairo_pattern_destroy (pattern);
pattern = cairo_pattern_create_linear (xoffset+1, 0, 3+xoffset, 0);
cairo_pattern_add_color_stop_rgba (pattern, 0.0, shadow.r, shadow.g, shadow.b, params->disabled ? 0.125 : 0.3);
cairo_pattern_add_color_stop_rgba (pattern, 1.0, shadow.r, shadow.g, shadow.b, 0.0);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
}
/* Drawing the border */
if (!params->active && params->is_default)
{
const CairoColor *l = &colors->shade[4];
const CairoColor *d = &colors->shade[4];
ge_cairo_set_color (cr, l);
ge_cairo_stroke_rectangle (cr, 2.5, 2.5, width-5, height-5);
ge_cairo_set_color (cr, d);
ge_cairo_stroke_rectangle (cr, 3.5, 3.5, width-7, height-7);
}
if (params->disabled)
//.........这里部分代码省略.........
开发者ID:TALAPCH1,项目名称:LXDE-configuration,代码行数:101,代码来源:clearlooks_draw_inverted.c
示例11: clearlooks_inverted_draw_slider
static void
clearlooks_inverted_draw_slider (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *params,
int x, int y, int width, int height)
{
const CairoColor *border = &colors->shade[params->disabled ? 4 : 6];
const CairoColor *spot = &colors->spot[1];
const CairoColor *fill = &colors->shade[2];
double radius = MIN (params->radius, MIN ((width - 1.0) / 2.0, (height - 1.0) / 2.0));
cairo_pattern_t *pattern;
cairo_set_line_width (cr, 1.0);
cairo_translate (cr, x, y);
if (params->disabled)
border = &colors->shade[4];
else if (params->prelight)
border = &colors->spot[2];
else
border = &colors->shade[6];
/* fill the widget */
cairo_rectangle (cr, 1.0, 1.0, width-2, height-2);
/* Fake light */
if (!params->disabled)
{
const CairoColor *top = &colors->shade[2];
const CairoColor *bot = &colors->shade[0];
pattern = cairo_pattern_create_linear (0, 0, 0, height);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, top->r, top->g, top->b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, bot->r, bot->g, bot->b);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
}
else
{
ge_cairo_set_color (cr, fill);
cairo_rectangle (cr, 1.0, 1.0, width-2, height-2);
cairo_fill (cr);
}
/* Set the clip */
cairo_save (cr);
cairo_rectangle (cr, 1.0, 1.0, 6, height-2);
cairo_rectangle (cr, width-7.0, 1.0, 6, height-2);
cairo_clip_preserve (cr);
cairo_new_path (cr);
/* Draw the handles */
ge_cairo_rounded_rectangle (cr, 1.0, 1.0, width-1, height-1, radius, params->corners);
pattern = cairo_pattern_create_linear (0.5, 0.5, 0.5, 0.5+height);
if (params->prelight)
{
CairoColor highlight;
ge_shade_color (spot, 1.5, &highlight);
cairo_pattern_add_color_stop_rgb (pattern, 0.0, spot->r, spot->g, spot->b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, highlight.r, highlight.g, highlight.b);
cairo_set_source (cr, pattern);
}
else {
CairoColor hilight;
ge_shade_color (fill, 1.5, &hilight);
cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
}
cairo_fill (cr);
cairo_pattern_destroy (pattern);
cairo_restore (cr);
/* Draw the border */
ge_cairo_inner_rounded_rectangle (cr, 0, 0, width, height, radius, params->corners);
if (params->prelight || params->disabled)
ge_cairo_set_color (cr, border);
else
clearlooks_set_border_gradient (cr, border, 1.2, 0, height);
cairo_stroke (cr);
/* Draw handle lines */
if (width > 14)
{
cairo_move_to (cr, 6.5, 1.0);
cairo_line_to (cr, 6.5, height-1);
cairo_move_to (cr, width-6.5, 1.0);
cairo_line_to (cr, width-6.5, height-1);
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgba (cr, border->r,
border->g,
border->b,
0.3);
cairo_stroke (cr);
//.........这里部分代码省略.........
开发者ID:TALAPCH1,项目名称:LXDE-configuration,代码行数:101,代码来源:clearlooks_draw_inverted.c
示例12: clearlooks_inverted_draw_tab
static void
clearlooks_inverted_draw_tab (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *params,
const TabParameters *tab,
int x, int y, int width, int height)
{
const CairoColor *border1 = &colors->shade[6];
const CairoColor *border2 = &colors->shade[5];
const CairoColor *stripe_fill = &colors->spot[1];
const CairoColor *stripe_border = &colors->spot[2];
const CairoColor *fill;
CairoColor hilight;
CairoColor shadow;
cairo_pattern_t *pattern;
double radius;
double strip_size;
double length;
radius = MIN (params->radius, MIN ((width - 2.0) / 2.0, (height - 2.0) / 2.0));
/* Set clip */
cairo_rectangle (cr, x, y, width, height);
cairo_clip (cr);
cairo_new_path (cr);
/* Translate and set line width */
cairo_set_line_width (cr, 1.0);
cairo_translate (cr, x+0.5, y+0.5);
/* Make the tabs slightly bigger than they should be, to create a gap */
/* And calculate the strip size too, while you're at it */
if (tab->gap_side == CL_GAP_TOP || tab->gap_side == CL_GAP_BOTTOM)
{
height += 3.0;
length = height;
strip_size = 2.0/height; /* 2 pixel high strip */
if (tab->gap_side == CL_GAP_TOP)
cairo_translate (cr, 0.0, -3.0); /* gap at the other side */
}
else
{
width += 3.0;
length = width;
strip_size = 2.0/width;
if (tab->gap_side == CL_GAP_LEFT)
cairo_translate (cr, -3.0, 0.0); /* gap at the other side */
}
/* Set the fill color */
fill = &colors->bg[params->state_type];
/* Set tab shape */
ge_cairo_rounded_rectangle (cr, 0, 0, width-1, height-1,
radius, params->corners);
/* Draw fill */
ge_cairo_set_color (cr, fill);
cairo_fill (cr);
ge_shade_color (fill, 1.3, &hilight);
/* Draw highlight */
if (!params->active)
{
ShadowParameters shadow;
shadow.shadow = CL_SHADOW_OUT;
shadow.corners = params->corners;
/*
clearlooks_draw_highlight_and_shade (cr, colors, &shadow,
width,
height, radius);*/
}
if (params->active)
{
switch (tab->gap_side)
{
case CL_GAP_TOP:
pattern = cairo_pattern_create_linear (0, height-2, 0, 0);
break;
case CL_GAP_BOTTOM:
pattern = cairo_pattern_create_linear (0, 1, 0, height);
break;
case CL_GAP_LEFT:
pattern = cairo_pattern_create_linear (width-2, 0, 1, 0);
break;
case CL_GAP_RIGHT:
pattern = cairo_pattern_create_linear (1, 0, width-2, 0);
break;
default:
pattern = NULL;
}
//.........这里部分代码省略.........
开发者ID:TALAPCH1,项目名称:LXDE-configuration,代码行数:101,代码来源:clearlooks_draw_inverted.c
示例13: ppg_header_expose_event
static gboolean
ppg_header_expose_event (GtkWidget *widget,
GdkEventExpose *expose)
{
PpgHeader *header = (PpgHeader *)widget;
PpgHeaderPrivate *priv;
GtkStateType state = GTK_STATE_NORMAL;
GtkAllocation alloc;
GtkStyle *style;
GdkColor begin;
GdkColor end;
GdkColor line;
GdkColor v_begin;
GdkColor v_end;
cairo_pattern_t *p;
cairo_t *cr;
g_return_val_if_fail(PPG_IS_HEADER(header), FALSE);
priv = header->priv;
gtk_widget_get_allocation(widget, &alloc);
style = gtk_widget_get_style(widget);
begin = style->light[state];
end = style->mid[state];
line = style->dark[state];
v_begin = style->mid[state];
v_end = style->dark[state];
cr = gdk_cairo_create(expose->window);
p = cairo_pattern_create_linear(0, 0, 0, alloc.height);
cairo_pattern_add_color_stop_rgb(p, 0.0, TO_CAIRO_RGB(begin));
cairo_pattern_add_color_stop_rgb(p, 1.0, TO_CAIRO_RGB(end));
cairo_set_source(cr, p);
cairo_rectangle(cr, 0, 0, alloc.width, alloc.height);
cairo_fill(cr);
cairo_pattern_destroy(p);
if (priv->bottom_separator) {
cairo_set_source_rgb(cr, TO_CAIRO_RGB(line));
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, 0, alloc.height - 0.5);
cairo_line_to(cr, alloc.width, alloc.height - 0.5);
cairo_stroke(cr);
}
if (priv->right_separator) {
p = cairo_pattern_create_linear(0, 0, 0, alloc.height);
cairo_pattern_add_color_stop_rgb(p, 0.0, TO_CAIRO_RGB(v_begin));
cairo_pattern_add_color_stop_rgb(p, 1.0, TO_CAIRO_RGB(v_end));
cairo_set_source(cr, p);
cairo_set_line_width(cr, 1.0);
cairo_move_to(cr, alloc.width - 0.5, 0);
cairo_line_to(cr, alloc.width - 0.5, alloc.height);
cairo_stroke(cr);
cairo_pattern_destroy(p);
}
cairo_destroy(cr);
return FALSE;
}
开发者ID:jjardon,项目名称:perfkit,代码行数:64,代码来源:ppg-header.c
示例14: draw_edges
static void draw_edges (cairo_t *cr, polygon_t *p, gdouble sf, int dir)
{
int n;
if (dir < 0)
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
else
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
for (n = 0; n < p->num_edges; n++) {
const edge_t *e = &p->edges[n];
double dx, dy;
double x1, x2;
if (e->dir != dir)
continue;
dx = e->p2.x - e->p1.x;
dy = e->p2.y - e->p1.y;
x1 = e->p1.x + (e->top - e->p1.y) / dy * dx;
x2 = e->p1.x + (e->bot - e->p1.y) / dy * dx;
cairo_arc (cr, x1, e->top, 2/sf, 0, 2*M_PI);
cairo_arc (cr, x2, e->bot, 2/sf, 0, 2*M_PI);
cairo_fill (cr);
}
if (dir < 0)
cairo_set_source_rgba (cr, 0.0, 0.0, 1.0, 0.5);
else
cairo_set_source_rgba (cr, 1.0, 0.0, 0.0, 0.5);
for (n = 0; n < p->num_edges; n++) {
const edge_t *e = &p->edges[n];
if (e->dir != dir)
continue;
cairo_move_to (cr, e->p1.x, e->p1.y);
cairo_line_to (cr, e->p2.x, e->p2.y);
}
cairo_save (cr); {
cairo_identity_matrix (cr);
cairo_set_line_width (cr, 1.);
cairo_stroke (cr);
} cairo_restore (cr);
if (dir < 0)
cairo_set_source_rgb (cr, 0.0, 0.0, 1.0);
else
cairo_set_source_rgb (cr, 1.0, 0.0, 0.0);
for (n = 0; n < p->num_edges; n++) {
const edge_t *e = &p->edges[n];
double dx, dy;
double x1, x2;
if (e->dir != dir)
continue;
dx = e->p2.x - e->p1.x;
dy = e->p2.y - e->p1.y;
x1 = e->p1.x + (e->top - e->p1.y) / dy * dx;
x2 = e->p1.x + (e->bot - e->p1.y) / dy * dx;
cairo_move_to (cr, x1, e->top);
cairo_line_to (cr, x2, e->bot);
}
cairo_save (cr); {
cairo_identity_matrix (cr);
cairo_set_line_width (cr, 1.);
cairo_stroke (cr);
} cairo_restore (cr);
}
开发者ID:AZed,项目名称:cairo,代码行数:76,代码来源:show-polygon.c
示例15: cr_set_line_width
static VALUE
cr_set_line_width (VALUE self, VALUE width)
{
cairo_set_line_width (_SELF, NUM2DBL (width));
return self;
}
开发者ID:joshuawatson,项目名称:rcairo,代码行数:6,代码来源:rb_cairo_context.c
示例16: clearlooks_inverted_draw_scrollbar_slider
static void
clearlooks_inverted_draw_scrollbar_slider (cairo_t *cr,
const ClearlooksColors *colors,
const WidgetParameters *widget,
const ScrollBarParameters *scrollbar,
int x, int y, int width, int height)
{
if (scrollbar->junction & CL_JUNCTION_BEGIN)
{
if (scrollbar->horizontal)
{
x -= 1;
width += 1;
}
else
{
y -= 1;
height += 1;
}
}
if (scrollbar->junction & CL_JUNCTION_END)
{
if (scrollbar->horizontal)
width += 1;
else
height += 1;
}
if (!scrollbar->horizontal)
ge_cairo_exchange_axis (cr, &x, &y, &width, &height);
cairo_translate (cr, x, y);
if (scrollbar->has_color)
{
const CairoColor *border = &colors->shade[8];
CairoColor fill = scrollbar->color;
CairoColor hilight;
CairoColor shade1, shade2, shade3;
cairo_pattern_t *pattern;
if (widget->prelight)
ge_shade_color (&fill, 1.1, &fill);
cairo_set_line_width (cr, 1);
ge_shade_color (&fill, 1.3, &hilight);
ge_shade_color (&fill, 1.1, &shade1);
ge_shade_color (&fill, 1.05, &shade2);
ge_shade_color (&fill, 0.98, &shade3);
pattern = cairo_pattern_create_linear (1, 1, 1, height-2);
cairo_pattern_add_color_stop_rgb (pattern, 0, fill.r, fill.g, fill.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade3.r, shade3.g, shade3.b);
cairo_pattern_add_color_stop_rgb (pattern, 0.5, shade2.r, shade2.g, shade2.b);
cairo_pattern_add_color_stop_rgb (pattern, 1.0, shade1.r, shade1.g, shade1.b);
cairo_rectangle (cr, 1, 1, width-2, height-2);
cairo_set_source (cr, pattern);
cairo_fill (cr);
cairo_pattern_destroy (pattern);
cairo_set_source_rgba (cr, hilight.r, hilight.g, hilight.b, 0.5);
ge_cairo_stroke_rectangle (cr, 1.5, 1.5, width-3, height-3);
ge_cairo_set_color (cr, border);
ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
}
else
{
CairoColor border;
CairoColor s1, s2, s3;
cairo_pattern_t *pattern;
int bar_x, i;
const CairoColor *dark = &colors->shade[4];
const CairoColor *light = &colors->shade[0];
ge_shade_color(&colors->shade[6], 1.05, &border);
pattern = cairo_pattern_create_linear(1, 1, 1, height-1);
s1 = colors->bg[widget->state_type];
ge_shade_color(&s1, 0.95, &s2);
ge_shade_color(&s1, 1.05, &s3);
cairo_pattern_add_color_stop_rgb(pattern, 0, s2.r, s2.g, s2.b);
cairo_pattern_add_color_stop_rgb(pattern, 1.0, s3.r, s3.g, s3.b);
cairo_rectangle (cr, 1, 1, width-2, height-2);
cairo_set_source(cr, pattern);
cairo_fill(cr);
cairo_pattern_destroy(pattern);
widget->style_functions->draw_top_left_highlight (cr, &s2, widget, 1, 1, width-2, height-2, 0, widget->corners);
clearlooks_set_border_gradient (cr, &border, 1.2, 0, height);
ge_cairo_stroke_rectangle (cr, 0.5, 0.5, width-1, height-1);
/* draw handles */
cairo_set_line_width (cr, 1);
//.........这里部分代码省略.........
开发者ID:TALAPCH1,项目名称:LXDE-configuration,代码行数:101,代码来源:clearlooks_draw_inverted.c
示例17: cairo_set_line_width
void gfxContext::SetLineWidth(gfxFloat width)
{
cairo_set_line_width(mCairo, width);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:4,代码来源:gfxContext.cpp
示例18: _lib_histogram_draw_callback
static gboolean _lib_histogram_draw_callback(GtkWidget *widget, cairo_t *crf, gpointer user_data)
{
dt_lib_module_t *self = (dt_lib_module_t *)user_data;
dt_lib_histogram_t *d = (dt_lib_histogram_t *)self->data;
dt_develop_t *dev = darktable.develop;
uint32_t *hist = dev->histogram;
float hist_max = dev->histogram_type == DT_DEV_HISTOGR
|
请发表评论