1 /** 2 * @file 3 * @brief Path sink for Cairo contexts 4 *//* 5 * Copyright 2014 Krzysztof Kosiński 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it either under the terms of the GNU Lesser General Public 9 * License version 2.1 as published by the Free Software Foundation 10 * (the "LGPL") or, at your option, under the terms of the Mozilla 11 * Public License Version 1.1 (the "MPL"). If you do not alter this 12 * notice, a recipient may use your version of this file under either 13 * the MPL or the LGPL. 14 * 15 * You should have received a copy of the LGPL along with this library 16 * in the file COPYING-LGPL-2.1; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * You should have received a copy of the MPL along with this library 19 * in the file COPYING-MPL-1.1 20 * 21 * The contents of this file are subject to the Mozilla Public License 22 * Version 1.1 (the "License"); you may not use this file except in 23 * compliance with the License. You may obtain a copy of the License at 24 * http://www.mozilla.org/MPL/ 25 * 26 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY 27 * OF ANY KIND, either express or implied. See the LGPL or the MPL for 28 * the specific language governing rights and limitations. 29 * 30 */ 31 32 #ifndef LIB2GEOM_SEEN_CAIRO_PATH_SINK_H 33 #define LIB2GEOM_SEEN_CAIRO_PATH_SINK_H 34 35 #include <2geom/path-sink.h> 36 #include <cairo.h> 37 38 namespace Geom { 39 40 41 /** @brief Output paths to a Cairo drawing context 42 * 43 * This class converts from 2Geom path representation to the Cairo representation. 44 * Use it to simplify visualizing the results of 2Geom operations with the Cairo library, 45 * for example: 46 * @code 47 * CairoPathSink sink(cr); 48 * sink.feed(pv); 49 * cairo_stroke(cr); 50 * @endcode 51 * 52 * Currently the flush method is a no-op, but this is not guaranteed 53 * to hold forever. 54 */ 55 class CairoPathSink 56 : public PathSink 57 { 58 public: 59 CairoPathSink(cairo_t *cr); 60 61 void moveTo(Point const &p); 62 void lineTo(Point const &p); 63 void curveTo(Point const &c0, Point const &c1, Point const &p); 64 void quadTo(Point const &c, Point const &p); 65 void arcTo(Coord rx, Coord ry, Coord angle, 66 bool large_arc, bool sweep, Point const &p); 67 void closePath(); 68 void flush(); 69 70 private: 71 cairo_t *_cr; 72 Point _current_point; 73 }; 74 75 } 76 77 #endif // !LIB2GEOM_SEEN_CAIRO_PATH_SINK_H 78 /* 79 Local Variables: 80 mode:c++ 81 c-file-style:"stroustrup" 82 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) 83 indent-tabs-mode:nil 84 fill-column:99 85 End: 86 */ 87 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 : 88