https://github.com/hatoo/blackbody
Temperature to blackbody color
https://github.com/hatoo/blackbody
Last synced: about 1 year ago
JSON representation
Temperature to blackbody color
- Host: GitHub
- URL: https://github.com/hatoo/blackbody
- Owner: hatoo
- License: mit
- Created: 2022-01-06T11:37:23.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-01-06T11:50:46.000Z (over 4 years ago)
- Last Synced: 2025-06-15T18:56:28.765Z (about 1 year ago)
- Language: Rust
- Homepage:
- Size: 11.7 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# blackbody
[](https://crates.io/crates/blackbody)
Blackbody simply provides functions that convert temperature into color.
Codes are ported from [pbrt-v3](https://github.com/mmp/pbrt-v3).
```rust
use blackbody::{temperature_to_rgb, temperature_to_xyz};
fn main() {
// Convert temperatue (Kelvin) into RGB color whose components are [0.0, 1.0].
dbg!(temperature_to_rgb(3000.0));
// Convert temperatue (Kelvin) into XYZ color whose components are [0.0, 1.0].
dbg!(temperature_to_xyz(3000.0));
}
```
```text
[examples\example.rs:4] temperature_to_rgb(3000.0) = [
0.73506474,
0.3504873,
0.112983376,
]
[examples\example.rs:5] temperature_to_xyz(3000.0) = [
0.44889182,
0.4151354,
0.16
]
```