Function reference
graphics.h documentation for C graphics programming
Use these standalone references when you need syntax, parameter behavior, runnable examples, and practical mistakes for classic BGI functions. Our reference pages cover shapes, colors, and fill styles to help you learn C graphics programming.
Active Batches
Phase 1: Shape primitives
Phase 2: Colors and Fills
Phase 3: Text, Pixels, Setup, Timing
Phase 4: Screen clearing and cursor movement
Shapes
Drawing primitives
circle()
Draw a circle from a center point and radius, with examples for targets, rings, and classroom diagrams.
Outline shaperectangle()
Draw boxes, frames, panels, and coordinate windows from left, top, right, and bottom edges.
Drawing primitiveline()
Create straight segments between two absolute points using the active color and line style.
Curve segmentarc()
Draw a circular curve between start and end angles measured in degrees.
Curve shapeellipse()
Draw oval outlines and partial elliptical arcs with independent x and y radii.
Colors & Fills
Texturing and palettes
bar()
Draw solid or patterned rectangular blocks without outline borders, best for UI panels and charts.
Color Settingssetcolor()
Configure the active foreground color index for outline vector shapes and outtextxy text rendering.
Color Settingssetbkcolor()
Change the background canvas color dynamically using BGI hardware palette index configuration.
Fill Settingssetfillstyle()
Set active tiling bitmaps and colors for solid shape fills like bar and floodfill.
Fill Operationfloodfill()
Use paint bucket boundary fills starting from a seed point inside enclosed coordinate spaces.
Text, Pixels & Setup
Program control and precise drawing
outtextxy()
Draw labels, scores, and captions at exact graphics coordinates using the active text settings.
Pixel Plottingputpixel()
Plot individual pixels for raster algorithms, curves, particles, and custom low-level drawings.
Setupinitgraph()
Start BGI graphics mode, detect a driver, configure the graphics mode, and handle startup errors.
Setupclosegraph()
Close graphics mode cleanly after displaying output, animations, or interactive drawing screens.
Timingdelay()
Pause drawing loops for simple animations, step-by-step demos, and timed screen updates.
Screen Control & Cursor Movement
Viewport refresh and connected path tools
cleardevice()
Clear the full active graphics screen before redrawing a new scene, chart, or animation frame.
Viewport Controlclearviewport()
Clear only the active viewport so panel borders, titles, or outside content can stay visible.
Cursor Movementmoveto()
Reposition the graphics cursor without drawing, so the next connected segment starts exactly where you want.
Connected Linelineto()
Draw from the current cursor point to a new absolute endpoint and continue a connected path.
Relative Linelinerel()
Draw a segment using relative offsets, which is perfect for stepwise patterns and path construction.