pub struct Scale(pub f32);Expand description
表示 scale — 論理 px の token 値を物理 px へ変換する倍率。
creo-ui の dimension token は 論理 px (crate docs の契約表参照)。
wgpu / glyphon のような物理ピクセル基準の生描画では、window の scale factor を
ここに包んで描画直前に Scale::px を通す:
use creo_ui::{tokens, Scale};
let scale = Scale::new(2.0); // 例: Retina。実際は window.scale_factor() 等から
let font_px = scale.px(tokens::TYPOGRAPHY_SIZE_M); // 論理 px → 物理 px (2 倍)
assert_eq!(font_px, tokens::TYPOGRAPHY_SIZE_M * 2.0);glyphon なら TextArea.scale にそのまま factor を渡す手もある。padding や
配置座標など layout 値も論理で組み、同じ Scale を通すこと (文字だけ
掛けると余白と釣り合いが崩れる)。
Default は意図的に実装しない — 「黙って 1.0」は Retina で半分サイズになる
bug (scale 掛け忘れ) をそのまま既定化してしまうため、factor は常に明示する。
Tuple Fields§
§0: f32Implementations§
Trait Implementations§
impl Copy for Scale
impl StructuralPartialEq for Scale
Auto Trait Implementations§
impl Freeze for Scale
impl RefUnwindSafe for Scale
impl Send for Scale
impl Sync for Scale
impl Unpin for Scale
impl UnsafeUnpin for Scale
impl UnwindSafe for Scale
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more