Skip to main content
← PSoXide SDK guides and examples · SDK 80d1c329e977 · All Cargo features enabled; check feature gates before use.

Brightness

Struct Brightness 

Source
pub struct Brightness(/* private fields */);
Expand description

The BRIGHTNESS setting: Brightness::MIN to Brightness::MAX, where Brightness::DEFAULT (zero) is the picture as drawn.

use psx_display::Brightness;
let mut brightness = Brightness::DEFAULT;
brightness = brightness.stepped(1);
assert_eq!(brightness.label().as_str(), "BRIGHTER 1");
brightness = brightness.stepped(-3);
assert_eq!(brightness.label().as_str(), "DARKER 2");

Implementations§

Source§

impl Brightness

Source

pub const STEP_COUNT: i8 = 5

Steps either side of the picture as drawn.

Source

pub const MIN: Self

The darkest step.

Source

pub const MAX: Self

The brightest step.

Source

pub const DEFAULT: Self

The picture as drawn.

Source

pub const fn new(level: i8) -> Self

The step level: negative is darker, positive brighter. A level outside MIN to MAX is clamped.

Source

pub const fn level(self) -> i8

The signed step: negative darker, positive brighter, zero as drawn.

Source

pub const fn is_default(self) -> bool

Whether this is the picture as drawn, which needs no overlay.

Source

pub const fn stepped(self, delta: i8) -> Self

This setting moved by delta steps (left is negative, right positive), stopping at the ends instead of wrapping.

Source

pub const fn label(self) -> Label

What the options row shows: DEFAULT, DARKER n or BRIGHTER n.

Source

pub const fn label_for_level(level: i8) -> Label

The row text for any signed level, with no clamp. A game whose own brightness steps are not five either side (a palette with its own count of gamma rows) keeps its range and its application and shows the same words through this.

Source

pub const fn to_byte(self) -> u8

The save byte: the step in two’s complement, so zero (the default) is also what a save from before the setting reads as.

Source

pub const fn from_byte(byte: u8) -> Self

The setting a save byte holds. Any byte decodes: one outside the range is clamped to the nearest end.

Source

pub const fn overlay_gain(self) -> u8

Grey of 255 the overlay carries: zero at the default, else the step count times 8, darker or brighter. On the GPU’s five bits that is exactly the step count (1 to 5) subtracted or added per channel.

Source

pub const fn faded_gain(self, fade: u8) -> u8

The overlay grey while a screen fades: overlay_gain scaled by fade, where 128 is the screen at full strength. A fade to black then still ends black instead of a lifted grey.

Source

pub const fn overlay(self, resolution: Resolution) -> Option<BrightnessOverlay>

The overlay for a resolution frame, or None at the default (no packet, no GPU work, no per-frame cost).

Source

pub const fn faded_overlay( self, resolution: Resolution, fade: u8, ) -> Option<BrightnessOverlay>

The overlay for a screen mid-fade (see faded_gain), or None when the setting is at the default or the fade has taken the grey to nothing.

Trait Implementations§

Source§

impl Clone for Brightness

Source§

fn clone(&self) -> Brightness

Returns a duplicate of the value. Read more
1.0.0§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Brightness

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Brightness

Source§

fn default() -> Brightness

Returns the “default value” for a type. Read more
Source§

impl Hash for Brightness

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given [Hasher]. Read more
1.3.0§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given [Hasher]. Read more
Source§

impl PartialEq for Brightness

Source§

fn eq(&self, other: &Brightness) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Brightness

Source§

impl Eq for Brightness

Source§

impl StructuralPartialEq for Brightness

Auto Trait Implementations§

§

impl Freeze for Brightness

§

impl RefUnwindSafe for Brightness

§

impl Send for Brightness

§

impl Sync for Brightness

§

impl Unpin for Brightness

§

impl UnsafeUnpin for Brightness

§

impl UnwindSafe for Brightness

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CloneToUninit for T
where T: Clone,

§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.