本文整理汇总了C++中render_context::cairo方法的典型用法代码示例。如果您正苦于以下问题:C++ render_context::cairo方法的具体用法?C++ render_context::cairo怎么用?C++ render_context::cairo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类render_context
的用法示例。
在下文中一共展示了render_context::cairo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply
bool paint::apply(const element* parent, render_context& ctx) const
{
switch(color_attrib_) {
case ColorAttrib::NONE:
// Nothing to do if there is no color.
return false;
case ColorAttrib::CURRENT_COLOR: {
auto cc = ctx.get_current_color();
ASSERT_LOG(cc != NULL, "Current color specified as color source, but there is no current color value.");
cairo_set_source_rgb(ctx.cairo(), cc->r(), cc->g(), cc->b());
return true;
}
case ColorAttrib::FUNC_IRI:
ASSERT_LOG(false, "XXX: todo: lookup FUNC_IRI to get color value");
return true;
case ColorAttrib::ICC_COLOR:
ASSERT_LOG(false, "XXX: todo: ICC_COLOR to get color value");
return true;
case ColorAttrib::INHERIT:
// XXX: Nothing to do?
return true;
case ColorAttrib::VALUE:
double opacity = ctx.opacity_top();
cairo_set_source_rgba(ctx.cairo(), color_value_.r(), color_value_.g(), color_value_.b(), opacity);
return true;
}
return false;
}
示例2: handle_apply
void handle_apply(render_context& ctx) override {
if(std::abs(cx_) < DBL_EPSILON && std::abs(cy_) < DBL_EPSILON) {
cairo_rotate(ctx.cairo(), angle_);
} else {
cairo_translate(ctx.cairo(), cx_, cy_);
cairo_rotate(ctx.cairo(), angle_);
cairo_translate(ctx.cairo(), -cx_, -cy_);
}
}
示例3: handle_set_source
void linear_gradient::handle_set_source(render_context& ctx) const
{
cairo_pattern_t* pattern = cairo_pattern_create_linear(
x1_.value_in_specified_units(svg_length::SVG_LENGTHTYPE_NUMBER),
y1_.value_in_specified_units(svg_length::SVG_LENGTHTYPE_NUMBER),
x2_.value_in_specified_units(svg_length::SVG_LENGTHTYPE_NUMBER),
y2_.value_in_specified_units(svg_length::SVG_LENGTHTYPE_NUMBER));
apply_stops(ctx, pattern);
auto status = cairo_pattern_status(pattern);
ASSERT_LOG(status == CAIRO_STATUS_SUCCESS, "Linear Gradient pattern couldn't be created: " << cairo_status_to_string(status));
pattern_.reset(pattern, [](cairo_pattern_t* p) { cairo_pattern_destroy(p); });
apply_transforms(pattern);
cairo_set_source(ctx.cairo(), pattern);
}
示例4: render
void parse::render(render_context& ctx) const
{
cairo_set_source_rgb(ctx.cairo(), 0.0, 0.0, 0.0);
cairo_set_line_cap(ctx.cairo(), CAIRO_LINE_CAP_BUTT);
cairo_set_line_join(ctx.cairo(), CAIRO_LINE_JOIN_MITER);
cairo_set_miter_limit(ctx.cairo(), 4.0);
cairo_set_fill_rule(ctx.cairo(), CAIRO_FILL_RULE_WINDING);
cairo_set_line_width(ctx.cairo(), 1.0);
ctx.fill_color_push(paint_ptr(new paint(0,0,0,255)));
ctx.stroke_color_push(paint_ptr(new paint()));
ctx.opacity_push(1.0);
ctx.letter_spacing_push(0);
ctx.fa().push_font_size(12);
for(auto p : svg_data_) {
p->render(ctx);
}
ctx.letter_spacing_pop();
ctx.opacity_pop();
ctx.stroke_color_pop();
ctx.fill_color_pop();
}