[Go to CFHT Home Page] Man Pages
Back to Software Index  BORDER=0Manpage Top Level
    Pattern(3X) manual page Table of Contents

Name

Pattern - fill patterns used by Painter

Synopsis

#include <ivplus/pattern.h>

Description

Pattern defines how to fill areas during graphics operations on a canvas. A pattern is essentially a mask for drawing that is replicated to fill the size of the destination area on the canvas.

Class Hierarchy

Pattern->Resource

Constructors

Pattern()

Creates a solid pattern.

Pattern(char*, unsigned int width, unsigned int height)

Creates a pattern with the given width and height, using the bits described by the first parameter.

Pattern(int)

Creates a 4x4 pattern determined from the least significant 16 bits of the parameter.

Pattern(int*)

Constructs a 16x16 pattern from the given data.

Public Data

enum { solid = 0xffff, clear = 0x0000, lightgray = 0x8020, gray = 0xa5a5, darkgray = 0xfafa }

Predefined patterns.

Public Operations

PatternRep* rep() const

Returns a pointer to the instance of PatternRep used by the pattern. The PatternRep class is a low level interface to X Windows. It is not expected that developers will need details of the PatternRep interface so the PatternRep class is not documented.

X Resources

None.

Examples


//                          Pattern Example
#include <ivplus/box.h>
#include <ivplus/frame.h>
#include <ivplus/painter.h>
#include <ivplus/pattern.h>
#include <ivplus/shape.h>
#include <ivplus/world.h>
// Create a derived class from Interactor to make use of pattern.
class MyInteractor : public Interactor {
public:
   MyInteractor()
      : Interactor() { };
private:
   void Reconfig();
   void Redraw(IntCoord, IntCoord, IntCoord, IntCoord);
   Painter* painter;
};
void MyInteractor::Reconfig()
{
   // Create a painter whose attributes are set below.
   painter = new Painter(output);
   // Create a 4x4 pattern using the least significant 16 bits.
   const Pattern* pattern = new Pattern(0xfca0);
   // Ask painter to use this pattern for drawing.
   painter->SetPattern(pattern);
   Interactor::Reconfig();
   // Make some space for drawing, shape is defined in Interactor.
   shape->width = 500;
   shape->height = 500;
};
void MyInteractor::Redraw(IntCoord, IntCoord, IntCoord, IntCoord)
{
   // Draw a filled rectangle using attributes of painter on the canvas.
   painter->FillRect(canvas, 10, 10,
                 shape->width-10, shape->height-10);
};
int main(int argc, char **argv)
{
   // Create the world to get the connection with the display.
   World* world = new World("MyApp", argc, argv);
   // Create an instance of MyInteractor.
   MyInteractor* interactor = new MyInteractor();
   // Map the window.
   world->InsertApplication(new Frame(interactor, 1, BevelOut));
   // Enter the event loop.
   world->Run();
   return 0;
}

Files


pattern.h

See Also

Painter(3X) , Resource(3X) .


Table of Contents