Skip to content

Commit 07374a2

Browse files
committed
--wip-- [skip ci]
1 parent c9b2eed commit 07374a2

File tree

1 file changed

+32
-7
lines changed

1 file changed

+32
-7
lines changed

debug-tools/examples/line-perp.rs

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ fn x_perpendicular(
105105
core::mem::swap(&mut width_l, &mut width_r);
106106
}
107107

108+
let orig_width_l = width_l as f32;
109+
let orig_width_r = width_r as f32;
110+
108111
let width_l = width_l.pow(2) * (dx * dx + dy * dy);
109112
let width_r = width_r.pow(2) * (dx * dx + dy * dy);
110113

@@ -116,13 +119,35 @@ fn x_perpendicular(
116119

117120
let (c1, c2) = (Rgb565::GREEN, Rgb565::GREEN);
118121

119-
while tk.pow(2) <= width_l + tk.pow(2) && width_l > 0 {
120-
let thing = (tk.pow(2) - width_l) as f32 / width_l as f32;
121-
let fract = if tk.pow(2) > width_l {
122-
1.0 - thing
123-
} else {
124-
1.0
125-
};
122+
let mut dist = 0.0f32;
123+
124+
while tk.pow(2) <= width_l * 4 && width_l > 0 {
125+
// while dist.floor() <= orig_width_l && width_l > 0 {
126+
// let thing = (tk.pow(2) - width_l) as f32 / width_l as f32;
127+
// let fract = if tk.pow(2) > width_l {
128+
// 1.0 - thing
129+
// } else {
130+
// 1.0
131+
// };
132+
let distance = tk as f32 / f32::sqrt(width_l as f32);
133+
let fract = distance;
134+
135+
// dist = f32::sqrt(((point.x - x0).pow(2) as f32) + ((point.y - y0).pow(2) as f32));
136+
// let fract = if dist > orig_width_l {
137+
// (orig_width_l - dist).max(0.0)
138+
// } else {
139+
// dist
140+
// };
141+
142+
let dist = width_l - tk.pow(2);
143+
dbg!(dist, (dist as f32 / width_l as f32));
144+
145+
// let fract = dist.clamp(0.0, 1.0);
146+
147+
// Debug: Clamp at non-black colour
148+
let fract = (dist as f32 / width_l as f32).max(0.2);
149+
150+
// Pixel(point, Rgb565::RED).draw(display)?;
126151

127152
Pixel(
128153
point,

0 commit comments

Comments
 (0)