-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add color struct #4
base: master
Are you sure you want to change the base?
Conversation
Self::new(r, g, b, 1.0) | ||
} | ||
|
||
swizzle!(r, r, r); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These swizzles will produce vectors instead of colors, we should review whether we want this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think we should rework the swizzle marco to support a specified type
} | ||
|
||
impl_op_ex!(+= |a: &mut Color, b: &Color| { a.r += b.r; a.g += b.g; a.b += b.b; a.a += b.a; }); | ||
impl_op_ex!(-= |a: &mut Color, b: &Color| { a.r -= b.r; a.g -= b.g; a.b -= b.b; a.a -= b.a; }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens when one of the components gets <0 ? The field docs specify the components to be [0.0-1.0]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should allow all ranges, to keep it simple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would probably be the best solution
/// Creates a Color from a hex value. | ||
/// The format of `hex` is `0xBBGGRR`, the MSB is discarded. | ||
/// The `a` component is always set to 1.0. | ||
pub fn from_hex_bgr(hex: u32) -> Self { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the hell would you ever want to use this? I think the selling point of gfx_maths is, that it is being simple. If you really want to have sth like this (I don't see a single use case though), I would implement it via macro.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions cover most of the commonly used rgb pixel formats. E.g. some image formats store their pixels in BBGGRR instead of RRGGBB. I don't want to leave these common use cases unaccounted for.
No description provided.