1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Color conversion between cotis and wgpu representations.
//!
//! Cotis [`cotis_defaults::colors::Color`] stores each channel as `f32` in the `0..=255`
//! range. This module normalizes channels to `0.0..=1.0` for GPU use.
//!
//! **Alpha handling differs by consumer:**
//!
//! - [`cotis_color_to_ui_color`] — RGB only; used by the UI geometry pipeline, which forces
//! opaque fragments in the WGSL shader.
//! - [`cotis_color_to_wgpu`] — full RGBA; suitable for swapchain clear colors and
//! [`crate::renderer::CotisWgpuRenderer::set_background`].
//! - Text rendering converts cotis colors to glyphon `Color` with rounded `u8` channels,
//! preserving alpha.
use Color;
use crateUIColor;
/// Converts a cotis RGBA color (0..255 per channel) into normalized GPU color components.
///
/// Alpha is omitted because the UI geometry shader outputs opaque fragments.
///
/// # Examples
///
/// ```
/// use cotis_defaults::colors::Color;
/// use cotis_wgpu::color::cotis_color_to_ui_color;
///
/// let ui = cotis_color_to_ui_color(Color::rgba(255.0, 255.0, 255.0, 255.0));
/// assert!((ui.r - 1.0).abs() < f32::EPSILON);
/// assert!((ui.g - 1.0).abs() < f32::EPSILON);
/// assert!((ui.b - 1.0).abs() < f32::EPSILON);
/// ```
/// Converts a cotis RGBA color into a wgpu clear/present color (0.0..=1.0 per channel).
///
/// Use this when setting the swapchain background via
/// [`crate::renderer::CotisWgpuRenderer::set_background`] or during renderer construction.