modes.rst 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. .. _sld-extensions_composite-blend_modes:
  2. Composite and blending modes
  3. ============================
  4. There are two types of modes: alpha composite and color blending.
  5. Alpha compositing controls how two images are merged together by using the alpha levels of the two. No color mixing is being performed, only pure binary selection (either one or the other).
  6. Color blending modes mix the colors of source and destination in various ways. Each pixel in the result will be some sort of combination between the source and destination pixels.
  7. The following page shows the full list of available modes. (See the :ref:`syntax <sld-extensions_composite-blend_syntax>` page for more details.) To aid in comprehension, two source and two destination images will be used to show visually how each mode works:
  8. .. list-table::
  9. :widths: 50 50
  10. :header-rows: 1
  11. * - Source 1
  12. - Source 2
  13. * - .. figure:: images/map.png
  14. - .. figure:: images/map2.png
  15. .. list-table::
  16. :widths: 50 50
  17. :header-rows: 1
  18. * - Destination 1
  19. - Destination 2
  20. * - .. figure:: images/bkg.png
  21. - .. figure:: images/bkg2.png
  22. Alpha compositing modes
  23. -----------------------
  24. copy
  25. ^^^^
  26. Only the source will be present in the output.
  27. .. list-table::
  28. :widths: 50 50
  29. :header-rows: 1
  30. * - Example 1
  31. - Example 2
  32. * - .. figure:: images/blend1-copy.png
  33. - .. figure:: images/blend2-copy.png
  34. destination
  35. ^^^^^^^^^^^
  36. Only the destination will be present in the output
  37. .. list-table::
  38. :widths: 50 50
  39. :header-rows: 1
  40. * - Example 1
  41. - Example 2
  42. * - .. figure:: images/blend1-destination.png
  43. - .. figure:: images/blend2-destination.png
  44. source-over
  45. ^^^^^^^^^^^
  46. The source is drawn over the destination, and the destination is visible where the source is transparent. Opposite of *destination-over*.
  47. .. list-table::
  48. :widths: 50 50
  49. :header-rows: 1
  50. * - Example 1
  51. - Example 2
  52. * - .. figure:: images/blend1-source-over.png
  53. - .. figure:: images/blend2-source-over.png
  54. destination-over
  55. ^^^^^^^^^^^^^^^^
  56. The source is drawn below the destination, and is visible only when the destination is transparent. Opposite of *source-over*.
  57. .. list-table::
  58. :widths: 50 50
  59. :header-rows: 1
  60. * - Example 1
  61. - Example 2
  62. * - .. figure:: images/blend1-destination-over.png
  63. - .. figure:: images/blend2-destination-over.png
  64. source-in
  65. ^^^^^^^^^
  66. The source is visible only when overlapping some non-transparent pixel of the destination. This allows the background map to act as a mask for the layer/feature being drawn. Opposite of *destination-in*.
  67. .. list-table::
  68. :widths: 50 50
  69. :header-rows: 1
  70. * - Example 1
  71. - Example 2
  72. * - .. figure:: images/blend1-source-in.png
  73. - .. figure:: images/blend2-source-in.png
  74. destination-in
  75. ^^^^^^^^^^^^^^
  76. The destination is retained only when overlapping some non transparent pixel in the source. This allows the layer/feature to be drawn to act as a mask for the background map. Opposite of *source-in*.
  77. .. list-table::
  78. :widths: 50 50
  79. :header-rows: 1
  80. * - Example 1
  81. - Example 2
  82. * - .. figure:: images/blend1-destination-in.png
  83. - .. figure:: images/blend2-destination-in.png
  84. source-out
  85. ^^^^^^^^^^
  86. The source is retained only in areas where the destination is transparent. This acts as a reverse mask when compared to *source-in*.
  87. .. list-table::
  88. :widths: 50 50
  89. :header-rows: 1
  90. * - Example 1
  91. - Example 2
  92. * - .. figure:: images/blend1-source-out.png
  93. - .. figure:: images/blend2-source-out.png
  94. destination-out
  95. ^^^^^^^^^^^^^^^
  96. The destination is retained only in areas where the source is transparent. This acts as a reverse mask when compared to *destination-in*.
  97. .. list-table::
  98. :widths: 50 50
  99. :header-rows: 1
  100. * - Example 1
  101. - Example 2
  102. * - .. figure:: images/blend1-destination-out.png
  103. - .. figure:: images/blend2-destination-out.png
  104. source-atop
  105. ^^^^^^^^^^^
  106. The destination is drawn fully, while the source is drawn only where it intersects the destination.
  107. .. list-table::
  108. :widths: 50 50
  109. :header-rows: 1
  110. * - Example 1
  111. - Example 2
  112. * - .. figure:: images/blend1-source-atop.png
  113. - .. figure:: images/blend2-source-atop.png
  114. destination-atop
  115. ^^^^^^^^^^^^^^^^
  116. The source is drawn fully, and the destination is drawn over the source and only where it intersects it.
  117. .. list-table::
  118. :widths: 50 50
  119. :header-rows: 1
  120. * - Example 1
  121. - Example 2
  122. * - .. figure:: images/blend1-destination-atop.png
  123. - .. figure:: images/blend2-destination-atop.png
  124. xor
  125. ^^^
  126. "Exclusive Or" mode. Each pixel is rendered only if either the source or the destination is not
  127. blank, but not both.
  128. .. list-table::
  129. :widths: 50 50
  130. :header-rows: 1
  131. * - Example 1
  132. - Example 2
  133. * - .. figure:: images/blend1-xor.png
  134. - .. figure:: images/blend2-xor.png
  135. Color blending modes
  136. --------------------
  137. multiply
  138. ^^^^^^^^
  139. The source color is multiplied by the destination color and replaces the destination. The resulting color is always at least as dark as either the source or destination color. Multiplying any color with black results in black. Multiplying any color with white preserves the original color.
  140. .. list-table::
  141. :widths: 50 50
  142. :header-rows: 1
  143. * - Example 1
  144. - Example 2
  145. * - .. figure:: images/blend1-multiply.png
  146. - .. figure:: images/blend2-multiply.png
  147. screen
  148. ^^^^^^
  149. Multiplies the complements of the source and destination color values, then complements the result. The end result color is always at least as light as either of the two constituent colors. Screening any color with white produces white; screening with black leaves the original color unchanged.
  150. The effect is similar to projecting multiple photographic slides simultaneously onto a single screen.
  151. .. list-table::
  152. :widths: 50 50
  153. :header-rows: 1
  154. * - Example 1
  155. - Example 2
  156. * - .. figure:: images/blend1-screen.png
  157. - .. figure:: images/blend2-screen.png
  158. overlay
  159. ^^^^^^^
  160. Multiplies (screens) the colors depending on the destination color value. Source colors overlay the destination while preserving its highlights and shadows. The backdrop color is not replaced but is mixed with the source color to reflect the lightness or darkness of the backdrop.
  161. .. list-table::
  162. :widths: 50 50
  163. :header-rows: 1
  164. * - Example 1
  165. - Example 2
  166. * - .. figure:: images/blend1-overlay.png
  167. - .. figure:: images/blend2-overlay.png
  168. darken
  169. ^^^^^^
  170. Selects the darker of the destination and source colors. The destination is replaced with the source only where the source is darker.
  171. .. list-table::
  172. :widths: 50 50
  173. :header-rows: 1
  174. * - Example 1
  175. - Example 2
  176. * - .. figure:: images/blend1-darken.png
  177. - .. figure:: images/blend2-darken.png
  178. lighten
  179. ^^^^^^^
  180. Selects the lighter of the destination and source colors. The destination is replaced with the source only where the source is lighter.
  181. .. list-table::
  182. :widths: 50 50
  183. :header-rows: 1
  184. * - Example 1
  185. - Example 2
  186. * - .. figure:: images/blend1-lighten.png
  187. - .. figure:: images/blend2-lighten.png
  188. color-dodge
  189. ^^^^^^^^^^^
  190. Brightens the destination color to reflect the source color. Drawing with black produces no changes.
  191. .. list-table::
  192. :widths: 50 50
  193. :header-rows: 1
  194. * - Example 1
  195. - Example 2
  196. * - .. figure:: images/blend1-color-dodge.png
  197. - .. figure:: images/blend2-color-dodge.png
  198. color-burn
  199. ^^^^^^^^^^
  200. Darkens the destination color to reflect the source color. Drawing with white produces no change.
  201. .. list-table::
  202. :widths: 50 50
  203. :header-rows: 1
  204. * - Example 1
  205. - Example 2
  206. * - .. figure:: images/blend1-color-burn.png
  207. - .. figure:: images/blend2-color-burn.png
  208. hard-light
  209. ^^^^^^^^^^
  210. Multiplies or screens the colors, depending on the source color value. The effect is similar to shining a harsh spotlight on the destination.
  211. .. list-table::
  212. :widths: 50 50
  213. :header-rows: 1
  214. * - Example 1
  215. - Example 2
  216. * - .. figure:: images/blend1-hard-light.png
  217. - .. figure:: images/blend2-hard-light.png
  218. soft-light
  219. ^^^^^^^^^^
  220. Darkens or lightens the colors, depending on the source color value. The effect is similar to shining a diffused spotlight on the destination.
  221. .. list-table::
  222. :widths: 50 50
  223. :header-rows: 1
  224. * - Example 1
  225. - Example 2
  226. * - .. figure:: images/blend1-soft-light.png
  227. - .. figure:: images/blend2-soft-light.png
  228. difference
  229. ^^^^^^^^^^
  230. Subtracts the darker of the two constituent colors from the lighter color. White inverts the destination color; black produces no change.
  231. .. list-table::
  232. :widths: 50 50
  233. :header-rows: 1
  234. * - Example 1
  235. - Example 2
  236. * - .. figure:: images/blend1-difference.png
  237. - .. figure:: images/blend2-difference.png
  238. exclusion
  239. ^^^^^^^^^
  240. Produces an effect similar to that of *difference* but lower in contrast. White inverts the destination color; black produces no change.
  241. .. list-table::
  242. :widths: 50 50
  243. :header-rows: 1
  244. * - Example 1
  245. - Example 2
  246. * - .. figure:: images/blend1-exclusion.png
  247. - .. figure:: images/blend2-exclusion.png