From 18889450d1bfee725278a26e9c0b9a77a5538b54 Mon Sep 17 00:00:00 2001 From: Bruce Mitchener Date: Wed, 4 Dec 2024 20:03:04 +0700 Subject: [PATCH] Use CSS palette more for basic colors These are exact matches for CSS colors, so use them instead. --- examples/scenes/src/test_scenes.rs | 42 +++++++++++++++--------------- examples/with_winit/src/stats.rs | 4 +-- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/examples/scenes/src/test_scenes.rs b/examples/scenes/src/test_scenes.rs index ebf0a2fe..85845020 100644 --- a/examples/scenes/src/test_scenes.rs +++ b/examples/scenes/src/test_scenes.rs @@ -138,28 +138,28 @@ mod impls { scene.fill( Fill::NonZero, Affine::translate((100.0, 100.0)), - Color::from_rgba8(0, 0, 255, 255), + palette::css::BLUE, None, &missing_movetos, ); scene.fill( Fill::NonZero, Affine::IDENTITY, - Color::from_rgba8(0, 0, 255, 255), + palette::css::BLUE, None, &empty, ); scene.fill( Fill::NonZero, Affine::IDENTITY, - Color::from_rgba8(0, 0, 255, 255), + palette::css::BLUE, None, &only_movetos, ); scene.stroke( &Stroke::new(8.0), Affine::translate((100.0, 100.0)), - Color::from_rgba8(0, 255, 255, 255), + palette::css::AQUA, None, &missing_movetos, ); @@ -564,7 +564,7 @@ mod impls { scene.fill( Fill::NonZero, t, - &Brush::Solid(Color::from_rgba8(128, 128, 128, 255)), + palette::css::GRAY, None, &rect, ); @@ -586,7 +586,7 @@ mod impls { scene.fill( Fill::NonZero, t, - &Brush::Solid(Color::from_rgba8(128, 128, 128, 255)), + palette::css::GRAY, None, &rect, ); @@ -686,7 +686,7 @@ mod impls { scene.fill( Fill::NonZero, Affine::IDENTITY, - &Brush::Solid(Color::from_rgba8(128, 128, 128, 255)), + palette::css::GRAY, None, &rect, ); @@ -734,7 +734,7 @@ mod impls { scene.stroke( &Stroke::new(5.0), Affine::IDENTITY, - &Brush::Solid(Color::from_rgba8(128, 0, 0, 255)), + palette::css::MAROON, None, &[MoveTo(center), LineTo(p1)], ); @@ -825,7 +825,7 @@ mod impls { pub(super) fn square(scene: &mut Scene, kind: Kind, transform: Affine, extend: Extend) { let colors = [ palette::css::RED, - Color::from_rgba8(0, 255, 0, 255), + palette::css::LIME, palette::css::BLUE, ]; let width = 300f64; @@ -1168,7 +1168,7 @@ mod impls { scene.stroke( &Stroke::new(2.0), Affine::IDENTITY, - Color::from_rgba8(0, 0, 255, 255), + palette::css::BLUE, None, &path, ); @@ -1199,7 +1199,7 @@ mod impls { scene.fill( Fill::NonZero, Affine::IDENTITY, - &Brush::Solid(Color::from_rgba8(0, 255, 0, 255)), + palette::css::LIME, None, &rect, ); @@ -1213,14 +1213,14 @@ mod impls { scene.fill( Fill::NonZero, Affine::IDENTITY, - Color::from_rgba8(255, 0, 0, 255), + palette::css::RED, None, &make_diamond(1024.0, 100.0), ); scene.fill( Fill::NonZero, Affine::IDENTITY, - Color::from_rgba8(0, 255, 0, 0x80), + palette::css::LIME.with_alpha(0.5), None, &make_diamond(1024.0, 125.0), ); @@ -1233,7 +1233,7 @@ mod impls { scene.fill( Fill::NonZero, Affine::IDENTITY, - Color::from_rgba8(0, 0, 255, 0x80), + palette::css::BLUE.with_alpha(0.5), None, &make_diamond(1024.0, 175.0), ); @@ -1257,9 +1257,9 @@ mod impls { scene.fill(Fill::NonZero, transform, &radial, None, &rect); } const COLORS: &[Color] = &[ - Color::from_rgba8(255, 0, 0, 255), - Color::from_rgba8(0, 255, 0, 255), - Color::from_rgba8(0, 0, 255, 255), + palette::css::RED, + palette::css::LIME, + palette::css::BLUE, ]; scene.push_layer(Mix::Normal, 1.0, transform, &rect); for (i, c) in COLORS.iter().enumerate() { @@ -1548,7 +1548,7 @@ mod impls { scene.fill( Fill::NonZero, Affine::IDENTITY, - Color::from_rgba8(255, 255, 255, 128), + palette::css::WHITE.with_alpha(0.5), None, &Rect::new(50.0, 50.0, 500.0, 500.0), ); @@ -1608,7 +1608,7 @@ mod impls { scene.fill( Fill::NonZero, Affine::new([scale, 0.0, 0.0, scale, 27.07470703125, 176.40660533027858]), - Color::from_rgba8(0, 0, 255, 255), + palette::css::BLUE, None, &large_background_rect, ); @@ -1622,7 +1622,7 @@ mod impls { 29.027636718750003, 182.9755506427786, ]), - Color::from_rgba8(0, 255, 0, 255), + palette::css::LIME, None, &inside_clip_rect, ); @@ -1636,7 +1636,7 @@ mod impls { 29.027636718750003, scale * 559.3583631427786, ]), - Color::from_rgba8(255, 0, 0, 255), + palette::css::RED, None, &outside_clip_rect, ); diff --git a/examples/with_winit/src/stats.rs b/examples/with_winit/src/stats.rs index 14ed0eb7..93ed9f3e 100644 --- a/examples/with_winit/src/stats.rs +++ b/examples/with_winit/src/stats.rs @@ -48,7 +48,7 @@ impl Snapshot { scene.fill( Fill::NonZero, offset, - &Brush::Solid(Color::from_rgba8(0, 0, 0, 200)), + palette::css::BLACK.with_alpha(0.75), None, &Rect::new(0., 0., width, height), ); @@ -310,7 +310,7 @@ pub fn draw_gpu_profiling( scene.fill( Fill::NonZero, offset, - &Brush::Solid(Color::from_rgba8(0, 0, 0, 200)), + palette::css::BLACK.with_alpha(0.75), None, &Rect::new(0., 0., width, height), );