1 // tiledCanvas.h 2 // this file is part of Context Free 3 // --------------------- 4 // Copyright (C) 2006-2012 John Horigan - john@glyphic.com 5 // 6 // This program is free software; you can redistribute it and/or 7 // modify it under the terms of the GNU General Public License 8 // as published by the Free Software Foundation; either version 2 9 // of the License, or (at your option) any later version. 10 // 11 // This program is distributed in the hope that it will be useful, 12 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // GNU General Public License for more details. 15 // 16 // You should have received a copy of the GNU General Public License 17 // along with this program; if not, write to the Free Software 18 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 // 20 // John Horigan can be contacted at john@glyphic.com or at 21 // John Horigan, 1209 Villa St., Mountain View, CA 94041-1123, USA 22 // 23 // 24 25 #ifndef INCLUDE_TILEDCANVAS_H 26 #define INCLUDE_TILEDCANVAS_H 27 28 #include "agg2/agg_trans_affine.h" 29 #include "agg2/agg_color_rgba.h" 30 #include "cfdg.h" 31 #include "bounds.h" 32 #include "shape.h" 33 #include <vector> 34 #include "pathIterator.h" 35 36 using tileList = std::vector<agg::point_i>; 37 38 class tiledCanvas : public Canvas { 39 public: 40 void start(bool clear, const agg::rgba& bk, int width, int height) override; 41 void end() override; 42 43 void primitive(int shape, RGBA8 c, agg::trans_affine tr, agg::comp_op_e blend) override; 44 void path(RGBA8 c, agg::trans_affine tr, const AST::CommandInfo& attr) override; 45 46 tiledCanvas(Canvas* tile, const agg::trans_affine& tr, CFDG::frieze_t f); 47 ~tiledCanvas() override = default; 48 tiledCanvas& operator=(const tiledCanvas&) = delete; 49 50 void scale(double scaleFactor); 51 52 tileList getTessellation(int width, int height, int x, int y, bool flipY = false); 53 void tileTransform(const Bounds& b); 54 55 private: 56 Canvas* mTile; 57 const agg::trans_affine mTileTransform; 58 CFDG::frieze_t mFrieze; 59 agg::trans_affine mOffset; 60 agg::trans_affine mInvert; 61 std::vector<agg::point_d> mTileList; 62 inline bool checkTile(const Bounds& b, const agg::rect_d& canvas, double dx, double dy); 63 inline bool checkTileInt(const agg::rect_i& screen, 64 const agg::trans_affine& screenTessellation, 65 int px, int py, tileList& points); 66 }; 67 68 #endif // INCLUDE_TILEDCANVAS_H 69