Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
canvas.hpp
1// Copyright (c) 2026 ttldtor.
2// SPDX-License-Identifier: BSL-1.0
3#pragma once
4#include <portals/widget_types.hpp>
5
6namespace portals {
12class Canvas {
13public:
20 Canvas(PaintContext &context, CellRect clip, const GraphemeText *brush = nullptr) noexcept;
26 std::expected<void, TreeError> point(CellPoint position, CellStyle style = {});
34 std::expected<void, TreeError> line(CellPoint first, CellPoint last, CellStyle style = {});
35
36private:
37 PaintContext &context_;
38 CellRect clip_;
39 const GraphemeText *brush_;
40};
41} // namespace portals
Canvas(PaintContext &context, CellRect clip, const GraphemeText *brush=nullptr) noexcept
Borrow a sink and optional one-cell glyph for this frame.
std::expected< void, TreeError > point(CellPoint position, CellStyle style={})
Draw a cell if it is inside the clip.
std::expected< void, TreeError > line(CellPoint first, CellPoint last, CellStyle style={})
Rasterize an inclusive DDA line, rounding ties away from zero, then clip. Only the clip's dominant-ax...
An owning, invariant-preserving half-open cell rectangle.
Definition geometry.hpp:81
Owning validated UTF-8 and immutable extended grapheme measurements.
Definition text.hpp:145
Borrowed synchronous command sink supplied by the frame owner. submit must consume commands immediate...
Definition widget_types.hpp:66
Public Portals API.
Definition action.hpp:8
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition widget_types.hpp:26
An owning value in terminal columns/rows, x right and y down.
Definition geometry.hpp:24
Small owning paint value, independent of themes and text metrics.
Definition cell_buffer.hpp:35