Skip to main content

agg_rust/
conv_smooth_poly1.rs

1//! Smooth polygon converter.
2//!
3//! Port of `agg_conv_smooth_poly1.h` wrapper around `VcgenSmoothPoly1`.
4
5use crate::basics::VertexSource;
6use crate::conv_adaptor_vcgen::ConvAdaptorVcgen;
7use crate::vcgen_smooth_poly1::VcgenSmoothPoly1;
8
9/// Port of C++ `conv_smooth_poly1<VertexSource>`.
10pub struct ConvSmoothPoly1<VS: VertexSource> {
11    base: ConvAdaptorVcgen<VS, VcgenSmoothPoly1>,
12}
13
14impl<VS: VertexSource> ConvSmoothPoly1<VS> {
15    pub fn new(source: VS) -> Self {
16        Self {
17            base: ConvAdaptorVcgen::new(source, VcgenSmoothPoly1::new()),
18        }
19    }
20
21    pub fn set_smooth_value(&mut self, v: f64) {
22        self.base.generator_mut().set_smooth_value(v);
23    }
24
25    pub fn smooth_value(&self) -> f64 {
26        self.base.generator().smooth_value()
27    }
28
29    pub fn source(&self) -> &VS {
30        self.base.source()
31    }
32
33    pub fn source_mut(&mut self) -> &mut VS {
34        self.base.source_mut()
35    }
36}
37
38impl<VS: VertexSource> VertexSource for ConvSmoothPoly1<VS> {
39    fn rewind(&mut self, path_id: u32) {
40        self.base.rewind(path_id);
41    }
42
43    fn vertex(&mut self, x: &mut f64, y: &mut f64) -> u32 {
44        self.base.vertex(x, y)
45    }
46}