Expand description
CPU rendering backend for FerroChart, built on tiny-skia.
Executes the DrawCmds of a Frame one by one. DrawCmd::Series is expanded
on the CPU with the core’s transform_helpers, the same f32 arithmetic the
wgpu shaders use, so both backends produce the same pixels. Rectangles,
axis-aligned lines and text are drawn without anti-aliasing by direct
source-over blending into the pixmap; only slanted or dashed lines go through
tiny-skia’s anti-aliased stroker.
Uses: golden-image tests, server-side rendering, fallback without a GPU. No performance targets.
§Examples
use ferrochart_core::chart::{SeriesData, SeriesOptions};
use ferrochart_core::frame::SeriesKind;
use ferrochart_core::geom::SizeCss;
use ferrochart_core::render::Renderer;
use ferrochart_core::testing::random_walk;
use ferrochart_core::{Chart, ChartOptions};
use ferrochart_render_cpu::CpuRenderer;
let mut chart = Chart::new(ChartOptions::default());
chart.resize(SizeCss { w: 320.0, h: 200.0 }, 1.0);
let id = chart.add_series(chart.main_pane(), SeriesKind::Candlestick, SeriesOptions::default())?;
chart.set_data(id, SeriesData::Ohlc(random_walk(7, 200, 0, 60_000)?))?;
let mut renderer = CpuRenderer::new();
chart.build_frame(0.0, &renderer.measurer());
renderer.render(chart.frame(), &chart.data_view())?;
assert_eq!(renderer.pixmap().map(|p| p.width()), Some(320));Structs§
- CpuRenderer
- The CPU renderer.
- Engine
Measurer - Adapts a
TextEngineto the core’sTextMeasurer.