Skip to content

Commit b5df451

Browse files
committed
Update utilities.py
1 parent 4c3344f commit b5df451

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

branca/utilities.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ def linear_gradient(hexList: List[str], nColors: int) -> List[str]:
6969
input_color_bytes = [
7070
[int(_hex[i : i + 2], 16) for i in (1, 3, 5)] for _hex in hexList
7171
]
72+
# to have the same output as the previous version of this function we use
73+
# a resolution of 765 'indexes' per color bin.
7274
resolution = 765
7375
n_indexes = resolution * (len(hexList) - 1)
7476
result: List[str] = []
7577
for counter in range(nColors - 1):
7678
fraction_overall = float(counter) / (nColors - 1)
7779
index_overall = int(fraction_overall * (n_indexes - 1))
78-
index_color_bin = index_overall % 765
79-
idx_input = index_overall // 765
80+
index_color_bin = index_overall % resolution
81+
idx_input = index_overall // resolution
8082
fraction = index_color_bin / (resolution - 1)
8183
start = input_color_bytes[idx_input]
8284
end = input_color_bytes[idx_input + 1]

0 commit comments

Comments
 (0)