1use crate::prelude::*;
2use crate::{Matrix, Paint, Path, Rect};
3use skia_bindings as sb;
4
5/// Returns the filled equivalent of the stroked path.
6///
7/// * `src` - [`Path`] read to create a filled version
8/// * `paint` - [`Paint`], from which attributes such as stroke cap, width, miter, and join,
9/// as well as `path_effect` will be used.
10/// * `dst` - resulting [`Path`]
11/// * `cull_rect` - optional limit passed to [`crate::PathEffect`]
12/// * `matrix` - if scale > 1, increase precision, else if (0 < scale < 1) reduce precision
13/// to favor speed and size
14/// Returns: `true` if the dst path was updated, `false` if it was not (e.g. if the path
15/// represents hairline and cannot be filled).
16pub fn fill_path_with_paint<'a>(
17 src: &Path,
18 paint: &Paint,
19 dst: &mut Path,
20 cull_rect: impl Into<Option<&'a Rect>>,
21 matrix: impl Into<Option<Matrix>>,
22) -> bool {
23 let cull_rect: Option<&'a Rect> = cull_rect.into();
24 let matrix = matrix.into().unwrap_or(Matrix::scale((1.0, 1.0)));
25
26 unsafe {
27 sb::C_PathUtils_FillPathWithPaint(
28 src:src.native(),
29 paint:paint.native(),
30 dst:dst.native_mut(),
31 cullRect:cull_rect.native_ptr_or_null(),
32 matrix:matrix.native(),
33 )
34 }
35}
36