struct UI::DesignTokens::Material

Overview

Glass material token branch (two-axis).

#step is the declared ThicknessStep; #semantic is the declared AppleSemantic; #intensity is the brand-declaration-time scalar used by the #thickness_for_brand quantizer on web + Android.

Per-step records (#ultra_thin / #thin / #regular / #thick / #chrome) carry the predefined blur_radius / opacity constants the quantizer's effective step lookup returns.

Render-time only. Material changes require a re-render — there is no runtime mutator on intensity / step / semantic. Consumers observe brand-overridden values by rebuilding the view tree.

Defined in:

ui/design_tokens/material.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(ultra_thin : MaterialStep, thin : MaterialStep, regular : MaterialStep, thick : MaterialStep, chrome : MaterialStep, intensity : Float64, step : ThicknessStep = ThicknessStep::Regular, semantic : AppleSemantic = AppleSemantic::SystemResolved) #

[View source]

Class Method Detail

def self.step_baseline(step : ThicknessStep) : Float64 #

Per-step baseline multiplier for the quantizer. Step baselines are deliberately spaced so that at intensity = 1.0 each declared step quantizes back to itself (UltraThin->UltraThin, etc.), except Chrome (baseline 1.9) which collapses to Chrome (>= 1.8 bucket) — that's the documented "Chrome is the ceiling" behavior.


[View source]

Instance Method Detail

def apple_semantic : AppleSemantic #

Apple axis: the declared semantic, unchanged. Intensity does NOT modify this — Apple materials are role-based.


[View source]
def apple_step(declared : Symbol) : Symbol #

[View source]
def chrome : MaterialStep #

def clone #

[View source]
def copy_with(ultra_thin _ultra_thin = @ultra_thin, thin _thin = @thin, regular _regular = @regular, thick _thick = @thick, chrome _chrome = @chrome, intensity _intensity = @intensity, step _step = @step, semantic _semantic = @semantic) #

[View source]
def intensity : Float64 #

def material_step_for(s : ThicknessStep) : MaterialStep #

Lookup the MaterialStep for a ThicknessStep.


[View source]
def regular : MaterialStep #

def resolve(name : Symbol) : ResolvedStep #

Render-time resolution for web / Android. Returns a ResolvedStep carrying the EFFECTIVE step's predefined blur_radius + opacity (not proportionally scaled). The name field in the resolved record is the effective step's Symbol so renderers that key CSS classes / custom-property suffixes on the step name still find the right bucket.


[View source]
def semantic : AppleSemantic #

def step(name : Symbol) : MaterialStep #

Backwards-compat: pre-v2 callers used #step(:menu) / #step(:thin) with a single-axis Symbol vocabulary. The v2 model splits the vocabulary (semantics on Apple, thickness on web/Android), so these shims convert Symbol -> appropriate axis output:

  • #step(name) — accepts the legacy ThicknessStep symbol shape; unknown symbols fall back to the declared #step.
  • #apple_step(declared) — legacy quantizer call. v2 maps the declared Symbol through ThicknessStep.from_symbol, overrides this Material's step temporarily via copy, then applies #thickness_for_brand and returns the result as a Symbol. Callers (GlassBackground visit, web_renderer, android_renderer) get the same Symbol-in/Symbol-out shape they had pre-v2; the QUANTIZER semantics are now correct.
  • #resolve(name) — preserved; uses the quantizer's effective step to choose blur_radius (not proportional scaling).


[View source]
def step : ThicknessStep #

def thick : MaterialStep #

def thickness_for_brand : ThicknessStep #

Web / Android axis: quantizer model.

Per the v2 architecture doc lines 65-77: baseline = step_baseline(step) i = baseline * intensity <= 0.3 -> UltraThin <= 0.7 -> Thin <= 1.3 -> Regular

= 1.8 -> Chrome else -> Thick



[View source]
def thin : MaterialStep #

def ultra_thin : MaterialStep #