本文整理汇总了C++中cairo_arc_negative函数的典型用法代码示例。如果您正苦于以下问题:C++ cairo_arc_negative函数的具体用法?C++ cairo_arc_negative怎么用?C++ cairo_arc_negative使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cairo_arc_negative函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: render
void render() {
draw_fill(ctx, rgba(0,0,0,127));
int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, window->width);
cairo_surface_t * surface = cairo_image_surface_create_for_data(ctx->buffer, CAIRO_FORMAT_ARGB32, window->width, window->height, stride);
cairo_t * cr = cairo_create(surface);
cairo_set_line_width (cr, 6);
cairo_rectangle (cr, 12, 12, 232, 70);
cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI);
cairo_new_sub_path (cr); cairo_arc_negative (cr, 192, 64, 40, 0, -2*M_PI);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_set_source_rgb (cr, 0, 0.7, 0); cairo_fill_preserve (cr);
cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr);
cairo_translate (cr, 0, 128);
cairo_rectangle (cr, 12, 12, 232, 70);
cairo_new_sub_path (cr); cairo_arc (cr, 64, 64, 40, 0, 2*M_PI);
cairo_new_sub_path (cr); cairo_arc_negative (cr, 192, 64, 40, 0, -2*M_PI);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_WINDING);
cairo_set_source_rgb (cr, 0, 0, 0.9); cairo_fill_preserve (cr);
cairo_set_source_rgb (cr, 0, 0, 0); cairo_stroke (cr);
cairo_surface_flush(surface);
cairo_destroy(cr);
cairo_surface_flush(surface);
cairo_surface_destroy(surface);
}
开发者ID:Atomication,项目名称:toaruos,代码行数:31,代码来源:cairo-demo.c
示例2: platformPath
void Path::addArc(const FloatPoint& p, float r, float startAngle, float endAngle, bool anticlockwise)
{
// http://bugs.webkit.org/show_bug.cgi?id=16449
// cairo_arc() functions hang or crash when passed inf as radius or start/end angle
if (!isfinite(r) || !isfinite(startAngle) || !isfinite(endAngle))
return;
cairo_t* cr = platformPath()->context();
float sweep = endAngle - startAngle;
const float twoPI = 2 * piFloat;
if ((sweep <= -twoPI || sweep >= twoPI)
&& ((anticlockwise && (endAngle < startAngle)) || (!anticlockwise && (startAngle < endAngle)))) {
if (anticlockwise)
cairo_arc_negative(cr, p.x(), p.y(), r, startAngle, startAngle - twoPI);
else
cairo_arc(cr, p.x(), p.y(), r, startAngle, startAngle + twoPI);
cairo_new_sub_path(cr);
cairo_arc(cr, p.x(), p.y(), r, endAngle, endAngle);
} else {
if (anticlockwise)
cairo_arc_negative(cr, p.x(), p.y(), r, startAngle, endAngle);
else
cairo_arc(cr, p.x(), p.y(), r, startAngle, endAngle);
}
}
开发者ID:bearmingo,项目名称:UI,代码行数:25,代码来源:PathCairo.cpp
示例3: nand_gate_glyph
void nand_gate_glyph(cairo_t *cr) {
static cairo_pattern_t *pat = 0;
cairo_save(cr);
cairo_scale(cr,0.68,0.8);
if(pat == 0) {
pat = cairo_pattern_create_radial (0.27, 0.3, 0.08, 0.2, 0.35, 0.6);
cairo_pattern_add_color_stop_rgb (pat, 0, 0.9, 0.9, 0.9);
cairo_pattern_add_color_stop_rgb (pat, 1, 1.0, 1.0, 0.8);
}
cairo_new_path(cr);
cairo_move_to(cr,0.0,0.0);
cairo_line_to(cr,0.0,1.0);
cairo_line_to(cr,0.5,1.0);
cairo_arc_negative(cr,0.5,0.5,0.5,M_PI/2.0,0);
cairo_arc(cr,1.1,0.5,0.1,M_PI,0);
cairo_arc(cr,1.1,0.5,0.1,0,M_PI);
cairo_arc_negative(cr,0.5,0.5,0.5,0,-M_PI/2.0);
cairo_close_path(cr);
cairo_set_source (cr, pat);
cairo_fill_preserve (cr);
cairo_set_source_rgb(cr,0.0,0.0,0.0);
cairo_set_line_width(cr,0.07);
cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND);
cairo_stroke(cr);
cairo_restore(cr);
}
开发者ID:petersn,项目名称:rala_util,代码行数:34,代码来源:rala_glyphs.c
示例4: or_gate_glyph
void or_gate_glyph(cairo_t *cr) {
static cairo_pattern_t *pat = 0;
cairo_save(cr);
cairo_scale(cr,0.8,0.8);
if(pat == 0) {
pat = cairo_pattern_create_radial (0.35, 0.3, 0.08, 0.2, 0.35, 0.6);
cairo_pattern_add_color_stop_rgb (pat, 0, 0.9, 0.9, 0.9);
cairo_pattern_add_color_stop_rgb (pat, 1, 0.68, 1.0, 0.68);
}
cairo_new_path(cr);
cairo_move_to(cr,0,0);
cairo_arc(cr,-0.5,0.5,sqrt(2.0)/2,-M_PI/4,M_PI/4);
cairo_line_to(cr,0.5,1.0);
cairo_save(cr);
cairo_scale(cr,0.9,2.0);
double angle = asin(3.0/4);
cairo_arc_negative(cr,0.5,-0.5,1.0,M_PI/2,angle);
cairo_arc_negative(cr,0.5,1.0,1.0,-angle,-M_PI/2);
cairo_restore(cr);
cairo_close_path(cr);
cairo_set_source (cr, pat);
cairo_fill_preserve (cr);
cairo_set_source_rgb(cr,0.0,0.0,0.0);
cairo_set_line_width(cr,0.07);
cairo_set_line_join(cr,CAIRO_LINE_JOIN_ROUND);
cairo_stroke(cr);
cairo_restore(cr);
}
开发者ID:petersn,项目名称:rala_util,代码行数:35,代码来源:rala_glyphs.c
示例5: aosd_deco_rfunc_concaverect
static void
aosd_deco_rfunc_concaverect ( Ghosd * osd , cairo_t * cr , aosd_deco_style_data_t * data )
{
/* decoration information
----------------------
draws a rectangle with concave angles; uses 2 colors
(user color 1 and 2) and 1 font (user font 1), with optional shadow
*/
PangoLayout *osd_layout = data->layout;
aosd_color_t color0 = g_array_index( data->decoration->colors , aosd_color_t , 0 );
aosd_color_t color1 = g_array_index( data->decoration->colors , aosd_color_t , 1 );
aosd_color_t textcolor0 = data->text->fonts_color[0];
aosd_color_t shadowcolor0 = data->text->fonts_shadow_color[0];
gboolean draw_shadow = data->text->fonts_draw_shadow[0];
gint width = 0, height = 0, bearing = 0;
aosd_layout_size( osd_layout , &width , &height , &bearing );
/* draw jigsaw-piece-like container */
cairo_set_source_rgba( cr , (gdouble)color0.red / 65535 , (gdouble)color0.green / 65535 ,
(gdouble)color0.blue / 65535 , (gdouble)color0.alpha / 65535 );
cairo_move_to( cr , aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left , 0 );
cairo_arc_negative( cr , width + aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left + 2 ,
aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.top - 2 ,
8. , -G_PI_2 , 0. );
cairo_arc_negative( cr , width + aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left + 2 ,
aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.top + height + 2 ,
8. , -4. * G_PI_2 , -3. * G_PI_2 );
cairo_arc_negative( cr , aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left - 2 ,
aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.top + height + 2 ,
8. , -3. * G_PI_2 , -2. * G_PI_2 );
cairo_arc_negative( cr , aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left - 2 ,
aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.top - 2 ,
8. , -2. * G_PI_2 , -G_PI_2 );
cairo_close_path( cr );
cairo_fill_preserve( cr );
cairo_set_source_rgba( cr , (gdouble)color1.red / 65535 , (gdouble)color1.green / 65535 ,
(gdouble)color1.blue / 65535 , (gdouble)color1.alpha / 65535 );
cairo_stroke( cr );
if ( draw_shadow == TRUE )
{
/* draw text shadow */
cairo_set_source_rgba( cr , (gdouble)shadowcolor0.red / 65535 , (gdouble)shadowcolor0.green / 65535 ,
(gdouble)shadowcolor0.blue / 65535 , (gdouble)shadowcolor0.alpha / 65535 );
cairo_move_to( cr ,
aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left + bearing + 2 ,
aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.top + 2 );
pango_cairo_show_layout( cr , osd_layout );
}
/* draw text */
cairo_set_source_rgba( cr , (gdouble)textcolor0.red / 65535 , (gdouble)textcolor0.green / 65535 ,
(gdouble)textcolor0.blue / 65535 , (gdouble)textcolor0.alpha / 65535 );
cairo_move_to( cr ,
aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.left + bearing ,
aosd_deco_styles[AOSD_DECO_STYLE_CONCAVERECT].padding.top );
pango_cairo_show_layout( cr , osd_layout );
}
开发者ID:Falcon-peregrinus,项目名称:mlplayer,代码行数:59,代码来源:aosd_style.c
示例6: shot_animation
void shot_animation(cairo_t* cr, double size, double direction,
struct cannon* can)
{
UNUSED(size);
UNUSED(direction);
/* Reduce the reload time by half of it so it draws the explosion and
* the flash for half the reload time.
*/
int time = can->timeToReload - RELOAD_RATIO / 2;
if (time <= 0) {
return; /* if the gun is loaded don't paint anything */
}
cairo_save(cr);
cairo_pattern_t* pat;
cairo_translate(cr, can->x, can->y);
#if 0
/* flash of the shot, should be translate to the robot's position. */
cairo_scale(cr, size, size);
cairo_rotate(cr, direction);
pat = cairo_pattern_create_linear(128, 64,
128, 128.0);
cairo_pattern_add_color_stop_rgba(pat, 0, 1, 0, 0, time /
(RELOAD_RATIO / 2.0));
cairo_pattern_add_color_stop_rgba(pat, 1, 1, 1, 0, time /
(RELOAD_RATIO / 2.0));
cairo_set_source(cr, pat);
cairo_move_to(cr, 32, 50);
cairo_arc_negative(cr, 32, 32, 18, 90 * (M_PI / 180.0), 0);
cairo_arc_negative(cr, 68, 32, 18, M_PI, 90 * (M_PI / 180.0));
cairo_arc_negative(cr, 50, 50, 18, M_PI, 0);
cairo_fill(cr);
cairo_pattern_destroy(pat);
#endif
/* explosion */
cairo_arc(cr, 0, 0, 40, 0, 2 * M_PI);
pat = cairo_pattern_create_radial(0, 0, 10, 0, 0, 40);
cairo_pattern_add_color_stop_rgba(pat, 0, 1, 0, 0, time /
(RELOAD_RATIO / 2.0));
cairo_pattern_add_color_stop_rgba(pat, 0.3, 1, 0.5, 0, time /
(RELOAD_RATIO / 2.0));
cairo_pattern_add_color_stop_rgba(pat, 0.6, 1, 0.2, 0, time /
(RELOAD_RATIO / 2.0));
cairo_set_source(cr, pat);
cairo_fill(cr);
cairo_pattern_destroy(pat);
cairo_restore(cr);
}
开发者ID:marco-m,项目名称:netrobots,代码行数:55,代码来源:field.c
示例7: buttonDoButtonPathImpl
void buttonDoButtonPathImpl(button *self, cairo_t *cr)
{
size ourSize = WIDGET(self)->size;
// Do the rounded rectangle
cairo_arc_negative(cr, borderRadius, borderRadius, borderRadius, -M_PI_2, -M_PI);
cairo_line_to(cr, 0, ourSize.y-borderRadius);
cairo_arc_negative(cr, borderRadius, ourSize.y-borderRadius, borderRadius, M_PI, M_PI_2);
cairo_line_to(cr, ourSize.x-borderRadius, ourSize.y);
cairo_arc_negative(cr, ourSize.x-borderRadius, ourSize.y-borderRadius, borderRadius, M_PI_2, 0);
cairo_line_to(cr, ourSize.x, borderRadius);
cairo_arc_negative(cr, ourSize.x-borderRadius, borderRadius, borderRadius, 0, -M_PI_2);
cairo_close_path(cr);
}
开发者ID:BG1,项目名称:warzone2100,代码行数:14,代码来源:button.cpp
示例8: fill_arc
static void
fill_arc(DiaRenderer *self,
Point *center,
real width, real height,
real angle1, real angle2,
Color *color)
{
DiaCairoRenderer *renderer = DIA_CAIRO_RENDERER (self);
Point start;
double a1, a2;
DIAG_NOTE(g_message("draw_arc %fx%f <%f,<%f",
width, height, angle1, angle2));
cairo_set_source_rgba (renderer->cr, color->red, color->green, color->blue, 1.0);
cairo_new_path (renderer->cr);
start.x = center->x + (width / 2.0) * cos((M_PI / 180.0) * angle1);
start.y = center->y - (height / 2.0) * sin((M_PI / 180.0) * angle1);
cairo_move_to (renderer->cr, center->x, center->y);
cairo_line_to (renderer->cr, start.x, start.y);
a1 = - (angle1 / 180.0) * G_PI;
a2 = - (angle2 / 180.0) * G_PI;
/* FIXME: to handle width != height some cairo_scale/cairo_translate would be needed */
cairo_arc_negative (renderer->cr, center->x, center->y,
width > height ? height / 2.0 : width / 2.0, /* FIXME 2nd radius */
a1, a2);
cairo_line_to (renderer->cr, center->x, center->y);
cairo_close_path (renderer->cr);
cairo_fill (renderer->cr);
DIAG_STATE(renderer->cr)
}
开发者ID:rennhak,项目名称:Dia,代码行数:32,代码来源:diacairo-renderer.c
示例9: cairo_arc
void RadialPlot::DrawItem(cairo_t* cr, RadialPlotTreeItem const &item, wxPoint c, int diameter)
{
double ro = ((double)diameter) * (item.level +1) / (2*(maxLevel + 1));
double ri = ((double)diameter) * (item.level+.1) / (2*(maxLevel + 1));
double sa = item.startAngle;
double ea = item.endAngle;
double da = .01;
sa += da;
ea -= da;
if (ea < sa)
ea = sa = (sa+ea) / 2;
sa -= M_PI/2;
ea -=M_PI/2;
cairo_arc(cr, c.x, c.y, ro, sa, ea);
cairo_arc_negative(cr, c.x, c.y, ri, ea, sa);
cairo_close_path(cr);
cairo_set_source_rgb(cr, item.color.Red()/255.0, item.color.Green()/255.0, item.color.Blue()/255.0);
cairo_fill_preserve(cr);
cairo_set_source_rgb(cr, 0, 0, 0);
cairo_set_line_width(cr, 1);
cairo_stroke(cr);
}
开发者ID:wziard,项目名称:massifplot,代码行数:33,代码来源:radialplot.cpp
示例10: cairo_save
// FIXME: This function needs to be adjusted to match the functionality on the Mac side.
void GraphicsContext::strokeArc(const IntRect& rect, int startAngle, int angleSpan)
{
if (paintingDisabled())
return;
if (strokeStyle() == NoStroke)
return;
int x = rect.x();
int y = rect.y();
float w = rect.width();
#if 0 // FIXME: unused so far
float h = rect.height();
float scaleFactor = h / w;
float reverseScaleFactor = w / h;
#endif
float r = w / 2;
float fa = startAngle;
float falen = fa + angleSpan;
cairo_t* cr = m_data->cr;
cairo_save(cr);
cairo_arc_negative(cr, x + r, y + r, r, -fa * M_PI/180, -falen * M_PI/180);
setColor(cr, strokeColor());
cairo_set_line_width(cr, strokeThickness());
cairo_stroke(cr);
cairo_restore(cr);
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:29,代码来源:GraphicsContextCairo.cpp
示例11: br_cairo_draw_section
static void br_cairo_draw_section(duc_graph *g, double a1, double a2, double r1, double r2, double H, double S, double V, double line)
{
struct cairo_backend_data *bd = g->backend_data;
cairo_t *cr = bd->cr;
double R, G, B;
hsv2rgb(H, S, V, &R, &G, &B);
cairo_new_path(cr);
cairo_arc(cr, g->cx, g->cy, r1, ang(a1), ang(a2));
cairo_arc_negative(cr, g->cx, g->cy, r2, ang(a2), ang(a1));
cairo_close_path(cr);
if(R != 1.0 || G != 1.0 || B != 1.0) {
cairo_pattern_t *pat;
pat = cairo_pattern_create_radial(g->cx, g->cy, 0, g->cx, g->cy, g->cx-50);
double off1 = r2 / g->cx;
double off2 = r1 / g->cx;
cairo_pattern_add_color_stop_rgb(pat, off1, R, G, B);
cairo_pattern_add_color_stop_rgb(pat, off2, R * 0.6, G * 0.6, B * 0.6);
cairo_set_source(cr, pat);
cairo_fill_preserve(cr);
cairo_pattern_destroy(pat);
}
if(line) {
cairo_set_line_width(cr, 0.5);
cairo_set_source_rgba(cr, 0, 0, 0, 0.9);
cairo_stroke(cr);
}
}
开发者ID:NethServer,项目名称:duc,代码行数:32,代码来源:graph-cairo.c
示例12: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
/* We draw in the default black, so paint white first. */
cairo_save (cr);
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); /* white */
cairo_paint (cr);
cairo_restore (cr);
/* subpath starts with cairo_move_to */
cairo_new_sub_path (cr);
cairo_move_to (cr, SIZE, SIZE);
cairo_rel_line_to (cr, SIZE, 0);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, 0.5 * SIZE, SIZE);
/* subpath starts with cairo_line_to */
cairo_new_sub_path (cr);
cairo_line_to (cr, SIZE, 3 * SIZE);
cairo_rel_line_to (cr, SIZE, 0);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, 0, SIZE);
/* subpath starts with cairo_curve_to */
cairo_new_sub_path (cr);
cairo_curve_to (cr,
SIZE, 5 * SIZE,
1.5 * SIZE, 6 * SIZE,
2 * SIZE, 5 * SIZE);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, -0.5 * SIZE, SIZE);
/* subpath starts with cairo_arc */
cairo_new_sub_path (cr);
cairo_arc (cr,
1.5 * SIZE, 7 * SIZE,
0.5 * SIZE,
M_PI, 2 * M_PI);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, -0.7 * SIZE, 0.7 * SIZE);
/* subpath starts with cairo_arc_negative */
cairo_new_sub_path (cr);
cairo_arc_negative (cr,
1.5 * SIZE, 9 * SIZE,
0.5 * SIZE,
M_PI, 2 * M_PI);
cairo_rel_line_to (cr, 0, SIZE);
cairo_close_path (cr);
cairo_rel_line_to (cr, -0.8 * SIZE, 0.3 * SIZE);
cairo_stroke (cr);
return CAIRO_TEST_SUCCESS;
}
开发者ID:AZed,项目名称:cairo,代码行数:59,代码来源:close-path-current-point.c
示例13: cr_arc_negative
static int
cr_arc_negative (lua_State *L) {
cairo_t **obj = luaL_checkudata(L, 1, OOCAIRO_MT_NAME_CONTEXT);
cairo_arc_negative(*obj, luaL_checknumber(L, 2), luaL_checknumber(L, 3),
luaL_checknumber(L, 4), luaL_checknumber(L, 5),
luaL_checknumber(L, 6));
return 0;
}
开发者ID:awesomeWM,项目名称:oocairo,代码行数:8,代码来源:obj_context.c
示例14: draw_1
static gboolean
draw_1 (ClutterCanvas *canvas,
cairo_t *cr,
int width_raw,
int height_raw)
{
/* rounded rectangle taken from:
*
* http://cairographics.org/samples/rounded_rectangle/
*
* we leave 1 pixel around the edges to avoid jagged edges
* when rotating the actor
*/
double x = 1.0, /* parameters like cairo_rectangle */
y = 1.0,
width = width_raw - 2.0,
height = height_raw - 2.0,
corner_radius = 5.0,
tab_radius = 20.0;
double radius = corner_radius ;
double degrees = M_PI / 180.0;
cairo_save (cr);
cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
cairo_paint (cr);
cairo_restore (cr);
cairo_new_sub_path (cr);
cairo_arc (cr, x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
cairo_arc (cr, x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
/*bottom-left*/cairo_arc (cr, x + radius + 30, y + height - radius, radius, 90 * degrees, 180 * degrees);
cairo_arc_negative (cr, x + 30 - tab_radius, 225, tab_radius, 0 * degrees, -45 * degrees);
cairo_arc (cr, x + tab_radius, 255 - 75, tab_radius, 135 * degrees, 180 * degrees);
cairo_arc (cr, x + tab_radius, 255 - 75 - 85, tab_radius, 180 * degrees, 225 * degrees);
cairo_arc_negative (cr, x + 30 - tab_radius, 255 - 75 - 85 - 45, tab_radius, 45 * degrees, 0 * degrees);
/*top-left*/cairo_arc (cr, x + radius + 30, y + radius, radius, 180 * degrees, 270 * degrees);
cairo_close_path (cr);
cairo_set_source_rgba (cr, 0.14*.2, 0.14, 0.36*.5, 0.5);
cairo_fill_preserve (cr);
/* we're done drawing */
return TRUE;
}
开发者ID:jsdir,项目名称:_,代码行数:45,代码来源:ipLocationWidget.old.c
示例15: cr_arc_negative
static VALUE
cr_arc_negative (VALUE self, VALUE xc, VALUE yc, VALUE radius,
VALUE angle1, VALUE angle2)
{
cairo_arc_negative (_SELF, NUM2DBL (xc), NUM2DBL (yc), NUM2DBL (radius),
NUM2DBL (angle1), NUM2DBL (angle2));
cr_check_status (_SELF);
return self;
}
开发者ID:exvayn,项目名称:cairo-1.8.1-i386,代码行数:9,代码来源:rb_cairo_context.c
示例16: platformContext
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 = platformContext()->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);
int patternWidth = 0;
switch (strokeStyle()) {
case DottedStroke:
patternWidth = floorf(strokeThickness() / 2.f);
break;
case DashedStroke:
patternWidth = 3 * floorf(strokeThickness() / 2.f);
break;
default:
break;
}
setSourceRGBAFromColor(cr, strokeColor());
if (patternWidth) {
float distance = 0;
if (hRadius == vRadius)
distance = (piFloat * hRadius) / 2.f;
else // We are elliptical and will have to estimate the distance
distance = (piFloat * sqrtf((hRadius * hRadius + vRadius * vRadius) / 2.f)) / 2.f;
double patternOffset = calculateStrokePatternOffset(floorf(distance), patternWidth);
double patternWidthAsDouble = patternWidth;
cairo_set_dash(cr, &patternWidthAsDouble, 1, patternOffset);
}
cairo_stroke(cr);
cairo_restore(cr);
}
开发者ID:sysrqb,项目名称:chromium-src,代码行数:56,代码来源:GraphicsContextCairo.cpp
示例17: cairox_paint_curved_arrow
void cairox_paint_curved_arrow(cairo_t *cr, ArrowHeadType head, CairoxPoint *coordinates, int points, double width, double zoom)
{
int i = 0;
cairo_set_line_width(cr, width * zoom);
cairo_move_to(cr, zoom * coordinates[i].x, zoom * coordinates[i].y);
if (points <= 2) {
/* Not enough line segments for true curves: */
cairox_paint_final_arrow_segment(cr, head, &coordinates[1], width, zoom);
}
else {
while (++i < points-1) {
double w1 = line_length(&coordinates[i-1], &coordinates[i]);
double w2 = line_length(&coordinates[i+1], &coordinates[i]);
double dw = MIN(w1, w2) / 2.0;
CairoxPoint point_a;
// CairoxPoint point_b;
CairoxPoint centre;
double slope_a, slope_b, radius;
double angle1, angle2;
/* Where does the arc start: */
point_a.x = coordinates[i-1].x + (coordinates[i].x-coordinates[i-1].x)*(w1-dw)/w1;
point_a.y = coordinates[i-1].y + (coordinates[i].y-coordinates[i-1].y)*(w1-dw)/w1;
/* Where does the arc end: */
// point_b.x = coordinates[i+1].x + (coordinates[i].x-coordinates[i+1].x)*(w2-dw)/w2;
// point_b.y = coordinates[i+1].y + (coordinates[i].y-coordinates[i+1].y)*(w2-dw)/w2;
slope_a = line_calculate_slope(&coordinates[i-1], &coordinates[i]);
slope_b = line_calculate_slope(&coordinates[i+1], &coordinates[i]);
radius = dw * tan((slope_b-slope_a)/2.0);
/* arc is of size radius and goes from point_a to point_b */
centre.x = point_a.x - radius * sin(slope_a);
centre.y = point_a.y + radius * cos(slope_a);
/* Draw a line segment in the appropriate direction: */
cairo_line_to(cr, point_a.x, point_a.y);
/* Now draw the arc: */
if (radius < 0) {
angle1 = slope_a + M_PI / 2.0;
angle2 = slope_b - M_PI / 2.0;
cairo_arc(cr, centre.x, centre.y, -radius, angle1, angle2);
}
else {
angle1 = slope_a - M_PI / 2.0;
angle2 = slope_b + M_PI / 2.0;
cairo_arc_negative(cr, centre.x, centre.y, radius, angle1, angle2);
}
}
cairox_paint_final_arrow_segment(cr, head, &coordinates[i-1], width, zoom);
}
}
开发者ID:nicksexton,项目名称:gui-tools,代码行数:56,代码来源:lib_cairox.c
示例18: draw
static cairo_test_status_t
draw (cairo_t *cr, int width, int height)
{
const cairo_test_context_t *ctx = cairo_test_get_context (cr);
cairo_surface_t *image;
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_paint (cr);
image = cairo_test_create_surface_from_png (ctx, png_filename);
cairo_set_source_surface (cr, image, 0, 0);
/* simple clip */
cairo_save (cr);
cairo_rectangle (cr, 2, 2, 16, 16);
cairo_clip (cr);
cairo_paint (cr);
cairo_restore (cr);
cairo_translate (cr, WIDTH, 0);
/* unaligned clip */
cairo_save (cr);
cairo_rectangle (cr, 2.5, 2.5, 15, 15);
cairo_clip (cr);
cairo_paint (cr);
cairo_restore (cr);
cairo_translate (cr, -WIDTH, HEIGHT);
/* aligned-clip */
cairo_save (cr);
cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD);
cairo_rectangle (cr, 0, 0, 20, 20);
cairo_rectangle (cr, 3, 3, 10, 10);
cairo_rectangle (cr, 7, 7, 10, 10);
cairo_clip (cr);
cairo_paint (cr);
cairo_restore (cr);
cairo_translate (cr, WIDTH, 0);
/* force a clip-mask */
cairo_save (cr);
cairo_arc (cr, 10, 10, 10, 0, 2 * M_PI);
cairo_new_sub_path (cr);
cairo_arc_negative (cr, 10, 10, 5, 2 * M_PI, 0);
cairo_new_sub_path (cr);
cairo_arc (cr, 10, 10, 2, 0, 2 * M_PI);
cairo_clip (cr);
cairo_paint (cr);
cairo_restore (cr);
return CAIRO_TEST_SUCCESS;
}
开发者ID:jaglass,项目名称:WinCairoRequirements,代码行数:55,代码来源:clip-image.c
示例19: l_cairo_arc_negative
// cairo_public void
// cairo_arc_negative (cairo_t *cr,
// double xc, double yc,
// double radius,
// double angle1, double angle2);
static int l_cairo_arc_negative(lua_State* L)
{
cairo_t *cr = get_cairo_t (L, 1);
double xc = luaL_checknumber(L, 2);
double yc = luaL_checknumber(L, 3);
double radius = luaL_checknumber(L, 4);
double angle1 = luaL_checknumber(L, 5);
double angle2 = luaL_checknumber(L, 6);
cairo_arc_negative(cr, xc, yc, radius, angle1, angle2);
return 0;
}
开发者ID:umibps,项目名称:KABURAGI,代码行数:16,代码来源:lcairo-path.c
示例20: draw_pie
static void
draw_pie(GtkWidget *pie, WindowData *windata, cairo_t *cr)
{
gdouble arc_angle = 1.0 - (gdouble)windata->remaining / (gdouble)windata->timeout;
cairo_set_source_rgba (cr, 1.0, 0.4, 0.0, 0.3);
cairo_move_to(cr, PIE_RADIUS, PIE_RADIUS);
cairo_arc_negative(cr, PIE_RADIUS, PIE_RADIUS, PIE_RADIUS,
-M_PI/2, (-0.25 + arc_angle)*2*M_PI);
cairo_line_to(cr, PIE_RADIUS, PIE_RADIUS);
cairo_fill (cr);
}
开发者ID:VictorCabello,项目名称:mate-notification-daemon,代码行数:12,代码来源:nodoka-theme.c
注:本文中的cairo_arc_negative函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论