summaryrefslogtreecommitdiff
path: root/gmathview/gmathview_utils.c
blob: c466594955834b90fb1e1bf1950a4460154e6662 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
 * gMathView, mathematic expressions viewing & editing widget
 *
 *  # Helper functions
 *
 * Author : Guillaume Seguin
 * Email : guillaume@segu.in
 *
 * Copyright (c) 2007 Guillaume Seguin <guillaume@segu.in>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA  02110-1301, USA.
 */

#include <gmathview.h>

cairo_surface_t*
g_math_view_copy_surface (cairo_surface_t *source)
{
    cairo_surface_t     *dest;
    cairo_t             *cr;

    if (!source)
        return NULL;

    dest = cairo_image_surface_create (cairo_image_surface_get_format (source),
                                       cairo_image_surface_get_width (source),
                                       cairo_image_surface_get_height (source));
    cr = cairo_create (dest);
    cairo_set_source_surface (cr, source, 0, 0);
    cairo_paint (cr);
    cairo_destroy (cr);

    return dest;
}

void
g_math_view_outline_boxed (cairo_surface_t *surface, GMathBoxed *boxed)
{
    cairo_t             *cr;

    if (!surface || !boxed)
        return;

    cr = cairo_create (surface);
    cairo_set_antialias (cr, CAIRO_ANTIALIAS_NONE);
    cairo_set_line_width (cr, OUTLINE_WIDTH);
    cairo_rectangle (cr, boxed->box.x, boxed->box.y,
                     boxed->box.width, boxed->box.height);
    cairo_stroke (cr);

    cairo_destroy (cr);
}