Use this file to discover all available pages before exploring further.
FLTK provides a comprehensive set of drawing functions in FL/fl_draw.H for creating custom graphics, from simple shapes to complex drawings. All drawing must occur within a widget’s draw() method or when a window is current.
// RGB color (0-255 for each component)fl_color(200, 220, 240);// Or use fl_rgb_color helperFl_Color c = fl_rgb_color(200, 220, 240);fl_color(c);// GrayscaleFl_Color gray = fl_rgb_color(128);fl_color(gray);
// Lighter/darker versionsfl_color(fl_lighter(FL_BLUE));fl_color(fl_darker(FL_RED));// Average two colorsFl_Color mix = fl_color_average(FL_RED, FL_BLUE, 0.5);// Inactive colorfl_color(fl_inactive(FL_BLACK));// Get current colorFl_Color current = fl_color();
From FL/fl_draw.H:478-526, fast integer circle drawing:
// Arc outline (angles in degrees from 3 o'clock)fl_arc(x, y, w, h, start_angle, end_angle);fl_arc(100, 100, 50, 50, 0, 180); // Half circle// Filled pie slicefl_pie(x, y, w, h, start_angle, end_angle);fl_pie(100, 100, 50, 50, 45, 135); // Quarter pie
From FL/fl_draw.H:528-686, precise floating-point drawing:
// Must use with vertex systemfl_begin_line();fl_arc(center_x, center_y, radius, start_angle, end_angle);fl_end_line();// Full circlefl_begin_polygon();fl_circle(center_x, center_y, radius);fl_end_polygon();
// Set font firstfl_font(FL_HELVETICA, 14);// Draw text at positionfl_draw("Hello World", x, y);// Draw with lengthfl_draw(text, length, x, y);// Rotated text (degrees counter-clockwise)fl_draw(45, "Rotated", x, y);
// RGB image data (3 bytes per pixel)uchar *rgb_data = get_rgb_data();fl_draw_image(rgb_data, x, y, w, h);// With custom stridefl_draw_image(rgb_data, x, y, w, h, 3, // bytes per pixel (RGB) 0); // line stride (0 = w*3)// Grayscale image (1 byte per pixel)uchar *gray_data = get_gray_data();fl_draw_image_mono(gray_data, x, y, w, h);// Draw with callback (for on-demand generation)void image_cb(void *data, int x, int y, int w, uchar *buf) { // Fill buf with scanline data // buf must be filled with w pixels starting at x,y}fl_draw_image(image_cb, userdata, x, y, w, h, 3);
From FL/fl_draw.H:82-197, restrict drawing to regions:
// Push clip regionfl_push_clip(x, y, w, h);// Drawing is clipped to this rectanglefl_rectf(0, 0, 1000, 1000); // Only visible in clip region// Pop clip regionfl_pop_clip();// Check if rectangle is visibleif (fl_not_clipped(x, y, w, h)) { // At least part is visible}// Get clipped bounding boxint cx, cy, cw, ch;if (fl_clip_box(x, y, w, h, cx, cy, cw, ch)) { // Rectangle was clipped, use cx,cy,cw,ch}