Skip to content

Commit

Permalink
Use Color::from_rgb8, update to Peniko 0.3.1 (#797)
Browse files Browse the repository at this point in the history
This is a short hand that was added in Color 0.2.3. This change only
impacts tests, examples, and docs.

The update to Peniko 0.3.1 brings a requirement for color 0.2.3.
  • Loading branch information
waywardmonkeys authored Jan 20, 2025
1 parent 032d893 commit 1949d09
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 33 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bytemuck = { version = "1.21.0", features = ["derive"] }
skrifa = "0.26.4"
# The version of kurbo used below should be kept in sync
# with the version of kurbo used by peniko.
peniko = "0.3.0"
peniko = "0.3.1"
# FIXME: This can be removed once peniko supports the schemars feature.
kurbo = "0.11.1"
futures-intrusive = "0.5.0"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ let mut scene = Scene::new();
scene.fill(
Fill::NonZero,
Affine::IDENTITY,
Color::from_rgba8(242, 140, 168, 255),
Color::from_rgb8(242, 140, 168),
None,
&Circle::new((420.0, 200.0), 120.0),
);
Expand Down
14 changes: 7 additions & 7 deletions examples/scenes/src/mmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,13 @@ impl TestScene for MMark {
}

const COLORS: &[Color] = &[
Color::from_rgba8(0x10, 0x10, 0x10, 0xff),
Color::from_rgba8(0x80, 0x80, 0x80, 0xff),
Color::from_rgba8(0xc0, 0xc0, 0xc0, 0xff),
Color::from_rgba8(0x10, 0x10, 0x10, 0xff),
Color::from_rgba8(0x80, 0x80, 0x80, 0xff),
Color::from_rgba8(0xc0, 0xc0, 0xc0, 0xff),
Color::from_rgba8(0xe0, 0x10, 0x40, 0xff),
Color::from_rgb8(0x10, 0x10, 0x10),
Color::from_rgb8(0x80, 0x80, 0x80),
Color::from_rgb8(0xc0, 0xc0, 0xc0),
Color::from_rgb8(0x10, 0x10, 0x10),
Color::from_rgb8(0x80, 0x80, 0x80),
Color::from_rgb8(0xc0, 0xc0, 0xc0),
Color::from_rgb8(0xe0, 0x10, 0x40),
];

impl Element {
Expand Down
30 changes: 15 additions & 15 deletions examples/scenes/src/test_scenes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ mod impls {
use PathEl::*;
move |scene, params| {
let colors = [
Color::from_rgba8(140, 181, 236, 255),
Color::from_rgba8(246, 236, 202, 255),
Color::from_rgba8(201, 147, 206, 255),
Color::from_rgba8(150, 195, 160, 255),
Color::from_rgb8(140, 181, 236),
Color::from_rgb8(246, 236, 202),
Color::from_rgb8(201, 147, 206),
Color::from_rgb8(150, 195, 160),
];
let simple_stroke = [MoveTo((0., 0.).into()), LineTo((100., 0.).into())];
let join_stroke = [
Expand Down Expand Up @@ -350,10 +350,10 @@ mod impls {
pub(super) fn tricky_strokes(scene: &mut Scene, params: &mut SceneParams<'_>) {
use PathEl::*;
let colors = [
Color::from_rgba8(140, 181, 236, 255),
Color::from_rgba8(246, 236, 202, 255),
Color::from_rgba8(201, 147, 206, 255),
Color::from_rgba8(150, 195, 160, 255),
Color::from_rgb8(140, 181, 236),
Color::from_rgb8(246, 236, 202),
Color::from_rgb8(201, 147, 206),
Color::from_rgb8(150, 195, 160),
];

const CELL_SIZE: f64 = 200.;
Expand Down Expand Up @@ -891,7 +891,7 @@ mod impls {
let colors = [
palette::css::RED,
palette::css::YELLOW,
Color::from_rgba8(6, 85, 186, 255),
Color::from_rgb8(6, 85, 186),
];
let width = 400_f64;
let height = 200_f64;
Expand Down Expand Up @@ -1236,9 +1236,9 @@ mod impls {
.with_stops([palette::css::BLACK, palette::css::WHITE]);
scene.fill(Fill::NonZero, transform, &linear, None, &rect);
const GRADIENTS: &[(f64, f64, Color)] = &[
(150., 0., Color::from_rgba8(255, 240, 64, 255)),
(175., 100., Color::from_rgba8(255, 96, 240, 255)),
(125., 200., Color::from_rgba8(64, 192, 255, 255)),
(150., 0., Color::from_rgb8(255, 240, 64)),
(175., 100., Color::from_rgb8(255, 96, 240)),
(125., 200., Color::from_rgb8(64, 192, 255)),
];
for (x, y, c) in GRADIENTS {
let color2 = c.with_alpha(0.);
Expand Down Expand Up @@ -1284,8 +1284,8 @@ mod impls {
let x = N + 0.5; // Fractional pixel offset reveals the problem on axis-aligned edges.
let mut y = N;

let bg_color = Color::from_rgba8(255, 194, 19, 255);
let fg_color = Color::from_rgba8(12, 165, 255, 255);
let bg_color = Color::from_rgb8(255, 194, 19);
let fg_color = Color::from_rgb8(12, 165, 255);

// Two adjacent triangles touching at diagonal edge with opposing winding numbers
scene.fill(
Expand Down Expand Up @@ -1435,7 +1435,7 @@ mod impls {
scene.fill(
Fill::NonZero,
Affine::translate((20.5, 20.5)) * Affine::scale(80.0),
Color::from_rgba8(0x70, 0x80, 0x80, 0xff),
Color::from_rgb8(0x70, 0x80, 0x80),
None,
&path,
);
Expand Down
6 changes: 3 additions & 3 deletions examples/with_winit/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ impl Snapshot {
let s = Affine::scale_non_uniform(1., -h);
#[allow(clippy::match_overlapping_arm)]
let color = match *sample {
..=16_667 => Color::from_rgba8(100, 143, 255, 255),
..=33_334 => Color::from_rgba8(255, 176, 0, 255),
_ => Color::from_rgba8(220, 38, 127, 255),
..=16_667 => Color::from_rgb8(100, 143, 255),
..=33_334 => Color::from_rgb8(255, 176, 0),
_ => Color::from_rgb8(220, 38, 127),
};
scene.fill(
Fill::NonZero,
Expand Down
2 changes: 1 addition & 1 deletion vello/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ let mut scene = vello::Scene::new();
scene.fill(
vello::peniko::Fill::NonZero,
vello::Affine::IDENTITY,
vello::Color::from_rgba8(242, 140, 168, 255),
vello::Color::from_rgb8(242, 140, 168),
None,
&vello::Circle::new((420.0, 200.0), 120.0),
);
Expand Down
2 changes: 1 addition & 1 deletion vello/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
//! scene.fill(
//! vello::peniko::Fill::NonZero,
//! vello::Affine::IDENTITY,
//! vello::Color::from_rgba8(242, 140, 168, 255),
//! vello::Color::from_rgb8(242, 140, 168),
//! None,
//! &vello::Circle::new((420.0, 200.0), 120.0),
//! );
Expand Down

0 comments on commit 1949d09

Please sign in to comment.