1
0
Fork 0

Mention Y-coordinate direction in remapping utils

Since the direction is probably opposite of what you want.
This commit is contained in:
Robbert van der Helm 2022-11-11 20:19:50 +01:00
parent 3510350425
commit 4f9a0eb117

View file

@ -48,6 +48,11 @@ pub fn remap_current_entity_x_t(cx: &EventContext, t: f32) -> f32 {
/// Remap a `[0, 1]` value to a y-coordinate within the current entity's bounding box. The value /// Remap a `[0, 1]` value to a y-coordinate within the current entity's bounding box. The value
/// will be clamped to `[0, 1]` if it isn't already in that range. This ignores the border width. /// will be clamped to `[0, 1]` if it isn't already in that range. This ignores the border width.
///
/// # Note
///
/// As y-coordinates increase from top to bottom, this value is likely the inverse of what you want.
/// 0.0 is the bottom of the enitty and 1.0 corresponds to the top of the entity.
pub fn remap_current_entity_y_t(cx: &EventContext, t: f32) -> f32 { pub fn remap_current_entity_y_t(cx: &EventContext, t: f32) -> f32 {
let border_width = match cx.style.border_width.get(cx.current()) { let border_width = match cx.style.border_width.get(cx.current()) {
Some(Units::Pixels(x)) => *x, Some(Units::Pixels(x)) => *x,
@ -72,6 +77,11 @@ pub fn remap_current_entity_x_coordinate(cx: &EventContext, x_coord: f32) -> f32
/// Remap an y-coordinate to a `[0, 1]` value within the current entity's bounding box. The value /// Remap an y-coordinate to a `[0, 1]` value within the current entity's bounding box. The value
/// will be clamped to `[0, 1]` if it isn't already in that range. This ignores the border width. /// will be clamped to `[0, 1]` if it isn't already in that range. This ignores the border width.
///
/// # Note
///
/// As y-coordinates increase from top to bottom, this value is likely the inverse of what you want.
/// 0.0 is the bottom of the enitty and 1.0 corresponds to the top of the entity.
pub fn remap_current_entity_y_coordinate(cx: &EventContext, y_coord: f32) -> f32 { pub fn remap_current_entity_y_coordinate(cx: &EventContext, y_coord: f32) -> f32 {
let border_width = match cx.style.border_width.get(cx.current()) { let border_width = match cx.style.border_width.get(cx.current()) {
Some(Units::Pixels(x)) => *x, Some(Units::Pixels(x)) => *x,