News | About | Download | Documentation | Development | Links
All ClanLib display primitives, including lines, rectangles, surfaces and fonts have built-in support for alpha-blending. Always keep in mind that alpha blending is slow (you should consider using the ClanLib OpenGL target if you use alot of alpha blending), and that alpha-values in ClanLib go from 0 as being totally transparent, to 255 being totally opaque.
Sometimes it's practical to limit the drawing of items to a specific area of the screen. ClanLib always uses the screen boundary as a clipping rectangle, so you never have to worry about showing objects outside the screen - just call the draw-function and they are trivially rejected by the clipper.
Like many other clipping systems, the ClanLib clipping system uses a stack principle. It's not possible to create polygonal clipping areas this way. Instead, if you push a new clipping rectangle upon the clipping stack, the single clipping rectangle used to clip further graphics is defined as the area shared by the previous clipping rectangle and the newly pushed one (the intersection).
The previous clipping rectangle is stored and brought back to use when the clipping rectangle in action is pop'ed off the clipping stack. However, it's also possible to set the clipping rectangle in absolute terms, disregarding any previous clipping rectangles.
Example of use:
CL_Display::push_cliprect(CL_Rect(10,10,100,100)); CL_Display::clear(); CL_Display::fill_rect(0,0,400,400, CL_Color::white); CL_Display::pop_cliprect();
In this example, the clear() and fill_rect() calls are clipped to the 10,10,100,100 rectangle.
Todo: Mention translation offset