Painter - graphics output


SYNOPSIS

       #include <InterViews/painter.h>


DESCRIPTION

       Painter is a class that provides ``immediate-mode'' graph-
       ics operations for drawing on a canvas.  The  state  of  a
       painter defines the graphics context for the drawing oper-
       ations and includes a  brush,  foreground  and  background
       colors,  a  fill  pattern  and  mode,  a text font, a text
       style, an output origin and current position, and a trans-
       formation matrix.


STATE OPERATIONS

       Painter(Painter* = stdpaint)
              Create  a  new  painter and copy its state from the
              given painter.

       void SetBrush(Brush*)
       Brush* GetBrush()
              Set or return the painter's brush.  Default is  the
              predefined brush ``single''.

       void SetColors(Color* fg, Color* bg)
       Color* GetFgColor()
       Color* GetBgColor()
              Set  or  return  the  painter's  colors.  If either
              argument to SetColors is nil, then the  correspond-
              ing  color  is not changed.  Defaults are ``black''
              for foreground and ``white'' for background.

       void SetFont(Font*)
       Font* GetFont()
              Set or return the painter's text font.  Default  is
              the predefined font ``stdfont''.

       void SetStyle(int style)
       int GetStyle()
              Set  or get the painter's text style.  A text style
              is a bit vector that can be assembled from the pre-
              defined  constants Plain, Boldface, Underlined, and
              Reversed.  Default is Plain.

       void SetPattern(Pattern*)
       Pattern* GetPattern()
       void FillBg(boolean mode)
       boolean BgFilled()
              Set or return the painter's fill pattern and  mode.
              If  the mode is true, fill operations will set pix-
              els corresponding to ones in the current fill  pat-
              tern to the foreground color and pixels correspond-
              pattern is ``solid''; default mode is true.

       void SetOrigin(int x0, int y0)
       void GetOrigin(int& x0, int& y0)
              Set or return the origin by which  all  coordinates
              are offset.  Default is (0, 0).

       void Translate(float dx, float dy)
       void Rotate(float angle)
       void Scale(float x, float y)
       void SetTransformer(Transformer*)
       Transformer* GetTransformer()
              Coordinates passed to drawing operations are trans-
              formed according to the current origin, translation
              (cumulative),  rotation,  and scale factor.  Inter-
              nally, a transformation matrix is stored  that  can
              be  directly  set and accessed using SetTransformer
              and GetTransformer.   The  default  transformer  is
              nil, meaning no transformations are performed.

       void SetPlaneMask(int mask)
              Set which bit planes are affected by drawing opera-
              tions.  If the Kth bit of mask is set, then display
              operations will draw on plane K.

       void SetOverwrite(boolean)
              Set  whether  a painter is allowed to write in sub-
              canvases.  If true, drawing operations will be able
              to  write  over  the canvases of component interac-
              tors.  If false, drawing operations will be clipped
              by any subcanvases.  The default is false.

       void Clip(Canvas*, Coord x1, Coord y1, Coord x2, Coord y2)
       void NoClip()
              Clip restricts output operations to  the  specified
              region  of the canvas.  NoClip removes the restric-
              tion so that operations affect the  entire  canvas.
              Only  one  clipping  region  may  be in effect at a
              time.

       void MoveTo(Coord x, Coord y)
              Set the current output position.  The output  posi-
              tion is used and updated by Text and CurveTo.


DRAWING OPERATIONS

       void Curve(Canvas*, Coord x0, y0, x1, y1, x2, y2, x3, y3)
       void CurveTo(Canvas*, Coord x1, y1, x2, y2, x3, y3)
              Paint  a  Bezier curve on the canvas from the first
              point to the last point (but not going through  the
              intermediate  control  points).  The curve will lie
              within the  polygon  formed  by  the  four  points.
              CurveTo  uses  the  current  position for the first

       void ClosedBSpline(Canvas*, Coord x[], y[], int n)
       void FillBSpline(Canvas*, Coord x[], y[], int n)
              Draw the B-spline defined by  the  n  control  ver-
              tices.  If closed or filled, the last point is con-
              nected to the first point.

       void Circle(Canvas*, Coord x, y, int r)
       void FillCircle(Canvas*, Coord x, y, int radius)
              Draw a circle with center (x, y) and radius r.

       void Ellipse(Canvas*, Coord x, y, int xr, int yr)
       void FillEllipse(Canvas*, Coord x, y, int xr, int yr)
              Draw an  ellipse  with  center  (x, y),  horizontal
              radius xr, and vertical radius yr.

       void Line(Canvas*, Coord x1, y1, x2, y2)
       void MultiLine(Canvas*, Coord x[], y[], int n)
       void Polygon(Canvas*, Coord x[], y[], int n)
       void FillPolygon(Canvas*, Coord x[], y[], int n)
              Draw  a  path  using  the current brush and colors.
              The Line  operation  draws  a  vector  between  two
              points  (inclusive);  MultiLine  draws  a number of
              connected vectors; Polygon draws a  closed  set  of
              vectors;  FillPolygon fills the area inside a poly-
              gon using the current fill pattern and colors.

       void Point(Canvas*, Coord x, y)
       void MultiPoint(Canvas*, Coord x[], y[], int n)
              Set a point or set of points to the  current  fore-
              ground color.

       void Rect(Canvas*, Coord x1, y1, x2, y2)
       void FillRect(Canvas*, Coord x1, y1, x2, y2)
       void ClearRect(Canvas*, Coord x1, y1, x2, y2)
              Draw  a rectangle with opposite corners specfied by
              (x1, y1) and (x2, y2).  FillRect fills the  rectan-
              gle using the current pattern and colors; ClearRect
              fills the rectangle with the background color.

       void Text(Canvas*, const char* str, Coord x, Coord y)
       void Text(Canvas*, const char* str, int n, Coord x, Coord
              y)
       void Text(Canvas*, const char* str)
       void Text(Canvas*, const char* str, int n)
              Draw  a  string or substring of text using the cur-
              rent Font and text style.  The  (x, y)  coordinates
              specify  the  lower-left corner of the bounding box
              of the text.  The width of the bounding box is  the
              width  of the string as reported by the Font::Width
              operation, and the height of the  bounding  box  is
              the  Font height.  Most fonts will result in output
              which only affects pixels within the bounding  box.
              drawn.   If  the  matrix specifies a transformation
              involving rotation or scaling, the resulting opera-
              tion  may proceed much more slowly than normal.  If
              background fill mode is on, then the characters are
              drawn  in  the  foreground  color, and other pixels
              within the bounding box are set to  the  background
              color.   If  background  fill mode is off, only the
              foreground pixels are set.  If no  coordinates  are
              specified,  then  the  current position (defined by
              MoveTo) is used and updated to reflect  the  lower-
              right corner of the bounding box.

       void  Stencil(Canvas*,  Coord  x, Coord y, Bitmap* image,
              Bitmap* mask = nil)
              Paint  foreground  and  background colors through a
              stencil formed by positioning the  image  and  mask
              Bitmaps  with  their  origins  at the point (x, y).
              Foreground color is painted where the image  Bitmap
              has  a  true value and background color where image
              is false.  However, only pixels corresponding to  a
              true  value in the mask Bitmap are affected.  A nil
              mask is equivalent to a mask of the same  size  and
              shape as image and containing all true values.  The
              current transformation matrix is  applied  to  both
              the  image  and mask Bitmaps.  If the matrix speci-
              fies a transformation involving rotation  or  scal-
              ing,  the resulting operation may proceed much more
              slowly than normal.

       void RasterRect(Canvas*, Coord x, Coord y, Raster*)
              Render the Raster with its lower-left corner at the
              position (x, y).  The current transformation matrix
              is applied to the Raster.  If the matrix  specifies
              a transformation involving rotation or scaling, the
              resulting operation may proceed  much  more  slowly
              than normal.

       void Read(Canvas*, void*, Coord x1, y1, x2, y2)
       void Write(Canvas*, const void*, Coord x1, y1, x2, y2)
       void  Copy(Canvas*  src, Coord x1, y1, x2, y2, Canvas*
              dst, Coord x0, y0)
              Read  copies  a  region  of  a  canvas into memory.
              Write copies data from memory to a region of a can-
              vas.   Copy reads a region of one canvas and writes
              the data into a region of another canvas (or within
              a  canvas  if src and dst are the same).  The point
              (x0, y0) is the lower-left corner of  the  destina-
              tion   region.    Note  that  Read  and  Write  are
              superceded by operations that use Rasters.


SEE ALSO

       Bitmap(3I), Brush(3I),  Canvas(3I),  Color(3I),  Font(3I),

Man(1) output converted with man2html