randomfills.rst 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. .. _css_examples_randomfills:
  2. Fills with randomized symbols
  3. =============================
  4. It is possible to generate fills by randomly repeating a symbol in the polygons to be filled.
  5. Please refer to the :ref:`equivalent SLD chapter <randomized>` for details on the meaning of the various options.
  6. Simple random distribution
  7. --------------------------
  8. Here is an example distributing up to 50 small "slash" symbols in a 100x100 pixel tile (in case of conflicts the symbol will be skipped), enabling random symbol rotation), and setting the seed to "5" to get a distribution different than the default one:
  9. .. code-block:: scss
  10. * {
  11. fill: symbol("shape://slash");
  12. :fill {
  13. size: 8;
  14. stroke: blue;
  15. stroke-width: 4;
  16. stroke-linecap: round;
  17. };
  18. stroke: black;
  19. fill-random: grid;
  20. fill-random-seed: 5;
  21. fill-random-rotation: free;
  22. fill-random-symbol-count: 50;
  23. fill-random-tile-size: 100;
  24. }
  25. .. figure:: ../../sld/extensions/images/random-slash.png
  26. :align: center
  27. *Random distribution of a diagonal line*
  28. Thematic map using point density
  29. --------------------------------
  30. Randomized distributions can also be used for thematic mapping, for example, here is the SLD for a version of topp:states that displays the number of inhabitantìs varying the density of a random point distribution:
  31. .. code-block:: scss
  32. * {
  33. fill: symbol("circle");
  34. stroke: black;
  35. fill-random: grid;
  36. fill-random-tile-size: 100;
  37. :fill {
  38. size: 2;
  39. fill: darkgray;
  40. };
  41. /* @title low */
  42. [PERSONS < 2000000] {
  43. fill-random-symbol-count: 50;
  44. };
  45. /* @title mid */
  46. [PERSONS >= 2000000] [PERSONS < 4000000] {
  47. fill-random-symbol-count: 150;
  48. };
  49. /* @title high */
  50. [PERSONS >= 4000000] {
  51. fill-random-symbol-count: 500;
  52. }
  53. }
  54. .. figure:: ../../sld/extensions/images/states-random.png
  55. :align: center
  56. *Thematic map via point density approach*