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.

Authors

Dejan Lekić

License

BSD-3-Clause

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

Text extents result structure.

Fields
int dx
int dy
int w
int h

Functions 64

fnvoid color(uint c) nothrow @nogcSets the current drawing color.
fnvoid color(ubyte r, ubyte g, ubyte b) nothrow @nogcSets the current drawing color from RGB values.
fnuint getColor() nothrow @nogcGets the current drawing color.
fnuint colorAverage(uint c1, uint c2, float weight) nothrow @nogcAverages two colors together.
fnuint contrast(uint fg, uint bg) nothrow @nogcReturns a contrasting color.
fnuint inactive(uint c) nothrow @nogcReturns an inactive (grayed) version of a color.
fnuint lighter(uint c) nothrow @nogcReturns a lighter version of a color.
fnuint darker(uint c) nothrow @nogcReturns a darker version of a color.
fnuint grayRamp(int i) pure nothrow @nogcCreates a color from the FLTK gray ramp.
fnuint colorCube(int r, int g, int b) pure nothrow @nogcCreates a color from the FLTK color cube.
fnuint showColormap(uint oldcol)Shows a color selection popup.
fnvoid line(int x1, int y1, int x2, int y2) nothrow @nogcDraws a line between two points.
fnvoid rect(int x, int y, int w, int h) nothrow @nogcDraws an outlined rectangle.
fnvoid rectf(int x, int y, int w, int h) nothrow @nogcDraws a filled rectangle.
fnvoid rectf(int x, int y, int w, int h, ubyte r, ubyte g, ubyte b) nothrow @nogcDraws a filled rectangle with a specific color.
fnvoid point(int x, int y) nothrow @nogcDraws a single point.
fnvoid arc(int x, int y, int w, int h, double a1, double a2) nothrow @nogcDraws an arc (part of an ellipse outline).
fnvoid pie(int x, int y, int w, int h, double a1, double a2) nothrow @nogcDraws a filled pie slice.
fnvoid circle(double x, double y, double r) nothrow @nogcDraws a circle outline.
fnvoid font(int face, int size) nothrow @nogcSets the current font and size for text drawing.
fnvoid font(Font face, int size) nothrow @nogcditto
fnint fontHeight() nothrow @nogcGets the height of the current font.
fnint fontDescent() nothrow @nogcGets the descent of the current font.
fndouble textWidth(string text)Gets the width of a string in the current font.
fnvoid measureText(string text, out int width, out int height)Measures the width and height of a string.
fnvoid drawText(string text, int x, int y)Draws text at a position.
fnvoid pushClip(int x, int y, int w, int h) nothrow @nogcPushes a clipping rectangle onto the stack.
fnvoid popClip() nothrow @nogcPops the most recent clipping rectangle.
fnbool notClipped(int x, int y, int w, int h) nothrow @nogcTests if a rectangle intersects the current clip region.
fnvoid pushNoClip() nothrow @nogcPushes an empty clipping region.
fnvoid beginComplexPolygon() nothrow @nogcBegins a complex polygon definition.
fnvoid endComplexPolygon() nothrow @nogcEnds a complex polygon definition and draws it filled.
fnvoid beginLine() nothrow @nogcBegins a line path.
fnvoid endLine() nothrow @nogcEnds a line path and draws it.
fnvoid beginLoop() nothrow @nogcBegins a closed loop path.
fnvoid endLoop() nothrow @nogcEnds a closed loop path and draws it.
fnvoid beginPolygon() nothrow @nogcBegins a filled polygon path.
fnvoid endPolygon() nothrow @nogcEnds a filled polygon path and draws it.
fnvoid vertex(double x, double y) nothrow @nogcAdds a vertex to the current path.
fnvoid polygon(int x0, int y0, int x1, int y1, int x2, int y2) nothrow @nogcDraws a filled triangle.
fnvoid polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) nothrow @nogcDraws a filled quadrilateral.
fnvoid loop(int x0, int y0, int x1, int y1, int x2, int y2) nothrow @nogcDraws an unfilled triangle (line loop).
fnvoid loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) nothrow @nogcDraws an unfilled quadrilateral (line loop).
fnvoid gap() nothrow @nogcMarks a gap in a complex polygon.
fnvoid overlayRect(int x, int y, int w, int h) nothrow @nogcDraws an XOR overlay rectangle.
fnvoid overlayClear() nothrow @nogcClears any XOR overlay drawing.
fnvoid setCursor(Cursor cursor) nothrow @nogcSets the cursor shape for the current window.
fnvoid setCursor(int cursor) nothrow @nogcditto
fnvoid setCursor(Cursor cursor, uint fg, uint bg = 0xFFFFFF00) nothrow @nogcSets the cursor shape with custom colors.
fnvoid 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.
fnstring shortcutLabel(uint shortcut)Gets the human-readable label for a keyboard shortcut.
fnbool drawSymbol(string label, int x, int y, int w, int h, uint c)Draws a named FLTK symbol.
fnTextExtents textExtents(string text)Gets the precise bounding box of text.
fnstring latin1ToLocal(string text)Converts Latin-1 encoded text to local encoding.
fnstring localToLatin1(string text)Converts local encoding to Latin-1.
fnstring macRomanToLocal(string text)Converts Mac Roman encoded text to local encoding.
fnstring localToMacRoman(string text)Converts local encoding to Mac Roman.
fnvoid drawBox(int boxtype, int x, int y, int w, int h, uint c) nothrow @nogcDraws a box with the specified type and color.
fnvoid frame(string s, int x, int y, int w, int h)Draws a frame using a string specification.
fnvoid frame2(string s, int x, int y, int w, int h)Draws a frame using a string specification (variant).
fnvoid 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.
fnvoid 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.
fnubyte * readImage(ubyte * buf, int x, int y, int w, int h, bool alpha = false) nothrow @nogcReads pixels from the current window into a buffer.
fnbool canDoAlphaBlending() nothrow @nogcChecks if the display supports alpha blending.