Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class SPPaintServer : public SPObject {
- public:
- SPPaintServer();
- virtual ~SPPaintServer();
- bool isSwatch() const;
- bool isSolid() const;
- virtual bool isValid() const;
- protected:
- bool swatch;
- };
- class SPPattern : public SPPaintServer {
- public:
- gdouble get_x(bool chain=true);
- gdouble get_y(bool chain=true);
- gdouble get_width(bool chain=true);
- gdouble get_heigth(bool chain=true);
- Geom::OptRect get_view_box(bool chain=true);
- //similar for pattern_units, pattern_content_unit, pattern_transform
- }
- class NRPaintServer {
- public:
- static NRPaintServer* create(SPPaintServer* ps) //can also use boost::unique_pointer<NRPaintServer>
- virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) = 0;
- }
- class NRPattern : public NRPaintServer {
- public:
- NRPattern(SPPattern& p);
- cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity) {
- //use _pattern and render the pattern
- }
- private:
- SPPattern& _pattern;
- }
- /****************************
- Class using NRPaintServer - NRStyle
- *****************************/
- class NRStyle {
- //...
- bool prepareFill() {
- NRPaintServer* ps = NRPaintServer::create(fill.server);
- fill_pattern = ps->pattern_new(dc.raw(), paintbox, fill.opacity);
- delete ps;
- //or store it somewhere for performance reasons
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement