Skip to content

Commit 1f77261

Browse files
committed
fix issue with polygon draw fill
1 parent dbf3565 commit 1f77261

1 file changed

Lines changed: 38 additions & 34 deletions

File tree

src/entry/entry_plot_elements.rs

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ pub fn entry_create_plot_elements_async<T: EvalexprFloat>(
227227
style,
228228
fill_rule,
229229
implicit_resolution,
230-
fill_alpha,
230+
fill_alpha,
231231
..
232232
} => {
233233
let default_color =
@@ -274,8 +274,12 @@ pub fn entry_create_plot_elements_async<T: EvalexprFloat>(
274274
}),
275275
});
276276
};
277-
let fill_color =
278-
Color32::from_rgba_unmultiplied(default_color.r(), default_color.g(), default_color.b(), (default_color.a() as f32 * fill_alpha.to_f32()) as u8);
277+
let fill_color = Color32::from_rgba_unmultiplied(
278+
default_color.r(),
279+
default_color.g(),
280+
default_color.b(),
281+
(default_color.a() as f32 * fill_alpha.to_f32()) as u8,
282+
);
279283

280284
if let Some(expr_func) = &func.expr_function {
281285
if func.args.is_empty() {
@@ -451,7 +455,7 @@ pub fn entry_create_plot_elements_async<T: EvalexprFloat>(
451455
&mut add_line,
452456
&mut add_egui_plot_mesh,
453457
color,
454-
fill_alpha.to_f32(),
458+
fill_alpha.to_f32(),
455459
)?;
456460
}
457461
}
@@ -510,7 +514,12 @@ pub fn entry_create_plot_elements_sync<T: EvalexprFloat>(
510514
&& points_len > 2
511515
&& let Some(plot_trans) = &plot_params.prev_plot_transform
512516
{
513-
let fill_color = Color32::from_rgba_unmultiplied(color.r(), color.g(), color.b(), (color.a() as f32 * style.fill_alpha.to_f32() ) as u8);
517+
let fill_color = Color32::from_rgba_unmultiplied(
518+
color.r(),
519+
color.g(),
520+
color.b(),
521+
(color.a() as f32 * style.fill_alpha.to_f32()) as u8,
522+
);
514523
Some((FillMesh::new(fill_color, style.fill_rule), plot_trans))
515524
} else {
516525
None
@@ -624,40 +633,35 @@ pub fn entry_create_plot_elements_sync<T: EvalexprFloat>(
624633
}
625634

626635
// let width = if selected { 3.5 } else { 1.0 };
627-
let width = 1.0;
628636

629-
if line_buffer.len() > 1 && style.show_lines {
630-
if style.connect_first_and_last {
631-
line_buffer.push(line_buffer[0]);
632-
}
633-
// let line = Line::new(name.to_string(), line_buffer)
634-
// .color(color)
635-
// .id(egui_id)
636-
// .width(style.line_style.line_width)
637-
// .allow_hover(style.line_style.selectable)
638-
// .style(style.line_style.egui_line_style());
639-
draw_buffer.lines.push(DrawLine2::new(
640-
sorting_idx,
641-
egui_id,
642-
name.to_string(),
643-
style.line_style.selectable,
644-
width,
645-
style.line_style.egui_line_style(),
646-
color,
647-
line_buffer,
648-
));
649-
if !arrow_buffer.is_empty() {
650-
draw_buffer.polygons.push(DrawPolygonGroup::new(
637+
if line_buffer.len() > 1 {
638+
if style.show_lines {
639+
if style.connect_first_and_last {
640+
line_buffer.push(line_buffer[0]);
641+
}
642+
643+
draw_buffer.lines.push(DrawLine2::new(
651644
sorting_idx,
645+
egui_id,
646+
name.to_string(),
647+
style.line_style.selectable,
648+
style.line_style.line_width,
649+
style.line_style.egui_line_style(),
652650
color,
653-
Stroke::new(0.0, color),
654-
arrow_buffer,
651+
line_buffer,
655652
));
653+
if !arrow_buffer.is_empty() {
654+
draw_buffer.polygons.push(DrawPolygonGroup::new(
655+
sorting_idx,
656+
color,
657+
Stroke::new(0.0, color),
658+
arrow_buffer,
659+
));
660+
}
656661
}
657-
if let Some((fill_mesh, _)) = fill_mesh {
658-
draw_buffer.meshes.push(DrawMesh { ty: DrawMeshType::FillMesh(fill_mesh) });
659-
}
660-
// plot_ui.line(line);
662+
}
663+
if let Some((fill_mesh, _)) = fill_mesh {
664+
draw_buffer.meshes.push(DrawMesh { ty: DrawMeshType::FillMesh(fill_mesh) });
661665
}
662666
},
663667
}

0 commit comments

Comments
 (0)