void CtrlRect::render(SPCanvasBuf *buf)
{
    if ((_area.x0 != 0 || _area.x1 != 0 || _area.y0 != 0 || _area.y1 != 0) &&
        (_area.x0 < buf->rect.x1) &&
        (_area.y0 < buf->rect.y1) &&
        ((_area.x1 + _shadow_size) >= buf->rect.x0) &&
        ((_area.y1 + _shadow_size) >= buf->rect.y0)) {
        sp_canvas_prepare_buffer(buf);

        /* Top */
        sp_ctrlrect_hline(buf, _area.y0, _area.x0, _area.x1, _border_color, _dashed);
        /* Bottom */
        sp_ctrlrect_hline(buf, _area.y1, _area.x0, _area.x1, _border_color, _dashed);
        /* Left */
        sp_ctrlrect_vline(buf, _area.x0, _area.y0 + 1, _area.y1 - 1, _border_color, _dashed);
        /* Right */
        sp_ctrlrect_vline(buf, _area.x1, _area.y0 + 1, _area.y1 - 1, _border_color, _dashed);
        if (_shadow_size > 0) {
            /* Right shadow */
            sp_ctrlrect_area(buf, _area.x1 + 1, _area.y0 + _shadow_size,
                             _area.x1 + _shadow_size, _area.y1 + _shadow_size, _shadow_color);
            /* Bottom shadow */
            sp_ctrlrect_area(buf, _area.x0 + _shadow_size, _area.y1 + 1,
                             _area.x1, _area.y1 + _shadow_size, _shadow_color);
        }
        if (_has_fill) {
            /* Fill */
            sp_ctrlrect_area(buf, _area.x0 + 1, _area.y0 + 1,
                             _area.x1 - 1, _area.y1 - 1, _fill_color);
        }
    }
}
예제 #2
0
static void
sp_ctrlline_render (SPCanvasItem *item, SPCanvasBuf *buf)
{
    SPCtrlLine *cl = SP_CTRLLINE (item);

    if (!buf->ct)
        return;

    if (cl->s == cl->e)
        return;

    sp_canvas_prepare_buffer (buf);

    guint32 rgba = cl->rgba;
    cairo_set_source_rgba(buf->ct, SP_RGBA32_B_F(rgba), SP_RGBA32_G_F(rgba), SP_RGBA32_R_F(rgba), SP_RGBA32_A_F(rgba));

    cairo_set_line_width(buf->ct, 1);
    cairo_new_path(buf->ct);

    Geom::Point s = cl->s * cl->affine;
    Geom::Point e = cl->e * cl->affine;

    cairo_move_to (buf->ct, s[Geom::X] - buf->rect.x0, s[Geom::Y] - buf->rect.y0);
    cairo_line_to (buf->ct, e[Geom::X] - buf->rect.x0, e[Geom::Y] - buf->rect.y0);

    cairo_stroke(buf->ct);
}