Have the GenericMaterial be an enum to make it easier to replace the ferromagnet model

This commit is contained in:
2020-08-27 12:51:12 -07:00
parent c68964403d
commit 6ac0dafa47
4 changed files with 152 additions and 95 deletions

View File

@@ -1,6 +1,5 @@
use ansi_term::Color::RGB;
use crate::consts;
use crate::SimState;
use crate::{consts, Material as _, SimState};
use std::fmt::Write as _;
pub struct NumericTermRenderer;
@@ -33,9 +32,9 @@ fn norm_color(v: f64) -> u8 {
(v * 64.0 + 128.0).max(0.0).min(255.0) as u8
}
fn curl(x: f32, y: f32) -> f32 {
fn curl(x: f64, y: f64) -> f64 {
let c = x * y;
if c >= 0f32 {
if c >= 0.0 {
c.sqrt()
} else {
-(-c).sqrt()
@@ -51,14 +50,14 @@ impl ColorTermRenderer {
let cell = state.get(x, y);
//let r = norm_color(cell.bz() * consts::C);
//let r = 0;
let r = norm_color(cell.mat.mz);
let b = (55.0*cell.mat().conductivity).min(255.0) as u8;
let r = norm_color(cell.mat.mz());
let b = (55.0*cell.mat().conductivity()).min(255.0) as u8;
//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).into());
let g = norm_color(cell.ey().into());
let g = norm_color((cell.bz() * 3.0e8).into());
//let g = norm_color(cell.ey().into());
write!(&mut buf, "{}", RGB(r, g, b).paint(square));
}
write!(&mut buf, "\n");