libepaper 2.0.0
A C++23 library for controlling Waveshare e-paper displays on Raspberry Pi, featuring transparent sleep/wake management and a fluent builder API.
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
epaper::Graphics Class Reference

#include <graphics.hpp>

Static Public Member Functions

template<FramebufferLike FB>
static auto draw_line (FB &fb, Point start, Point end, LineStyle style, Color color, Orientation orientation) -> void
 Draw a line on the framebuffer.
 
template<FramebufferLike FB>
static auto draw_rectangle (FB &fb, Point top_left, Point bottom_right, LineStyle style, Color color, DrawFill fill, Orientation orientation) -> void
 Draw a rectangle on the framebuffer.
 
template<FramebufferLike FB>
static auto draw_circle (FB &fb, Point center, std::size_t radius, LineStyle style, Color color, DrawFill fill, Orientation orientation) -> void
 Draw a circle on the framebuffer.
 
template<FramebufferLike FB>
static auto draw_text (FB &fb, Point pos, std::string_view text, const Font &font, Color foreground, Color background, Orientation orientation) -> void
 Draw text string on the framebuffer.
 
template<FramebufferLike FB>
static auto draw_bitmap (FB &fb, Point pos, std::span< const std::uint8_t > data, std::size_t w, std::size_t h, std::size_t target_w, std::size_t target_h, Orientation orientation) -> void
 Draw a bitmap on the framebuffer.
 

Member Function Documentation

◆ draw_bitmap()

template<FramebufferLike FB>
auto epaper::Graphics::draw_bitmap ( FB &  fb,
Point  pos,
std::span< const std::uint8_t >  data,
std::size_t  w,
std::size_t  h,
std::size_t  target_w,
std::size_t  target_h,
Orientation  orientation 
) -> void
static

Draw a bitmap on the framebuffer.

Template Parameters
FBFramebufferLike type
Parameters
fbTarget framebuffer
posTop-left position
dataRaw bitmap data
wSource width
hSource height
target_wTarget width (scaling)
target_hTarget height (scaling)
orientationCoordinate orientation
Examples
/mnt/nas/libepaper/include/epaper/core/display.hpp, and /mnt/nas/libepaper/include/epaper/graphics/graphics.hpp.
Here is the caller graph for this function:

◆ draw_circle()

template<FramebufferLike FB>
auto epaper::Graphics::draw_circle ( FB &  fb,
Point  center,
std::size_t  radius,
LineStyle  style,
Color  color,
DrawFill  fill,
Orientation  orientation 
) -> void
static

Draw a circle on the framebuffer.

Midpoint circle algorithm (Bresenham's circle).

Template Parameters
FBFramebufferLike type
Parameters
fbTarget framebuffer
centerCenter point
radiusRadius in pixels
styleBorder style
colorCircle color
fillFill mode
orientationCoordinate orientation

Efficient integer-only circle drawing using 8-way symmetry. Calculates one octant and mirrors to draw all 8 octants simultaneously.

Algorithm Properties:

  • No floating point (no trigonometry, no sqrt)
  • No multiplication in inner loop
  • 8-fold symmetry reduces computations by 87.5%
  • Incremental error calculation

Octant Symmetry: Computing (x, y) for one octant gives 8 points: (±x, ±y) and (±y, ±x)

Fill Implementation: For filled circles, draws horizontal scan lines between symmetric points in each octant, creating solid interior.

Reference: Derived from Bresenham's line algorithm, adapted for circles.

Examples
/mnt/nas/libepaper/include/epaper/core/display.hpp, and /mnt/nas/libepaper/include/epaper/graphics/graphics.hpp.
Here is the caller graph for this function:

◆ draw_line()

template<FramebufferLike FB>
auto epaper::Graphics::draw_line ( FB &  fb,
Point  start,
Point  end,
LineStyle  style,
Color  color,
Orientation  orientation 
) -> void
static

Draw a line on the framebuffer.

Bresenham's line algorithm implementation.

Template Parameters
FBFramebufferLike type
Parameters
fbTarget framebuffer
startStart point
endEnd point
styleLine style (Solid, Dotted, etc.)
colorLine color
orientationCoordinate orientation

Classic integer-only line drawing algorithm. Efficiently determines which pixels to illuminate on a raster display to approximate a straight line between two points.

Algorithm Properties:

  • No floating point arithmetic required
  • No division in inner loop (only initialization)
  • Symmetric - same pixels regardless of direction
  • Works for all octants (0°-360°)

Dotted Line Support:

  • Alternates pixels on/off based on step count
  • Pattern: pixel, skip, pixel, skip, ...

Reference: Bresenham, J. E. (1965). "Algorithm for computer control of a digital plotter". IBM Systems Journal. 4 (1): 25–30.

Examples
/mnt/nas/libepaper/include/epaper/core/display.hpp, and /mnt/nas/libepaper/include/epaper/graphics/graphics.hpp.
Here is the caller graph for this function:

◆ draw_rectangle()

template<FramebufferLike FB>
auto epaper::Graphics::draw_rectangle ( FB &  fb,
Point  top_left,
Point  bottom_right,
LineStyle  style,
Color  color,
DrawFill  fill,
Orientation  orientation 
) -> void
static

Draw a rectangle on the framebuffer.

Rectangle drawing via edge decomposition.

Template Parameters
FBFramebufferLike type
Parameters
fbTarget framebuffer
top_leftTop-left corner
bottom_rightBottom-right corner
styleBorder style
colorRectangle color
fillFill mode
orientationCoordinate orientation

Draws rectangle as 4 separate lines (top, right, bottom, left edges). For filled rectangles, draws horizontal scan lines between left and right edges.

Algorithm:

  1. Draw 4 border lines
  2. If fill requested, draw horizontal lines for interior

Optimization Note: For filled rectangles, could use faster set_pixel loops instead of draw_line, but current approach reuses line drawing logic for consistency.

Examples
/mnt/nas/libepaper/include/epaper/core/display.hpp, and /mnt/nas/libepaper/include/epaper/graphics/graphics.hpp.
Here is the caller graph for this function:

◆ draw_text()

template<FramebufferLike FB>
auto epaper::Graphics::draw_text ( FB &  fb,
Point  pos,
std::string_view  text,
const Font font,
Color  foreground,
Color  background,
Orientation  orientation 
) -> void
static

Draw text string on the framebuffer.

Template Parameters
FBFramebufferLike type
Parameters
fbTarget framebuffer
posTop-left position of text
textText content
fontFont to use
foregroundText color
backgroundBackground color (Color::None for transparent)
orientationCoordinate orientation
Examples
/mnt/nas/libepaper/include/epaper/core/display.hpp, and /mnt/nas/libepaper/include/epaper/graphics/graphics.hpp.
Here is the caller graph for this function:

The documentation for this class was generated from the following file: