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
Classes | Namespaces
builders.hpp File Reference

Fluent builder pattern for constructing drawing commands. More...

#include "epaper/core/geometry.hpp"
#include "epaper/draw/commands.hpp"
#include "epaper/draw/styles.hpp"
#include "epaper/graphics/font.hpp"
#include <cstdint>
#include <string>
#include <string_view>
Include dependency graph for builders.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  epaper::LineBuilder
 
class  epaper::RectangleBuilder
 
class  epaper::CircleBuilder
 
class  epaper::PointBuilder
 
class  epaper::TextBuilder
 

Namespaces

namespace  epaper
 

Detailed Description

Fluent builder pattern for constructing drawing commands.

Provides type-safe, expressive builders for all drawing command types. Each builder follows the fluent interface pattern (method chaining) for readable, self-documenting code.

Design Pattern:

Builder Pattern (Fluent Interface)
├─ Default Construction: Provides sensible defaults
├─ Method Chaining: Each setter returns *this for chaining
├─ Type Safety: All parameters statically typed (no stringly-typed APIs)
└─ Finalization: build() produces immutable command struct

Benefits:

Usage Patterns:

// Direct builder usage
auto line_cmd = LineBuilder()
.from({10, 10})
.to({100, 100})
.color(Color::Black)
.build();
display.draw(line_cmd);
// Using Display::line() factory (preferred)
display.draw(
display.line()
.from({10, 10})
.to({100, 100})
.color(Color::Black)
.build()
);
// Style reuse for consistent appearance
LineStyleSpec thick_black{Color::Black, DotPixel::Pixel3x3};
display.draw(display.line().from(a).to(b).with_style(thick_black).build());
display.draw(display.line().from(c).to(d).with_style(thick_black).build());

Implementation Details:

See also
commands.hpp, styles.hpp, Display::line(), Display::rectangle()