Skip to content

Commit

Permalink
feat: generate random color with more than 10 ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
merydian committed Jun 7, 2024
1 parent 19300dd commit 0b2cc85
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ORStools/common/isochrones_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* *
***************************************************************************/
"""

from random import random
from typing import Any, Generator

from qgis._core import QgsMapLayer
Expand Down Expand Up @@ -203,9 +203,12 @@ def stylePoly(self, layer: QgsMapLayer) -> None:
# initialize the default symbol for this geometry type
symbol = QgsSymbol.defaultSymbol(layer.geometryType())

# set color
color = colors[cid] if colors[cid] else QColor("%06x" % random.randint(0, 0xFFFFFF))

# configure a symbol layer
symbol_layer = QgsSimpleFillSymbolLayer(
color=colors[cid], strokeColor=QColor("#000000")
color=color, strokeColor=QColor("#000000")
)

# replace default symbol layer with the configured one
Expand Down

0 comments on commit 0b2cc85

Please sign in to comment.