Graphics & Drawing Overview
This section details ProGUI's core 2D graphics rendering capabilities. These functions provide the tools to draw shapes, text, images, and complex borders onto output targets, which can be either windows or in-memory images. ProGUI abstracts the underlying graphics subsystem (Direct2D on Windows, Cairo on Linux) to offer a consistent API.
Key functionalities include:
- Drawing Context: Initiating and terminating drawing operations on a specific output (BeginDraw(), EndDraw()). The output target is obtained via OutputImg() with BeginDraw() and EndDraw() being handled automatically internally inside draw event handlers for windows and widgets.
- State Management: Saving and restoring the drawing state (transformations, clipping, styles) using DrawSave() and DrawRestore(). Setting global drawing properties like anti-aliasing (DrawSetAntialias()), blend mode (DrawSetBlendMode()), and DPI scaling (DrawDPI()).
- Drawing Primitives: Functions for drawing basic shapes like lines (DrawLine()), rectangles (DrawBox()), rounded
rectangles (DrawRoundBox()), and ellipses (DrawEllipse()). Includes variants for filling (
*Fill) and outlining (*Stroke). - Paths: A vector path API allowing the creation of complex shapes composed of lines, curves, and arcs (PathMoveTo(), PathAddLine(), PathAddCurve(), PathAddArc(), PathClose()). Paths can be drawn filled or stroked (DrawPathFill(), DrawPathStroke()).
- Stroke Styling: Configuring the appearance of lines and outlines using DrawSetStroke(), DrawSetStrokeCustom(), and DrawSetStrokeMiterLimit() to control width, dash patterns, end caps, and corner joins.
- Images & Borders: Drawing images (DrawImg(), DrawImgEx()) and complex borders (DrawBorder()) created using the Border API.
- Text: Rendering text created with the Text Handling API (DrawTxt(), DrawTxtFill()).
- Layers & Clipping: Managing drawing layers with opacity and masking (BeginLayer(), EndLayer()) and defining clipping regions (BeginClipBox(), BeginClipPath(), EndClip()).
- Output Management: Clearing the output (DrawClear()) and managing DPI settings for the drawing context (DrawDPI(), DrawGetDPI(), DrawGetDPIScaleX(), DrawGetDPIScaleY()).