pub struct PathStorage { /* private fields */ }Expand description
Path storage — the main vertex container.
Stores an ordered sequence of vertices, each with an (x, y) coordinate and
a path command. Supports multiple sub-paths separated by move_to or stop
commands. Implements VertexSource for use in the rendering pipeline.
Port of C++ agg::path_storage (typedef for path_base<vertex_block_storage<double>>).
Implementations§
Source§impl PathStorage
impl PathStorage
Sourcepub fn remove_all(&mut self)
pub fn remove_all(&mut self)
Remove all vertices (keeps allocated memory).
Sourcepub fn start_new_path(&mut self) -> usize
pub fn start_new_path(&mut self) -> usize
Begin a new sub-path. If the last command is not stop,
inserts a stop command first. Returns the index where the
new path will start.
Sourcepub fn add_vertex(&mut self, x: f64, y: f64, cmd: u32)
pub fn add_vertex(&mut self, x: f64, y: f64, cmd: u32)
Add a vertex with an explicit command.
Port of C++ path_storage::add_vertex(x, y, cmd).
Sourcepub fn arc_to(
&mut self,
rx: f64,
ry: f64,
angle: f64,
large_arc_flag: bool,
sweep_flag: bool,
x: f64,
y: f64,
)
pub fn arc_to( &mut self, rx: f64, ry: f64, angle: f64, large_arc_flag: bool, sweep_flag: bool, x: f64, y: f64, )
Add an SVG-style arc_to command.
Sourcepub fn arc_rel(
&mut self,
rx: f64,
ry: f64,
angle: f64,
large_arc_flag: bool,
sweep_flag: bool,
dx: f64,
dy: f64,
)
pub fn arc_rel( &mut self, rx: f64, ry: f64, angle: f64, large_arc_flag: bool, sweep_flag: bool, dx: f64, dy: f64, )
Add a relative SVG-style arc_to command.
Sourcepub fn curve3(&mut self, x_ctrl: f64, y_ctrl: f64, x_to: f64, y_to: f64)
pub fn curve3(&mut self, x_ctrl: f64, y_ctrl: f64, x_to: f64, y_to: f64)
Add a quadratic Bezier curve (curve3) with explicit control point.
Sourcepub fn curve3_rel(&mut self, dx_ctrl: f64, dy_ctrl: f64, dx_to: f64, dy_to: f64)
pub fn curve3_rel(&mut self, dx_ctrl: f64, dy_ctrl: f64, dx_to: f64, dy_to: f64)
Add a relative quadratic Bezier curve with explicit control point.
Sourcepub fn curve3_smooth(&mut self, x_to: f64, y_to: f64)
pub fn curve3_smooth(&mut self, x_to: f64, y_to: f64)
Add a smooth quadratic Bezier curve (reflected control point).
Sourcepub fn curve3_smooth_rel(&mut self, dx_to: f64, dy_to: f64)
pub fn curve3_smooth_rel(&mut self, dx_to: f64, dy_to: f64)
Add a relative smooth quadratic Bezier curve.
Sourcepub fn curve4(
&mut self,
x_ctrl1: f64,
y_ctrl1: f64,
x_ctrl2: f64,
y_ctrl2: f64,
x_to: f64,
y_to: f64,
)
pub fn curve4( &mut self, x_ctrl1: f64, y_ctrl1: f64, x_ctrl2: f64, y_ctrl2: f64, x_to: f64, y_to: f64, )
Add a cubic Bezier curve (curve4) with two explicit control points.
Sourcepub fn curve4_rel(
&mut self,
dx_ctrl1: f64,
dy_ctrl1: f64,
dx_ctrl2: f64,
dy_ctrl2: f64,
dx_to: f64,
dy_to: f64,
)
pub fn curve4_rel( &mut self, dx_ctrl1: f64, dy_ctrl1: f64, dx_ctrl2: f64, dy_ctrl2: f64, dx_to: f64, dy_to: f64, )
Add a relative cubic Bezier curve with two explicit control points.
Sourcepub fn curve4_smooth(
&mut self,
x_ctrl2: f64,
y_ctrl2: f64,
x_to: f64,
y_to: f64,
)
pub fn curve4_smooth( &mut self, x_ctrl2: f64, y_ctrl2: f64, x_to: f64, y_to: f64, )
Add a smooth cubic Bezier curve (reflected first control point).
Sourcepub fn curve4_smooth_rel(
&mut self,
dx_ctrl2: f64,
dy_ctrl2: f64,
dx_to: f64,
dy_to: f64,
)
pub fn curve4_smooth_rel( &mut self, dx_ctrl2: f64, dy_ctrl2: f64, dx_to: f64, dy_to: f64, )
Add a relative smooth cubic Bezier curve.
Sourcepub fn close_polygon(&mut self, flags: u32)
pub fn close_polygon(&mut self, flags: u32)
Close the current polygon.
Sourcepub fn total_vertices(&self) -> usize
pub fn total_vertices(&self) -> usize
Total number of vertices stored.
Sourcepub fn vertices(&self) -> &[VertexD] ⓘ
pub fn vertices(&self) -> &[VertexD] ⓘ
Immutable access to the raw vertex slice.
Useful when you need to iterate or cache path data without going through
the mutable VertexSource iterator protocol. The slice is valid for the
lifetime of the PathStorage.
Sourcepub fn rel_to_abs(&self, x: &mut f64, y: &mut f64)
pub fn rel_to_abs(&self, x: &mut f64, y: &mut f64)
Convert relative coordinates to absolute by adding last vertex position.
Sourcepub fn last_vertex_xy(&self, x: &mut f64, y: &mut f64) -> u32
pub fn last_vertex_xy(&self, x: &mut f64, y: &mut f64) -> u32
Get the last vertex’s (x, y) and command. Returns PATH_CMD_STOP if empty.
Sourcepub fn prev_vertex_xy(&self, x: &mut f64, y: &mut f64) -> u32
pub fn prev_vertex_xy(&self, x: &mut f64, y: &mut f64) -> u32
Get the second-to-last vertex’s (x, y) and command.
Sourcepub fn last_command(&self) -> u32
pub fn last_command(&self) -> u32
Get the last command (or PATH_CMD_STOP if empty).
Sourcepub fn vertex_idx(&self, idx: usize, x: &mut f64, y: &mut f64) -> u32
pub fn vertex_idx(&self, idx: usize, x: &mut f64, y: &mut f64) -> u32
Get a vertex by index. Returns the command.
Sourcepub fn modify_vertex(&mut self, idx: usize, x: f64, y: f64)
pub fn modify_vertex(&mut self, idx: usize, x: f64, y: f64)
Modify a vertex’s coordinates.
Sourcepub fn modify_vertex_cmd(&mut self, idx: usize, x: f64, y: f64, cmd: u32)
pub fn modify_vertex_cmd(&mut self, idx: usize, x: f64, y: f64, cmd: u32)
Modify a vertex’s coordinates and command.
Sourcepub fn modify_command(&mut self, idx: usize, cmd: u32)
pub fn modify_command(&mut self, idx: usize, cmd: u32)
Modify only a vertex’s command.
Sourcepub fn swap_vertices(&mut self, v1: usize, v2: usize)
pub fn swap_vertices(&mut self, v1: usize, v2: usize)
Swap two vertices (coordinates and commands).
Sourcepub fn concat_path(&mut self, vs: &mut dyn VertexSource, path_id: u32)
pub fn concat_path(&mut self, vs: &mut dyn VertexSource, path_id: u32)
Concatenate all vertices from a vertex source as-is.
Sourcepub fn join_path(&mut self, vs: &mut dyn VertexSource, path_id: u32)
pub fn join_path(&mut self, vs: &mut dyn VertexSource, path_id: u32)
Join a vertex source to the existing path (pen stays down).
The first move_to of the joined path is converted to line_to if the current path already has a vertex endpoint.
Sourcepub fn concat_poly(&mut self, data: &[f64], closed: bool)
pub fn concat_poly(&mut self, data: &[f64], closed: bool)
Concatenate a polygon from flat coordinate data.
Sourcepub fn join_poly(&mut self, data: &[f64], closed: bool)
pub fn join_poly(&mut self, data: &[f64], closed: bool)
Join a polygon from flat coordinate data.
Sourcepub fn invert_polygon(&mut self, start: usize)
pub fn invert_polygon(&mut self, start: usize)
Invert the polygon starting at start.
Sourcepub fn arrange_polygon_orientation(
&mut self,
start: usize,
orientation: u32,
) -> usize
pub fn arrange_polygon_orientation( &mut self, start: usize, orientation: u32, ) -> usize
Arrange polygon orientation for a single polygon starting at start.
Returns the index past the end of the polygon.
Sourcepub fn arrange_orientations(&mut self, start: usize, orientation: u32) -> usize
pub fn arrange_orientations(&mut self, start: usize, orientation: u32) -> usize
Arrange orientations of all polygons in a sub-path.
Sourcepub fn arrange_orientations_all_paths(&mut self, orientation: u32)
pub fn arrange_orientations_all_paths(&mut self, orientation: u32)
Arrange orientations of all polygons in all paths.
Sourcepub fn translate(&mut self, dx: f64, dy: f64, path_id: usize)
pub fn translate(&mut self, dx: f64, dy: f64, path_id: usize)
Translate vertices starting from path_id until a stop command.
Sourcepub fn translate_all_paths(&mut self, dx: f64, dy: f64)
pub fn translate_all_paths(&mut self, dx: f64, dy: f64)
Translate all vertices in all paths.
Sourcepub fn transform<F: Fn(f64, f64) -> (f64, f64)>(
&mut self,
trans: &F,
path_id: usize,
)
pub fn transform<F: Fn(f64, f64) -> (f64, f64)>( &mut self, trans: &F, path_id: usize, )
Transform vertices starting from path_id using a closure.
Sourcepub fn transform_all_paths<F: Fn(f64, f64) -> (f64, f64)>(&mut self, trans: &F)
pub fn transform_all_paths<F: Fn(f64, f64) -> (f64, f64)>(&mut self, trans: &F)
Transform all vertices in all paths using a closure.
Sourcepub fn align_path(&mut self, idx: usize) -> usize
pub fn align_path(&mut self, idx: usize) -> usize
Align a single path so that nearly-equal start/end points become exact. Returns the index past the end of this path.
Sourcepub fn align_all_paths(&mut self)
pub fn align_all_paths(&mut self)
Align all paths.
Trait Implementations§
Source§impl Clone for PathStorage
impl Clone for PathStorage
Source§fn clone(&self) -> PathStorage
fn clone(&self) -> PathStorage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more