SophiaFramework UNIVERSE 5.3 |
Clipping is the function that the outside area of specified shape such as rectangle, circle, triangle, or polygon may not be drawn.
SFXClip is the Shape class for clipping.
In the figure below, the string is clipped by rectangle.
Example 12.33. Clip the string with rectangular
// black color SFXRGBColor black(0x00, 0x00, 0x00, 0x00); // rectangle SFXRectangle rectangle(10, 10, 150, 55); // draw border graphics->DrawRectangle(rectangle, black); // clip rectangle SFXClip clip(rectangle); // set clipping graphics->SetClip(rectangle); // get top-left of rectangle SFXGrid grid = rectangle.GetLeftTop(); // get font-height SInt32 fontHeight = graphics->GetFontHeight(); // draw string graphics->DrawText("test clipping", grid, black); // draw string (move drawing position down by fontHeight using grid.AddY(fontHeight)) graphics->DrawText("test clipping", grid.AddY(fontHeight), black); graphics->DrawText("test clipping", grid.AddY(fontHeight), black);
To do clipping by other than SFXRectangle, use the SFBGraphics instance instead of SFXGraphics.
Example 12.34. Clip the circle with other than rectangle
// get SFBGraphics interface SFBGraphicsSmp g = graphics->GetSFBGraphics(); // circle SFXCircle circle(100, 50, 40); // clip circle SFXClip clip(circle); // set clipping g->SetClip(&clip, AEE_GRAPHICS_FRAME); // set fill color g->SetFillColor(SFXRGBColor(0x99, 0x99, 0x99, 0x00)); // draw rectangle g->DrawRect(&SFXRectangle(55, 5, 60, 80));
The rectangle is clipped with the specified circle.
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |