use crate::nvg::context::NvgContext;
use crate::nvg::enums::{Solidity, Winding};
pub struct PathBuilder<'a> {
ctx: &'a NvgContext,
}
impl<'a> PathBuilder<'a> {
pub(crate) fn new(ctx: &'a NvgContext) -> Self {
Self { ctx }
}
pub fn move_to(self, x: f32, y: f32) -> Self {
self.ctx.move_to(x, y);
self
}
pub fn line_to(self, x: f32, y: f32) -> Self {
self.ctx.line_to(x, y);
self
}
pub fn bezier_to(self, c1x: f32, c1y: f32, c2x: f32, c2y: f32, x: f32, y: f32) -> Self {
self.ctx.bezier_to(c1x, c1y, c2x, c2y, x, y);
self
}
pub fn quad_to(self, cx: f32, cy: f32, x: f32, y: f32) -> Self {
self.ctx.quad_to(cx, cy, x, y);
self
}
pub fn arc_to(self, x1: f32, y1: f32, x2: f32, y2: f32, radius: f32) -> Self {
self.ctx.arc_to(x1, y1, x2, y2, radius);
self
}
pub fn close(self) -> Self {
self.ctx.close_path();
self
}
pub fn winding(self, dir: Winding) -> Self {
self.ctx.path_winding(dir);
self
}
pub fn solidity(self, sol: Solidity) -> Self {
self.ctx.path_winding(sol.into());
self
}
pub fn rect(self, x: f32, y: f32, w: f32, h: f32) -> Self {
self.ctx.rect(x, y, w, h);
self
}
pub fn rounded_rect(self, x: f32, y: f32, w: f32, h: f32, r: f32) -> Self {
self.ctx.rounded_rect(x, y, w, h, r);
self
}
pub fn circle(self, cx: f32, cy: f32, r: f32) -> Self {
self.ctx.circle(cx, cy, r);
self
}
pub fn ellipse(self, cx: f32, cy: f32, rx: f32, ry: f32) -> Self {
self.ctx.ellipse(cx, cy, rx, ry);
self
}
pub fn arc(self, cx: f32, cy: f32, r: f32, a0: f32, a1: f32, dir: Winding) -> Self {
self.ctx.arc(cx, cy, r, a0, a1, dir);
self
}
}