我尝试在iOS上使用cairo绘图。我找到了一个非常简单的示例如何draw rounded rectangle here。
但是当我使用此代码绘制白色路径时:
int r = 255;
int g = 255;
int b = 255;
double
lineWidth = 6.0,
degrees = M_PI / 180.0,
r = (double)color.r / 255.0,
g = (double)color.g / 255.0,
b = (double)color.b / 255.0;
/* start drawing from half of line width*/
x += lineWidth / 2.0;
y += lineWidth / 2.0;
width -= lineWidth;
height -= lineWidth;
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 );
cairo_arc( cr, x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees );
cairo_arc( cr, x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
cairo_close_path( cr );
cairo_set_fill_rule( cr, CAIRO_FILL_RULE_WINDING );
cairo_set_source_rgb( cr, r, g, b );
cairo_fill_preserve( cr );
cairo_set_source_rgb( cr, r, g, b );
cairo_set_line_width( cr, lineWidth );
cairo_stroke( cr );
像素应该是白色的,但是在角落里它们不是,我做错了什么?