Skip to content

Commit

Permalink
Tweak gamepad viewer example style (bevyengine#11484)
Browse files Browse the repository at this point in the history
# Objective

Since bevyengine#10339, the contrast in this example has been very low. While I
was in there, I made a few other tweaks to the style.

Alternative to bevyengine#10102.

## Solution

- Increase brightness of inactive buttons for higher contrast on the new
clear color
- Combine `DEAD_COLOR` and `EXTENT_COLOR`. These were using the same
value, and combining them might make the intent a little clearer. (This
is the single color for "not the live zone.")
- Make the "stick buttons" slightly smaller, so it's a bit more obvious
that they are sitting inside of the default dead zone.
- Remove explicit text color -- it was the same as the default
- Add top-left margin to the text in the top left, and change the font
size to better match other examples with text in the corner.

## Screenshots

<details>
  <summary>With Bevy's default dead / live zones.</summary>
Before / After


![default](https://github.com/bevyengine/bevy/assets/200550/67bf1f5c-7fc9-4e74-87cf-2a94fcf59a50)
</details>

<details>
<summary>With Bevy's old dead / live zones. (with the upper live zone
boundary != 1.0)</summary>
Before / After


![old](https://github.com/bevyengine/bevy/assets/200550/3aab6a2a-ad57-4749-b2e5-51ed34072b2c)
</details>
  • Loading branch information
rparrett committed Jan 23, 2024
1 parent f7c4988 commit 2951ddf
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions examples/tools/gamepad_viewer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ const BUTTONS_Y: f32 = 80.;
const STICKS_X: f32 = 150.;
const STICKS_Y: f32 = -135.;

const NORMAL_BUTTON_COLOR: Color = Color::rgb(0.2, 0.2, 0.2);
const NORMAL_BUTTON_COLOR: Color = Color::rgb(0.3, 0.3, 0.3);
const ACTIVE_BUTTON_COLOR: Color = Color::PURPLE;
const LIVE_COLOR: Color = Color::rgb(0.4, 0.4, 0.4);
const DEAD_COLOR: Color = Color::rgb(0.3, 0.3, 0.3);
const EXTENT_COLOR: Color = Color::rgb(0.3, 0.3, 0.3);
const TEXT_COLOR: Color = Color::WHITE;
const DEAD_COLOR: Color = Color::rgb(0.13, 0.13, 0.13);

#[derive(Component, Deref)]
struct ReactTo(GamepadButtonType);
Expand Down Expand Up @@ -290,7 +288,7 @@ fn setup_sticks(
parent.spawn(SpriteBundle {
sprite: Sprite {
custom_size: Some(Vec2::splat(STICK_BOUNDS_SIZE * 2.)),
color: EXTENT_COLOR,
color: DEAD_COLOR,
..default()
},
..default()
Expand Down Expand Up @@ -318,7 +316,6 @@ fn setup_sticks(
// text
let style = TextStyle {
font_size: 16.,
color: TEXT_COLOR,
..default()
};
parent.spawn((
Expand Down Expand Up @@ -349,7 +346,7 @@ fn setup_sticks(
mesh: meshes.circle.clone(),
material: materials.normal.clone(),
transform: Transform::from_xyz(0., 0., 5.)
.with_scale(Vec2::splat(0.2).extend(1.)),
.with_scale(Vec2::splat(0.15).extend(1.)),
..default()
},
MoveWithAxes {
Expand Down Expand Up @@ -400,7 +397,6 @@ fn setup_triggers(
format!("{:.3}", 0.),
TextStyle {
font_size: 16.,
color: TEXT_COLOR,
..default()
},
),
Expand All @@ -424,22 +420,30 @@ fn setup_triggers(
}

fn setup_connected(mut commands: Commands) {
let style = TextStyle {
color: TEXT_COLOR,
font_size: 30.,
let text_style = TextStyle {
font_size: 20.,
..default()
};
commands.spawn((
TextBundle::from_sections([
TextSection {
value: "Connected Gamepads:\n".to_string(),
style: style.clone(),
},
TextSection {
value: "None".to_string(),
style,
TextBundle {
text: Text::from_sections([
TextSection {
value: "Connected Gamepads:\n".to_string(),
style: text_style.clone(),
},
TextSection {
value: "None".to_string(),
style: text_style,
},
]),
style: Style {
position_type: PositionType::Absolute,
top: Val::Px(12.),
left: Val::Px(12.),
..default()
},
]),
..default()
},
ConnectedGamepadsText,
));
}
Expand Down

0 comments on commit 2951ddf

Please sign in to comment.