Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 213 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions tellur-core/src/color.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
use std::hash::{Hash, Hasher};

use crate::dyn_compare::hash_f32;

/// sRGB with straight alpha. Each component is in the range `[0.0, 1.0]`.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Color {
Expand All @@ -7,6 +11,15 @@ pub struct Color {
pub a: f32,
}

impl Hash for Color {
fn hash<H: Hasher>(&self, state: &mut H) {
hash_f32(self.r, state);
hash_f32(self.g, state);
hash_f32(self.b, state);
hash_f32(self.a, state);
}
}

impl Color {
/// Opaque color from 8-bit sRGB components.
pub const fn rgb_u8(r: u8, g: u8, b: u8) -> Self {
Expand Down
Loading
Loading