fltk.draw
FLTK Drawing Functions
This module provides drawing primitives for custom widget rendering:
- Color management
- Lines, rectangles, points
- Arcs, circles, pie slices
- Text drawing and font management
- Clipping regions
These functions should only be called from within a widget's draw() method or during an FLTK redraw operation.
License
BSD-3-Clause
Copyright
Copyright © 2025 DDN (D Developer Network) Members
struct TextExtents
fn arc beginComplexPolygon beginLine beginLoop beginPolygon canDoAlphaBlending circle color colorAverage colorCube contrast darker drawBox drawImage drawImageMono drawSymbol drawText endComplexPolygon endLine endLoop endPolygon font fontDescent fontHeight frame frame2 gap getColor grayRamp inactive latin1ToLocal lighter line localToLatin1 localToMacRoman loop macRomanToLocal measureText notClipped overlayClear overlayRect pie point polygon popClip pushClip pushNoClip readImage rect rectf scroll setCursor shortcutLabel showColormap textExtents textWidth vertex
Types 3
enumFont
Common font faces.
helvetica = 0
helveticaBold = 1
helveticaItalic = 2
helveticaBoldItalic = 3
courier = 4
courierBold = 5
courierItalic = 6
courierBoldItalic = 7
times = 8
timesBold = 9
timesItalic = 10
timesBoldItalic = 11
symbol = 12
screen = 13
screenBold = 14
zapfDingbats = 15
enumCursor
Cursor shapes for use with setCursor().
DEFAULT = 0The default cursor, usually an arrow
ARROW = 35An arrow pointer
CROSS = 66Crosshair
WAIT = 76Busy indicator (e.g. hourglass)
INSERT = 77I-beam for text insertion
HAND = 31Pointing hand
HELP = 47Question mark pointer
MOVE = 274-pointed arrow or hand
NS = 78Up/down resize
WE = 79Left/right resize
NWSE = 80Diagonal resize (NW-SE)
NESW = 81Diagonal resize (NE-SW)
N = 70Upwards resize
NE = 69Upwards, right resize
E = 49Rightwards resize
SE = 8Downwards, right resize
S = 9Downwards resize
SW = 7Downwards, left resize
W = 36Leftwards resize
NW = 68Upwards, left resize
NONE = 255Invisible cursor
structTextExtents
Text extents result structure.
Fields
int dxint dyint wint hFunctions 64
fn
void color(ubyte r, ubyte g, ubyte b) nothrow @nogcSets the current drawing color from RGB values.fn
void rectf(int x, int y, int w, int h, ubyte r, ubyte g, ubyte b) nothrow @nogcDraws a filled rectangle with a specific color.fn
void arc(int x, int y, int w, int h, double a1, double a2) nothrow @nogcDraws an arc (part of an ellipse outline).fn
void measureText(string text, out int width, out int height)Measures the width and height of a string.fn
void pushClip(int x, int y, int w, int h) nothrow @nogcPushes a clipping rectangle onto the stack.fn
bool notClipped(int x, int y, int w, int h) nothrow @nogcTests if a rectangle intersects the current clip region.fn
void polygon(int x0, int y0, int x1, int y1, int x2, int y2) nothrow @nogcDraws a filled triangle.fn
void polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) nothrow @nogcDraws a filled quadrilateral.fn
void loop(int x0, int y0, int x1, int y1, int x2, int y2) nothrow @nogcDraws an unfilled triangle (line loop).fn
void loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) nothrow @nogcDraws an unfilled quadrilateral (line loop).fn
void setCursor(Cursor cursor, uint fg, uint bg = 0xFFFFFF00) nothrow @nogcSets the cursor shape with custom colors.fn
void scroll(int x, int y, int w, int h, int dx, int dy,
ScrollDrawAreaCallback drawArea = null, void * data = null) nothrow @nogcScrolls a rectangle by a given amount.fn
void drawBox(int boxtype, int x, int y, int w, int h, uint c) nothrow @nogcDraws a box with the specified type and color.fn
void frame2(string s, int x, int y, int w, int h)Draws a frame using a string specification (variant).fn
void drawImage(const(ubyte)[] buf, int x, int y, int w, int h, int depth = 3, int lineSize = 0) nothrow @nogcDraws raw RGB image data to the screen.fn
void drawImageMono(const(ubyte)[] buf, int x, int y, int w, int h, int depth = 1, int lineSize = 0) nothrow @nogcDraws raw monochrome image data to the screen.fn
ubyte * readImage(ubyte * buf, int x, int y, int w, int h, bool alpha = false) nothrow @nogcReads pixels from the current window into a buffer.