build.rs 386 B

1234567891011121314151617181920
  1. use std::{
  2. env::var,
  3. f32::consts::TAU,
  4. fs::File,
  5. io::{Result, Write},
  6. path::PathBuf
  7. };
  8. fn main() -> Result<()> {
  9. let mut path = PathBuf::from(var("OUT_DIR")
  10. .expect("Cargo didn't set OUT_DIR"));
  11. path.push("normals.rs");
  12. let mut f = File::create(path)?;
  13. f.write_all(b"[0.0,")?;
  14. for n in 1..256 {
  15. write!(f, "{},", (n as f32 / 255.0 * TAU).sin())?;
  16. }
  17. f.write_all(b"]")
  18. }