From 09773f89a3d3ac37a18fc439da3c4fed708be20e Mon Sep 17 00:00:00 2001 From: Chad Brokaw Date: Wed, 19 Oct 2022 14:29:40 -0400 Subject: [PATCH] fix gradient ramp color packing --- piet-gpu/src/ramp.rs | 2 +- piet-gpu/src/samples.rs | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/piet-gpu/src/ramp.rs b/piet-gpu/src/ramp.rs index 8e4ca19..1c834f7 100644 --- a/piet-gpu/src/ramp.rs +++ b/piet-gpu/src/ramp.rs @@ -124,6 +124,6 @@ impl ColorF64 { let g = ((self.0[1] * a).min(1.0).max(0.0) * 255.0) as u32; let b = ((self.0[2] * a).min(1.0).max(0.0) * 255.0) as u32; let a = (a * 255.0) as u32; - b | (g << 8) | (r << 16) | (a << 24) + r | (g << 8) | (b << 16) | (a << 24) } } diff --git a/piet-gpu/src/samples.rs b/piet-gpu/src/samples.rs index 9a4f094..091f4ef 100644 --- a/piet-gpu/src/samples.rs +++ b/piet-gpu/src/samples.rs @@ -206,9 +206,9 @@ fn render_blend_square(sb: &mut SceneBuilder, blend: BlendMode, transform: Affin }); sb.fill(Fill::NonZero, transform, &linear, None, rect.elements()); const GRADIENTS: &[(f32, f32, Color)] = &[ - (150., 0., Color::rgb8(64, 240, 255)), - (175., 100., Color::rgb8(240, 96, 255)), - (125., 200., Color::rgb8(255, 192, 64)), + (150., 0., Color::rgb8(255, 240, 64)), + (175., 100., Color::rgb8(255, 96, 240)), + (125., 200., Color::rgb8(64, 192, 255)), ]; for (x, y, c) in GRADIENTS { let mut color2 = c.clone(); @@ -234,9 +234,9 @@ fn render_blend_square(sb: &mut SceneBuilder, blend: BlendMode, transform: Affin sb.fill(Fill::NonZero, transform, &rad, None, rect.elements()); } const COLORS: &[Color] = &[ - Color::rgb8(0, 0, 255), - Color::rgb8(0, 255, 0), Color::rgb8(255, 0, 0), + Color::rgb8(0, 255, 0), + Color::rgb8(0, 0, 255), ]; sb.push_layer(Mix::Normal.into(), transform, rect.elements()); for (i, c) in COLORS.iter().enumerate() {