Bezier curves in graph
This commit is contained in:
parent
1ae3e520c1
commit
eac140b26f
@ -41,6 +41,20 @@ pub(crate) fn draw_plot(
|
||||
),
|
||||
time2color(current.1),
|
||||
);
|
||||
let x_mid = gradient_f32(start.0.x, end.0.x, 0.5);
|
||||
let start_bezier = Pos2::new(x_mid, start.0.y);
|
||||
let end_bezier = Pos2::new(x_mid, end.0.y);
|
||||
|
||||
let bezier_calc = |ratio: f32| {
|
||||
let p_0_0 = gradient_pos(start.0, start_bezier, ratio);
|
||||
let p_0_1 = gradient_pos(start_bezier, end_bezier, ratio);
|
||||
let p_0_2 = gradient_pos(end_bezier, end.0, ratio);
|
||||
|
||||
let p_1_0 = gradient_pos(p_0_0, p_0_1, ratio);
|
||||
let p_1_1 = gradient_pos(p_0_1, p_0_2, ratio);
|
||||
|
||||
return gradient_pos(p_1_0, p_1_1, ratio);
|
||||
};
|
||||
|
||||
for j in 0..(gradient_precision) {
|
||||
let gradient_precision = gradient_precision as f32;
|
||||
@ -48,8 +62,8 @@ pub(crate) fn draw_plot(
|
||||
let ratio2 = (j as f32 + 1.0) / gradient_precision;
|
||||
canvas.line_segment(
|
||||
[
|
||||
gradient_pos(start.0, end.0, ratio1),
|
||||
gradient_pos(start.0, end.0, ratio2),
|
||||
bezier_calc(ratio1),
|
||||
bezier_calc(ratio2),
|
||||
],
|
||||
Stroke::new(1.0, gradient_color(start.1, end.1, ratio1)),
|
||||
);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user