Skip to main content

anchored_pos

Function anchored_pos 

Source
pub fn anchored_pos(
    pos: [f32; 2],
    size: Vec2,
    bounds: Rect,
    anchor: &Anchor,
) -> Pos2
Expand description

Where a palette’s top-left corner goes in bounds: an anchored axis keeps its distance to its edge, the other keeps pos (from the bounds’ top-left); kept inside either way.

use egui::{Rect, pos2, vec2};
use egui_pop_api::palettes::anchored_pos;
use egui_pop_model::layout::{Anchor, AnchorEdge};

let right = Anchor { x: AnchorEdge::End, ..Anchor::default() };
let wider = Rect::from_min_size(pos2(0.0, 0.0), vec2(1000.0, 600.0));
let at = anchored_pos([700.0, 200.0], vec2(100.0, 50.0), wider, &right);
assert_eq!(at, pos2(900.0, 200.0));