Panda3D

pnmBrush.h

00001 // Filename: pnmBrush.h
00002 // Created by:  drose (01Feb07)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef PNMBRUSH_H
00016 #define PNMBRUSH_H
00017 
00018 #include "pandabase.h"
00019 #include "referenceCount.h"
00020 #include "pointerTo.h"
00021 #include "luse.h"
00022 
00023 class PNMImage;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : PNMBrush
00027 // Description : This class is used to control the shape and color of
00028 //               the drawing operations performed by a PNMPainter
00029 //               object.
00030 //
00031 //               Normally, you don't create a PNMBrush directly;
00032 //               instead, use one of the static PNMBrush::make_*()
00033 //               methods provided here.
00034 //
00035 //               A PNMBrush is used to draw the border of a polygon or
00036 //               rectangle, as well as for filling its interior.  When
00037 //               it is used to draw a border, the brush is "smeared"
00038 //               over the border; when it is used to fill the
00039 //               interior, it is tiled through the interior.
00040 ////////////////////////////////////////////////////////////////////
00041 class EXPCL_PANDA_PNMIMAGE PNMBrush : public ReferenceCount {
00042 protected:
00043   INLINE PNMBrush(double xc, double yc);
00044 
00045 PUBLISHED:
00046   virtual ~PNMBrush();
00047 
00048   enum BrushEffect {
00049     BE_set,
00050     BE_blend,
00051     BE_darken,
00052     BE_lighten,
00053   };
00054 
00055   static PT(PNMBrush) make_transparent();
00056   static PT(PNMBrush) make_pixel(const LColord &color, BrushEffect effect = BE_blend);
00057   static PT(PNMBrush) make_spot(const LColord &color, double radius, bool fuzzy,
00058                                 BrushEffect effect = BE_blend);
00059   static PT(PNMBrush) make_image(const PNMImage &image, double xc, double yc,
00060                                  BrushEffect effect = BE_blend);
00061 
00062 public:
00063   INLINE double get_xc() const;
00064   INLINE double get_yc() const;
00065 
00066   virtual void draw(PNMImage &image, int x, int y, double pixel_scale)=0;
00067   virtual void fill(PNMImage &image, int xfrom, int xto, int y,
00068                     int xo, int yo)=0;
00069 
00070 protected:
00071   double _xc, _yc;
00072 };
00073 
00074 #include "pnmBrush.I"
00075 
00076 #endif
 All Classes Functions Variables Enumerations