Render just the B field: it gives a better visualization here

This commit is contained in:
2020-07-24 23:39:07 -07:00
parent 2e92980113
commit 1d9aa738ac
2 changed files with 18 additions and 3 deletions

View File

@@ -33,6 +33,15 @@ fn norm_color(v: f32) -> u8 {
(v * 64.0 + 128.0).max(0f32).min(255f32) as u8
}
fn curl(x: f32, y: f32) -> f32 {
let c = x * y;
if c >= 0f32 {
c.sqrt()
} else {
-(-c).sqrt()
}
}
impl ColorTermRenderer {
pub fn render(&self, state: &SimState) {
let mut buf = String::new();
@@ -42,8 +51,11 @@ impl ColorTermRenderer {
let cell = state.get(x, y);
//let r = norm_color(cell.bz() * consts::C);
let r = 0;
let g = norm_color(cell.ex());
let b = norm_color(cell.ey());
let b = 0;
//let g = norm_color(cell.ex());
//let b = norm_color(cell.ey());
//let g = norm_color(curl(cell.ex(), cell.ey()));
let g = norm_color(cell.bz() * 3.0e8);
write!(&mut buf, "{}", RGB(r, g, b).paint(square));
}
write!(&mut buf, "\n");