Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fltk/fltk/llms.txt
Use this file to discover all available pages before exploring further.
Overview
FLTK provides a comprehensive set of portable drawing functions for creating graphics, rendering text, drawing shapes, and manipulating images. These functions work across all supported platforms (Windows, macOS, Linux/X11). Header:<FL/fl_draw.H>
Color Functions
Sets the color for all subsequent drawing operations.For color-mapped displays, a color cell is allocated from fl_colormap the first time a color is used.
Color index from the FLTK color map
Returns the last fl_color() that was set. Can be used for state save/restore.
Line Style
Sets how to draw lines (the “pen”).
Bitmask of line style, cap style, and join style:
FL_SOLID- Solid line (0)FL_DASH- Dashed line (1)FL_DOT- Dotted line (2)FL_DASHDOT- Dash-dot pattern (3)FL_DASHDOTDOT- Dash-dot-dot pattern (4)FL_CAP_FLAT- Flat end caps (0x100)FL_CAP_ROUND- Round end caps (0x200)FL_CAP_SQUARE- Square end caps (0x300)FL_JOIN_MITER- Miter join (0x1000)FL_JOIN_ROUND- Round join (0x2000)FL_JOIN_BEVEL- Bevel join (0x3000)FL_UNIFORM_WIDTH- Uniform width in scaled contexts (0x10000)
Line thickness in pixels (0 = system default)
Array of dash lengths in pixels, terminated with 0
Turns antialiased line drawing ON or OFF (Windows only).
Returns whether line drawings are currently antialiased.
Rectangle Functions
Fills a rectangle with the current color.
Fills a rectangle with the specified color.
Fills a rectangle with an exact RGB color using dithering if needed.
Draws a rounded rectangle border.
Corner radius (optimized for values 5-15)
Fills a rounded rectangle.
Draws a dotted rectangle to indicate keyboard focus.
Line Functions
Draws a single pixel at the given coordinates.
Draws a line from (x,y) to (x1,y1).
Draws two connected line segments.
Draws a horizontal line from (x,y) to (x1,y).
Draws horizontal then vertical line segments.
Draws horizontal, vertical, horizontal line segments.
Draws a vertical line from (x,y) to (x,y1).
Draws vertical then horizontal line segments.
Draws vertical, horizontal, vertical line segments.
Polygon Functions
Outlines a 3-sided polygon with lines.
Outlines a 4-sided polygon with lines.
Fills a 3-sided polygon.
Fills a 4-sided polygon (must be convex).
Circle and Arc Functions
Draws a filled pie slice.
Adds a circle to the current path. Use with fl_begin_loop() or fl_begin_polygon().
Complex Path Drawing
Starts drawing a list of points. Add points with fl_vertex(), end with fl_end_points().
Starts drawing a list of lines.
Starts drawing a closed sequence of lines.
Starts drawing a convex filled polygon.
Starts drawing a complex filled polygon (can be concave or have holes).
Adds a single vertex to the current path.
fl_curve
void fl_curve(double X0, double Y0, double X1, double Y1, double X2, double Y2, double X3, double Y3)
Separates loops in complex polygons.
Ends and draws the point list.
Ends and draws the line list.
Ends and draws the closed line sequence.
Ends and draws the filled polygon.
Ends and draws the complex polygon.
Transformation Functions
Saves the current transformation matrix on the stack (max depth: 32).
Restores the transformation matrix from the stack.
Concatenates scaling transformation.
Concatenates uniform scaling transformation.
Concatenates translation transformation.
Concatenates rotation transformation (counter-clockwise in degrees).
Sets the transformation matrix to identity.
Concatenates another transformation: X’ = aX + cY + x, Y’ = bX + dY + y
Clipping Functions
Intersects the current clip region with a rectangle and pushes it onto the stack.
Pushes an empty clip region (nothing will be clipped).
Restores the previous clip region. Must be called once for every fl_push_clip().
Returns non-zero if any of the rectangle intersects the current clip region.
Intersects a rectangle with the current clip region and returns the bounding box.Returns non-zero if the resulting rectangle differs from the original.
Font Functions
Returns the current font face.
Returns the current font size.
Returns the recommended line spacing for the current font.
Returns the distance above the bottom of fl_height() to draw text for vertical centering.
Returns the typographical width of a null-terminated string.
Returns the width of n bytes of UTF-8 text.
Returns the width of a single Unicode character.
Text Drawing Functions
Draws text rotated counter-clockwise by angle degrees.
Rotation angle in degrees
Draws n bytes of UTF-8 text.
Draws text right-to-left.
fl_draw
void fl_draw(const char* str, int x, int y, int w, int h, Fl_Align align, Fl_Image* img = 0, int draw_symbols = 1, int spacing = 0)
Draws formatted and aligned text inside a bounding box.
UTF-8 string (can contain \n, \t, and @symbols)
Bounding box
Alignment flags (FL_ALIGN_LEFT, FL_ALIGN_CENTER, FL_ALIGN_RIGHT, etc.)
Optional image to draw with text
Whether to interpret @symbols
Spacing between text and image
Image Drawing Functions
fl_draw_image
void fl_draw_image(const uchar* buf, int X, int Y, int W, int H, int D = 3, int L = 0)
fl_draw_image_mono
void fl_draw_image_mono(const uchar* buf, int X, int Y, int W, int H, int D = 1, int L = 0)
Draws a grayscale (1 channel) image.
Reads a rectangular area of pixels from the screen.
Pixmap Functions
Measures the dimensions of XPM data.
Offscreen Rendering
Creates an offscreen buffer.
Begins drawing to an offscreen buffer.
Ends offscreen drawing and restores normal drawing.
Deletes an offscreen buffer.
fl_copy_offscreen
void fl_copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy)
Copies a rectangular area from an offscreen buffer to the current drawing destination.
Example Usage
Drawing Basic Shapes
Drawing with Line Styles
Drawing Text
Complex Polygon
Using Transformations
Drawing Raw Image Data
See Also
- Fl_Image - Image class hierarchy
- Fl_RGB_Image - RGB images
- Fl_Pixmap - XPM pixmaps