示例#1
0
/**
 * Rasterize the clipping path.
 * This method submits drawing operations required to draw a basic filled shape
 * of the item to the supplied drawing context. Rendering is limited to the
 * given area. The rendering of the clipped object is composited into
 * the result of this call using the IN operator. See the implementation
 * of render() for details.
 */
void
DrawingItem::clip(Inkscape::DrawingContext &dc, Geom::IntRect const &area)
{
    // don't bother if the object does not implement clipping (e.g. DrawingImage)
    if (!_canClip()) return;
    if (!_visible) return;
    if (!area.intersects(_bbox)) return;

    dc.setSource(0,0,0,1);
    dc.pushGroup();
    // rasterize the clipping path
    _clipItem(dc, area);
    if (_clip) {
        // The item used as the clipping path itself has a clipping path.
        // Render this item's clipping path onto a temporary surface, then composite it
        // with the item using the IN operator
        dc.pushGroup();
        _clip->clip(dc, area);
        dc.popGroupToSource();
        dc.setOperator(CAIRO_OPERATOR_IN);
        dc.paint();
    }
    dc.popGroupToSource();
    dc.setOperator(CAIRO_OPERATOR_OVER);
    dc.paint();
    dc.setSource(0,0,0,0);
}
示例#2
0
void NRStyle::applyTextDecorationStroke(Inkscape::DrawingContext &dc)
{
    dc.setSource(text_decoration_stroke_pattern);
    dc.setLineWidth(text_decoration_stroke_width);
    dc.setLineCap(CAIRO_LINE_CAP_BUTT);
    dc.setLineJoin(CAIRO_LINE_JOIN_MITER);
    dc.setMiterLimit(miter_limit);
    cairo_set_dash(dc.raw(), 0, 0, 0.0); // fixme (no dash)
}
示例#3
0
void NRStyle::applyStroke(Inkscape::DrawingContext &dc)
{
    dc.setSource(stroke_pattern);
    dc.setLineWidth(stroke_width);
    dc.setLineCap(line_cap);
    dc.setLineJoin(line_join);
    dc.setMiterLimit(miter_limit);
    cairo_set_dash(dc.raw(), dash, n_dash, dash_offset); // fixme
}
示例#4
0
bool NRStyle::prepareTextDecorationStroke(Inkscape::DrawingContext &dc, Geom::OptRect const &paintbox)
{
    if (!text_decoration_stroke_pattern) {
        switch (text_decoration_stroke.type) {
        case PAINT_SERVER: {
        	text_decoration_stroke_pattern = text_decoration_stroke.server->pattern_new(dc.raw(), paintbox, text_decoration_stroke.opacity);
		} break;
        case PAINT_COLOR: {
            SPColor const &c = text_decoration_stroke.color;
            text_decoration_stroke_pattern = cairo_pattern_create_rgba(
                c.v.c[0], c.v.c[1], c.v.c[2], text_decoration_stroke.opacity);
            } break;
        default: break;
        }
    }
    if (!text_decoration_stroke_pattern) return false;
    return true;
}
示例#5
0
bool NRStyle::prepareStroke(Inkscape::DrawingContext &ct, Geom::OptRect const &paintbox)
{
    if (!stroke_pattern) {
        switch (stroke.type) {
        case PAINT_SERVER: {
            stroke_pattern = sp_paint_server_create_pattern(stroke.server, ct.raw(), paintbox, stroke.opacity);
            } break;
        case PAINT_COLOR: {
            SPColor const &c = stroke.color;
            stroke_pattern = cairo_pattern_create_rgba(
                c.v.c[0], c.v.c[1], c.v.c[2], stroke.opacity);
            } break;
        default: break;
        }
    }
    if (!stroke_pattern) return false;
    return true;
}
示例#6
0
bool NRStyle::prepareFill(Inkscape::DrawingContext &dc, Geom::OptRect const &paintbox)
{
    // update fill pattern
    if (!fill_pattern) {
        switch (fill.type) {
        case PAINT_SERVER: {
            fill_pattern = fill.server->pattern_new(dc.raw(), paintbox, fill.opacity);
            } break;
        case PAINT_COLOR: {
            SPColor const &c = fill.color;
            fill_pattern = cairo_pattern_create_rgba(
                c.v.c[0], c.v.c[1], c.v.c[2], fill.opacity);
            } break;
        default: break;
        }
    }
    if (!fill_pattern) return false;
    return true;
}
示例#7
0
void NRStyle::applyTextDecorationFill(Inkscape::DrawingContext &dc)
{
    dc.setSource(text_decoration_fill_pattern);
    // Fill rule does not matter, no intersections.
}
示例#8
0
void NRStyle::applyFill(Inkscape::DrawingContext &dc)
{
    dc.setSource(fill_pattern);
    dc.setFillRule(fill_rule);
}