This commit is contained in:
2026-08-16 21:18:28 +08:00
parent 9d544c7ba9
commit 3153f7d64f
15 changed files with 387 additions and 200 deletions
+8 -3
View File
@@ -1,11 +1,13 @@
#include "Web_Plot_Session.h"
#include "Pixel_Frame.h"
#include "render_2D/export.h"
#include <renderive/error/Error_Policy.hpp>
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstdint>
#include <mutex>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include <vector>
@@ -64,7 +66,9 @@ struct Web_Plot_Session::Impl {
Impl() {
plot.init();
plot.set_background_color({3, 7, 18, 255});
static_cast<void>(plot.set_max_render_fps(30.0));
if (!plot.set_max_render_fps(30.0))
::renderive::error::unexpected<std::logic_error>(
"validated web plot frame rate was rejected");
plot.set_viewport_size({960, 600});
const auto root = plot.root_renderable();
constexpr Color axis_color{93, 116, 151, 255};
@@ -160,7 +164,7 @@ struct Web_Plot_Session::Impl {
plot.activate_view();
update_model();
const auto initial_render = plot.render_frame(true);
if (initial_render != Plot_Render_Result::none)
if (!initial_render || *initial_render != Plot_Render_Status::rendered)
plot.request_redraw();
}
~Impl() {
@@ -268,7 +272,8 @@ struct Web_Plot_Session::Impl {
if (!plot.view_active())
return std::nullopt;
update_model();
if (plot.render_frame(true) != Plot_Render_Result::none)
const auto render = plot.render_frame(true);
if (!render || *render != Plot_Render_Status::rendered)
return std::nullopt;
std::string pixels;
const Color background = plot.background_color();