bevy/crates
Gagnus 298b01f10d
Adds back in way to convert color to u8 array, implemented for the two RGB color types, also renames Color::linear to Color::to_linear. (#13759)
# Objective

One thing missing from the new Color implementation in 0.14 is the
ability to easily convert to a u8 representation of the rgb color.

(note this is a redo of PR https://github.com/bevyengine/bevy/pull/13739
as I needed to move the source branch

## Solution

I have added to_u8_array and to_u8_array_no_alpha to a new trait called
ColorToPacked to mirror the f32 conversions in ColorToComponents and
implemented the new trait for Srgba and LinearRgba.
To go with those I also added matching from_u8... functions and
converted a couple of cases that used ad-hoc implementations of that
conversion to use these.
After discussion on Discord of the experience of using the API I renamed
Color::linear to Color::to_linear, as without that it looks like a
constructor (like Color::rgb).
I also added to_srgba which is the other commonly converted to type of
color (for UI and 2D) to match to_linear.
Removed a redundant extra implementation of to_f32_array for LinearColor
as it is also supplied in ColorToComponents (I'm surprised that's
allowed?)

## Testing

Ran all tests and manually tested.
Added to_and_from_u8 to linear_rgba::tests

## Changelog

visible change is Color::linear becomes Color::to_linear.

---------

Co-authored-by: John Payne <20407779+johngpayne@users.noreply.github.com>
2024-06-10 13:03:46 +00:00
..
bevy_a11y fix: upgrade to winit v0.30 (#13366) 2024-06-03 13:06:48 +00:00
bevy_animation Make the component types of the new animation players clonable. (#13736) 2024-06-07 21:51:24 +00:00
bevy_app Let init_non_send_resource require FromWorld instead of Default (#13779) 2024-06-10 07:10:52 +00:00
bevy_asset Improve error handling for AssetServer::add_async (#13745) 2024-06-10 12:56:21 +00:00
bevy_audio Update to rodio 0.18 (#13612) 2024-06-02 14:25:51 +00:00
bevy_color Adds back in way to convert color to u8 array, implemented for the two RGB color types, also renames Color::linear to Color::to_linear. (#13759) 2024-06-10 13:03:46 +00:00
bevy_core Determine msrv for every standalone bevy_* crate. (#13211) 2024-05-13 18:26:41 +00:00
bevy_core_pipeline Allow mix of hdr and non-hdr cameras to same render target (#13419) 2024-06-06 20:55:05 +00:00
bevy_derive Deprecate dynamic plugins (#13080) 2024-05-20 20:01:28 +00:00
bevy_dev_tools Move utilities from examples to bevy_state and add concept of state-scoped entities (#13649) 2024-06-04 11:44:34 +00:00
bevy_diagnostic Add README.md to all crates (#13184) 2024-05-02 18:56:00 +00:00
bevy_dylib Add README.md to all crates (#13184) 2024-05-02 18:56:00 +00:00
bevy_dynamic_plugin Deprecate dynamic plugins (#13080) 2024-05-20 20:01:28 +00:00
bevy_ecs Fix EntityCommands::despawn docs (#13774) 2024-06-09 17:59:19 +00:00
bevy_encase_derive Add README.md to all crates (#13184) 2024-05-02 18:56:00 +00:00
bevy_gilrs Add README.md to all crates (#13184) 2024-05-02 18:56:00 +00:00
bevy_gizmos view.inverse_clip_from_world should be world_from_clip (#13756) 2024-06-09 14:40:14 +00:00
bevy_gltf Add labels to Gltf Node and Mesh assets (#13558) 2024-06-05 23:10:33 +00:00
bevy_hierarchy Fix EntityCommands::despawn docs (#13774) 2024-06-09 17:59:19 +00:00
bevy_input flush key_input cache when Bevy loses focus (Adopted) (#13678) 2024-06-05 02:06:47 +00:00
bevy_internal Move state installation methods from bevy_app to bevy_state (#13637) 2024-06-03 13:47:08 +00:00
bevy_log Improve tracing layer customization (#13159) 2024-05-12 21:16:56 +00:00
bevy_macro_utils Add README.md to all crates (#13184) 2024-05-02 18:56:00 +00:00
bevy_math Stable interpolation and smooth following (#13741) 2024-06-10 12:50:59 +00:00
bevy_mikktspace Determine msrv for every standalone bevy_* crate. (#13211) 2024-05-13 18:26:41 +00:00
bevy_pbr Adds back in way to convert color to u8 array, implemented for the two RGB color types, also renames Color::linear to Color::to_linear. (#13759) 2024-06-10 13:03:46 +00:00
bevy_ptr add Debug for ptr types (#13498) 2024-05-24 21:25:11 +00:00
bevy_reflect improved the error message by insert_boxed (issue #13646) (again) (#13706) 2024-06-07 20:56:16 +00:00
bevy_render Add segments to ExtrusionBuilder (#13719) 2024-06-10 12:50:29 +00:00
bevy_scene Align Scene::write_to_world_with to match DynamicScene::write_to_world_with (#13714) 2024-06-10 12:39:35 +00:00
bevy_sprite Adds back in way to convert color to u8 array, implemented for the two RGB color types, also renames Color::linear to Color::to_linear. (#13759) 2024-06-10 13:03:46 +00:00
bevy_state Clear messed up feature flag on AppExitStates impl (#13737) 2024-06-09 13:49:03 +00:00
bevy_tasks fix: upgrade to winit v0.30 (#13366) 2024-06-03 13:06:48 +00:00
bevy_text Uncouple DynamicTextureAtlasBuilder from assets (#13717) 2024-06-08 12:38:03 +00:00
bevy_time Fix minor doc typo (#13776) 2024-06-10 07:15:38 +00:00
bevy_transform Fix links to Transform in Transform and GlobalTransform docs (#13704) 2024-06-06 20:06:54 +00:00
bevy_ui Adds back in way to convert color to u8 array, implemented for the two RGB color types, also renames Color::linear to Color::to_linear. (#13759) 2024-06-10 13:03:46 +00:00
bevy_utils Add mappings to EntityMapper (#13727) 2024-06-08 12:52:23 +00:00
bevy_window rename touchpad to gesture, and add new gestures (#13660) 2024-06-04 12:44:25 +00:00
bevy_winit 13743 app exit hang (#13744) 2024-06-08 21:42:01 +00:00