diff options
Diffstat (limited to 'gmathview/gmathview_utils.c')
-rw-r--r-- | gmathview/gmathview_utils.c | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/gmathview/gmathview_utils.c b/gmathview/gmathview_utils.c new file mode 100644 index 0000000..c466594 --- /dev/null +++ b/gmathview/gmathview_utils.c @@ -0,0 +1,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); +} |