Atlaslog
Atlaslog / Field Notes / Styling & rendering
Field note · Styling & rendering

Two 50% translucent layers stack into 75% opacity

Quick answer

Two 0.5-opacity fills overlap and measure at about 0.75, much darker than the design. Alpha composites as a_top + a_bottom x (1 - a_top), and any CSS `opacity` on the pane multiplies the result again.

Last verified 2026-11-03 · Multiple versions · Cite this page
Applies to: Leaflet 1.9.x / Mapbox GL JS 2.15 / CSS source-over
Symptom
Checklist
  1. Read the pane's computed `opacity` in the Elements panel
  2. Compare the path's `fill-opacity` with the layer's `opacity` option for double application
  3. Sample single-layer and overlap pixels with a color picker and back-solve the alpha
  4. Check for global CSS setting `opacity` on `.leaflet-overlay-pane svg`
  5. Check Mapbox GL for `fill-opacity` multiplied by a layer-level opacity expression
Fix

Control transparency in one place with `fillOpacity` only (`fillOpacity: 0.35`), or back-solve the per-layer alpha for a target overlap: for 0.5 overlap, `2a - a*a = 0.5` gives a of about 0.293.

Code
α_result = α_top + α_bottom × (1 - α_top)
α = 0.5 + 0.5 × 0.5 = 0.75
const pane = map.getPane('overlayPane');
console.log(getComputedStyle(pane).opacity);        // 0.8  <- 额外的乘数
console.log(getComputedStyle(pane.querySelector('path')).fillOpacity);  // 0.5
Watch out
All 120 field notesChinese originalRunnable examples
English edition written for Atlaslog from the original Chinese field note. Code is unchanged and runs as-is.
Cite this page

Atlaslog (2026). Two 50% translucent layers stack into 75% opacity. https://www.jingweizhi.com/en/cookbook/opacity-multiply.html (accessed 2026-11-03).