// Generated by mix skia.codegen. Do not edit by hand.
fn draw_path_impl<'a>(
canvas: &skia_safe::Canvas,
args: Vec<Term<'a>>,
opts: generated_opts::PathOpts<'a>,
raw_opts: &[(Atom, Term<'a>)],
) -> NifResult<()> {
let mut path = build_path(*args.first().ok_or(rustler::Error::BadArg)?)?;
apply_fill_rule(&mut path, raw_opts)?;
if let Some(fill) = opts.fill {
let mut paint = decode_paint(fill)?;
apply_blend_mode(&mut paint, raw_opts)?;
canvas.draw_path(&path, &paint);
}
if let Some(stroke) = opts.stroke {
canvas
.draw_path(
&path,
&stroke_paint(
decode_color(stroke)?,
opts.stroke_width.unwrap_or(1.0),
raw_opts,
)?,
);
}
Ok(())
}
fn draw_path_op_impl<'a>(
canvas: &skia_safe::Canvas,
args: Vec<Term<'a>>,
opts: generated_opts::PathOpOpts<'a>,
raw_opts: &[(Atom, Term<'a>)],
) -> NifResult<()> {
let a = build_path(*args.first().ok_or(rustler::Error::BadArg)?)?;
let b = build_path(*args.get(1).ok_or(rustler::Error::BadArg)?)?;
let op = generated_enums::decode_path_op(opts.path_op)?;
let mut path = a.op(&b, op).ok_or(rustler::Error::BadArg)?;
apply_fill_rule(&mut path, raw_opts)?;
if let Some(fill) = opts.fill {
let mut paint = decode_paint(fill)?;
apply_blend_mode(&mut paint, raw_opts)?;
canvas.draw_path(&path, &paint);
}
if let Some(stroke) = opts.stroke {
canvas
.draw_path(
&path,
&stroke_paint(
decode_color(stroke)?,
opts.stroke_width.unwrap_or(1.0),
raw_opts,
)?,
);
}
Ok(())
}
fn draw_path_outline_impl<'a>(
canvas: &skia_safe::Canvas,
args: Vec<Term<'a>>,
opts: generated_opts::PathOutlineOpts<'a>,
raw_opts: &[(Atom, Term<'a>)],
) -> NifResult<()> {
let path = build_path(*args.first().ok_or(rustler::Error::BadArg)?)?;
let mut stroke = Paint::default();
stroke
.set_anti_alias(true)
.set_style(PaintStyle::Stroke)
.set_stroke_width(opts.outline_width);
apply_stroke_options(&mut stroke, raw_opts)?;
let mut builder = PathBuilder::new();
if !path_utils::fill_path_with_paint(&path, &stroke, &mut builder, None, None) {
return Ok(());
}
let mut outline = builder.detach();
apply_fill_rule(&mut outline, raw_opts)?;
if let Some(fill) = opts.fill {
let mut paint = decode_paint(fill)?;
apply_blend_mode(&mut paint, raw_opts)?;
canvas.draw_path(&outline, &paint);
} else {
if let Some(stroke_color) = opts.stroke {
let mut paint = fill_paint(decode_color(stroke_color)?);
apply_blend_mode(&mut paint, raw_opts)?;
canvas.draw_path(&outline, &paint);
}
}
Ok(())
}