//AppDimens SDP, HDP, WDP: Scalable Width and Height Dimensions/com.appdimens.dynamic.code.diagonal/toDynamicDiagonalPx
@JvmOverloadsfun Number.toDynamicDiagonalPx(context: Context, qualifier: DpQualifier, inverter: Inverter = Inverter.DEFAULT, ignoreMultiWindows: Boolean = false, applyAspectRatio: Boolean = false, customSensitivityK: Float? = null): Float
EN Converts a Number (base Dp value) into a dynamically scaled pixel Float for View-based (non-Compose) code.
The scaling logic:
Builds a 64-bit packed cache key from all dimension parameters.
IfenableCacheistrue (default): checks DimenCache first. On a hit, returns the cached pixel value immediately. On a miss, calls calculateDiagonalDp and converts Dp→px via scaledDp * displayMetrics.density (equivalent to android.util.TypedValue.applyDimension for COMPLEX_UNIT_DIP), then stores the result.
IfenableCacheisfalse: computes directly via calculateDiagonalDp, bypassing cache.
⚠️ Bypass note: when applyAspectRatio is false and qualifier is SMALL_WIDTH with DEFAULT inverter, the DimenCache.getOrPut call internally bypasses the hash lookup because a raw multiply (~2 ns) is faster than the cache access (~5 ns). Calls with these parameters measure raw math performance, NOT cache throughput.
Bulk resolution: for many keys in one pass, prefer building LongArray keys with DimenCache.buildKey and DimenCache.getBatch. Early init: call DimenSdp.warmupCache (or DimenSsp.warmupCache) once with your android.content.Context so persistence/DataStore work does not land on the first hot-frame call.
PT Converte um Number (valor Dp base) em um Float em pixels dinamicamente escalado para código View-based.
A lógica de escalonamento:
Constrói uma chave de cache de 64 bits a partir de todos os parâmetros da dimensão.
SeenableCachefortrue (padrão): consulta o DimenCache primeiro. No acerto, retorna o valor em pixels cacheado; no miss, calcula via calculateDiagonalDp e armazena.
SeenableCacheforfalse: calcula diretamente via calculateDiagonalDp.
Dynamically scaled pixel value as Float.
Android android.content.Context for configuration and density access.
Screen dimension qualifier: com.appdimens.dynamic.common.DpQualifier.SMALL_WIDTH, com.appdimens.dynamic.common.DpQualifier.HEIGHT, or com.appdimens.dynamic.common.DpQualifier.WIDTH.
Orientation-based dimension swap rule (default: Inverter.DEFAULT).
If true, returns the base value in pixels unscaled when in split-screen.
If true, applies the aspect-ratio multiplier.
Override for the AR sensitivity constant (null = library default).