Advertisement
Guest User

Untitled

a guest
May 26th, 2014
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.43 KB | None | 0 0
  1. class SPPaintServer : public SPObject {
  2. public:
  3.     SPPaintServer();
  4.     virtual ~SPPaintServer();
  5.  
  6.     bool isSwatch() const;
  7.     bool isSolid() const;
  8.     virtual bool isValid() const;
  9.  
  10. protected:
  11.     bool swatch;
  12. };
  13.  
  14. class SPPattern : public SPPaintServer {
  15. public:
  16.     gdouble get_x(bool chain=true);
  17.     gdouble get_y(bool chain=true);
  18.     gdouble get_width(bool chain=true);
  19.     gdouble get_heigth(bool chain=true);
  20.     Geom::OptRect get_view_box(bool chain=true);
  21.     //similar for pattern_units, pattern_content_unit, pattern_transform
  22. }
  23.  
  24. class NRPaintServer {
  25. public:
  26.     static NRPaintServer* create(SPPaintServer* ps) //can also use boost::unique_pointer<NRPaintServer>
  27.  
  28.     virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) = 0;
  29. }
  30.  
  31. class NRPattern : public NRPaintServer {
  32. public:
  33.     NRPattern(SPPattern& p);
  34.  
  35.     cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) {
  36.         //use _pattern and render the pattern
  37.     }
  38. private:
  39.     SPPattern& _pattern;
  40. }
  41.  
  42. /****************************
  43.   Class using NRPaintServer - NRStyle
  44. *****************************/
  45. class NRStyle {
  46. //...
  47.     bool prepareFill() {
  48.         NRPaintServer* ps = NRPaintServer::create(fill.server);
  49.         fill_pattern = ps->pattern_new(dc.raw(), paintbox, fill.opacity);
  50.         delete ps;
  51.         //or store it somewhere for performance reasons
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement