Same API surface as scaled with prefixes dgsdp / dghdp / dgwdp / dgssp / … — see COMPOSE-API-CONVENTIONS.md §3.
Diagonal scales by the length of the screen rectangle’s diagonal in dp: it combines width and height into one number, reflecting “perceived canvas size” better than a single axis alone. The SDP/HDP/WDP qualifier does not change the diagonal used — the math always uses the current window’s shorter and longer side.
Mathematically, for the current window:
shorter = min(widthDp, heightDp),longer = max(...)diag = √(shorter² + longer²)scale = diag / BASE_DIAGONAL_DPwithBASE_DIAGONAL_DP = √(300² + 533²) ≈ 611.63(DesignScaleConstants).out = base × scale.
Implementation note: scale is pre-computed once per configuration change in DimenCache.ScreenFactors.updateFactors() (exposed as DimenCache.currentDiagonalScale). The steps above describe what that factor represents; the runtime does not recompute √(shorter² + longer²) on every call.
- With
a: multiply by the pre-computed aspect-ratio factor (DimenCache.currentAspectRatioMul); custom sensitivity uses1 + k × logNormalizedAr(also derived from cached screen factors).
Implementation: calculateDiagonalDpCompose in DimenDiagonalDp.kt.
import com.appdimens.dynamic.compose.diagonal.dgsdp
Modifier.size(64.dgsdp)Main Compose prefixes: dgsdp, dghdp, dgwdp (plus a / i / ia, Px, inverters like .dgsdpPh, .dgsdpLw, … in DimenDiagonalDp.kt).
Code: com.appdimens.dynamic.code.diagonal.
Elements that should react to overall canvas size (games, dense dashboards, frames) rather than width or height alone.
- Balance wide short vs tall narrow screens fairly.
- When sdp or wdp alone skew visual hierarchy.
- Pros: one stable scalar for “how big is the screen” overall.
- Cons: less intuitive for designers used to width breakpoints; inverters have limited effect on the diagonal itself (the read axis changes, but the formula still uses the current sides).
Reserve diagonal for specific components (e.g. board piece size, centered hero icon); keep lists and running text on scaled or hdp/wdp depending on the dominant axis.