Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T05:37:44.608Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

units.rs

30 lines · 1.1 KB · rust
1use gpui::{Length, Rems, Window, rems};
2
3/// The base size of a rem, in pixels.
4pub const BASE_REM_SIZE_IN_PX: f32 = 16.;
5
6/// Returns a rem value derived from the provided pixel value and the base rem size (16px).
7///
8/// This can be used to compute rem values relative to pixel sizes, without
9/// needing to hard-code the rem value.
10///
11/// For instance, instead of writing `rems(0.875)` you can write `rems_from_px(14.)`
12#[inline(always)]
13pub fn rems_from_px(px: impl Into<f32>) -> Rems {
14    rems(px.into() / BASE_REM_SIZE_IN_PX)
15}
16
17/// Returns a [`Length`] corresponding to the specified percentage of the viewport's width.
18///
19/// `percent` should be a value between `0.0` and `1.0`.
20pub fn vw(percent: f32, window: &mut Window) -> Length {
21    Length::from(window.viewport_size().width * percent)
22}
23
24/// Returns a [`Length`] corresponding to the specified percentage of the viewport's height.
25///
26/// `percent` should be a value between `0.0` and `1.0`.
27pub fn vh(percent: f32, window: &mut Window) -> Length {
28    Length::from(window.viewport_size().height * percent)
29}
30
Served at tenant.openagents/omega Member data and write actions are omitted.