#pragma once #include "../base/Types.h" #include #include #include #include namespace renderive::detail { class Blend2D_Color_Cache final : public ::Color_Cache { public: Blend2D_Color_Cache() = default; explicit Blend2D_Color_Cache(std::pmr::memory_resource&) {} void clear() override; void composite(const ::Color_Cache& source) override; void ensure_size(Size size); [[nodiscard]] Size size() const noexcept; [[nodiscard]] Image_View view() const noexcept; private: friend class Painter; BLImage image_; }; class Painter { public: Painter(Blend2D_Color_Cache& cache, Size size); ~Painter(); Painter(const Painter&) = delete; Painter& operator=(const Painter&) = delete; [[nodiscard]] explicit operator bool() const noexcept { return active_; } void line(PointF first, PointF second, const Pen& pen); void polyline(std::span points, const Pen& pen); void polygon(std::span points, const Pen& pen, const Brush& brush); void rect(RectF rect, const Pen& pen, const Brush& brush = {}); void circle(PointF center, double radius, const Pen& pen, const Brush& brush = {}); void text(PointF position, std::string_view value, const Font& font, const Pen& pen, double rotation_degrees = 0.0); void heatmap(RectF target, int width, int height, std::span pixels, Image_Interpolation_Mode interpolation); private: void apply_pen(const Pen& pen); static BLRgba rgba(Color color) noexcept; static BLFont make_font(const Font& font); BLContext context_; bool active_{}; }; } // namespace renderive::detail