// 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; }
pattern.h