Skip to content

Commit

Permalink
fix: color name adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Jul 5, 2024
1 parent 88ee026 commit 1d68ad0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 24 deletions.
6 changes: 3 additions & 3 deletions examples/demo/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub fn controls_ui(
ui.heading("Theme");
for layer in composition.as_ref().get_layers() {
let color = theme.get_mut(layer).cloned().unwrap_or_default();
let color = color.to_srgba();
let color = color.to_linear();
let mut color_edit = [color.red, color.green, color.blue, color.alpha];
ui.horizontal(|ui| {
if ui
Expand All @@ -258,8 +258,8 @@ pub fn controls_ui(
.theme
.as_mut()
.unwrap()
.edit(layer, Color::srgba(r, g, b, a));
theme.edit(layer, Color::srgba(r, g, b, a));
.edit(layer, Color::linear_rgba(r, g, b, a));
theme.edit(layer, Color::linear_rgba(r, g, b, a));
};
ui.label(layer);
});
Expand Down
4 changes: 2 additions & 2 deletions examples/scene_ui/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::f64::consts::{FRAC_PI_4, SQRT_2};

use bevy::prelude::*;
use bevy::{color::palettes::css, prelude::*};
use bevy_vello::{prelude::*, VelloPlugin};

fn main() {
Expand All @@ -27,7 +27,7 @@ fn setup_ui(mut commands: Commands) {
border: UiRect::all(Val::Px(2.0)),
..default()
},
border_color: Srgba::rgb(1.0, 0.0, 1.0).with_alpha(0.5).into(),
border_color: css::FUCHSIA.with_alpha(0.5).into(),
..default()
},
Interaction::default(),
Expand Down
37 changes: 18 additions & 19 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
text::VelloTextAlignment, CoordinateSpace, VelloAsset, VelloAssetAlignment, VelloFont,
VelloText, ZFunction,
};
use bevy::{math::Vec3Swizzles, prelude::*};
use bevy::{color::palettes::css, math::Vec3Swizzles, prelude::*};

const RED_X_SIZE: f32 = 8.0;

Expand Down Expand Up @@ -150,7 +150,7 @@ fn render_text_debug(
}
};
let rect_center = origin + rect.size() / 2.0;
gizmos.rect_2d(rect_center, 0.0, rect.size(), Color::WHITE);
gizmos.rect_2d(rect_center, 0.0, rect.size(), css::WHITE);
}
CoordinateSpace::ScreenSpace => {
let Some(rect) = text.bb_in_screen_space(font, gtransform, camera, view) else {
Expand Down Expand Up @@ -200,7 +200,7 @@ fn render_text_debug(
rect_center,
0.0,
rect.size() * Vec2::new(1.0, 1.0),
Color::WHITE,
css::WHITE,
);
}
}
Expand All @@ -213,12 +213,12 @@ fn draw_origin(gizmos: &mut Gizmos, projection: &OrthographicProjection, origin:
let from = origin + RED_X_SIZE * Vec2::splat(1.0) * projection.scale;
let to = origin + RED_X_SIZE * Vec2::splat(-1.0) * projection.scale;

gizmos.line_2d(from, to, Srgba::RED);
gizmos.line_2d(from, to, css::RED);

let from = origin + RED_X_SIZE * Vec2::new(1.0, -1.0) * projection.scale;
let to = origin + RED_X_SIZE * Vec2::new(-1.0, 1.0) * projection.scale;

gizmos.line_2d(from, to, Srgba::RED);
gizmos.line_2d(from, to, css::RED);
}

/// A helper method to draw the bounding box
Expand All @@ -231,25 +231,25 @@ fn draw_bounding_box(gizmos: &mut Gizmos, z_fn: &ZFunction, position: Vec2, size
gizmos.line_2d(
position + Vec2::new(-half_width, -half_height),
position + Vec2::new(-half_width, half_height),
Color::WHITE,
css::WHITE,
);
// Top
gizmos.line_2d(
position + Vec2::new(-half_width, -half_height),
position + Vec2::new(half_width, -half_height),
Color::WHITE,
css::WHITE,
);
// Right
gizmos.line_2d(
position + Vec2::new(half_width, -half_height),
position + Vec2::new(half_width, half_height),
Color::WHITE,
css::WHITE,
);
// Bottom
gizmos.line_2d(
position + Vec2::new(-half_width, half_height),
position + Vec2::new(half_width, half_height),
Color::WHITE,
css::WHITE,
);

// TODO: When bevy_gizmos get text, I'd *much rather* just show the Z value with text.
Expand All @@ -261,50 +261,49 @@ fn draw_bounding_box(gizmos: &mut Gizmos, z_fn: &ZFunction, position: Vec2, size
// position,
// 0.0,
// size,
// Color::WHITE,
// css::WHITE,
// );
// ```
const Z_COLOR: Srgba = Srgba::GREEN;
match z_fn {
ZFunction::TransformX => gizmos.line_2d(
position + Vec2::new(0.0, -half_height),
position + Vec2::new(0.0, half_height),
Z_COLOR,
css::GREEN,
),
ZFunction::TransformY => gizmos.line_2d(
position + Vec2::new(-half_width, 0.0),
position + Vec2::new(half_width, 0.0),
Z_COLOR,
css::GREEN,
),
ZFunction::TransformXOffset(offset) => gizmos.line_2d(
position + Vec2::new(*offset, -half_height),
position + Vec2::new(*offset, half_height),
Z_COLOR,
css::GREEN,
),
ZFunction::TransformYOffset(offset) => gizmos.line_2d(
position + Vec2::new(-half_width, *offset),
position + Vec2::new(half_width, *offset),
Z_COLOR,
css::GREEN,
),
ZFunction::BbTop | ZFunction::BbTopInverse => gizmos.line_2d(
position + Vec2::new(-half_width, half_height),
position + Vec2::new(half_width, half_height),
Z_COLOR,
css::GREEN,
),
ZFunction::BbBottom | ZFunction::BbBottomInverse => gizmos.line_2d(
position + Vec2::new(-half_width, -half_height),
position + Vec2::new(half_width, -half_height),
Z_COLOR,
css::GREEN,
),
ZFunction::BbLeft | ZFunction::BbLeftInverse => gizmos.line_2d(
position + Vec2::new(-half_width, -half_height),
position + Vec2::new(-half_width, half_height),
Z_COLOR,
css::GREEN,
),
ZFunction::BbRight | ZFunction::BbRightInverse => gizmos.line_2d(
position + Vec2::new(half_width, -half_height),
position + Vec2::new(half_width, half_height),
Z_COLOR,
css::GREEN,
),
ZFunction::TransformZ
| ZFunction::TransformZOffset(_)
Expand Down

0 comments on commit 1d68ad0

Please sign in to comment.