The display pointer to be passed into this function can be accessed by calling: World::current()->display().
// Color Example #include <ivplus/color.h> #include <ivplus/interactor.h> #include <ivplus/frame.h> #include <ivplus/painter.h> #include <ivplus/shape.h> #include <ivplus/world.h> // Create a derived class from Interactor to make use of color. class MyInteractor : public Interactor { public: MyInteractor() {}; private: void Reconfig(); void Redraw(IntCoord, IntCoord, IntCoord, IntCoord); }; // Define shape of MyInteractor here. void MyInteractor::Reconfig() { Interactor::Reconfig(); shape->width = 300; // pixels shape->height = 300; }; // Do the drawing here void MyInteractor::Redraw(IntCoord, IntCoord, IntCoord, IntCoord) { int i; // Make foreground & background colors with some RGB value. const Color* fg1 = new Color(35000, 65535, 0); const Color* bg1 = new Color(0, 35000, 65535); // Make foreground & background colors from the display value. // This can be used if the window is mapped. // World* w = GetWorld(); // Display* dp = w->display(); // const Color* fg2 = Color::lookup (dp, "black"); // const Color* bg2 = Color::lookup (dp, "white"); // Draw a few filled rectangles using the fg, bg colors on the canvas. for (i=0; i<5; i++) { // Set the painter foreground & background colors // change the bg & fg after each iteration. if (i%2) output->SetColors(fg1, bg1); else output->SetColors(bg1, fg1); output->FillRect(canvas, (i*50), (i*50), shape->width-(i*50), shape->height-(i*50)); } }; int main(int argc, char **argv) { World* world = new World("MyApp", argc, argv); // Make 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; }
color.h