mirror of
https://github.com/enzet/map-machine.git
synced 2025-06-10 23:01:53 +02:00
Fix code style.
This commit is contained in:
parent
c9fe5e55b6
commit
2667ee9d02
16 changed files with 228 additions and 240 deletions
|
@ -1,3 +1,8 @@
|
|||
"""
|
||||
Röntgen project. Color utility.
|
||||
|
||||
Author: Sergey Vartanov (me@enzet.ru)
|
||||
"""
|
||||
from typing import Any, List
|
||||
|
||||
from colour import Color
|
||||
|
@ -10,9 +15,8 @@ def is_bright(color: Color) -> bool:
|
|||
Is color bright enough to have black outline instead of white.
|
||||
"""
|
||||
return (
|
||||
0.2126 * color.red * 256 +
|
||||
0.7152 * color.green * 256 +
|
||||
0.0722 * color.blue * 256 > 200)
|
||||
0.2126 * color.red + 0.7152 * color.green + 0.0722 * color.blue
|
||||
> 0.78125)
|
||||
|
||||
|
||||
def get_gradient_color(value: Any, bounds: MinMax, colors: List[Color]):
|
||||
|
@ -30,9 +34,9 @@ def get_gradient_color(value: Any, bounds: MinMax, colors: List[Color]):
|
|||
0 if bounds.max_ == bounds.min_ else
|
||||
(value - bounds.min_) / (bounds.max_ - bounds.min_))
|
||||
coefficient = min(1.0, max(0.0, coefficient))
|
||||
m: int = int(coefficient * color_length)
|
||||
color_coefficient = (coefficient - m / color_length) * color_length
|
||||
index: int = int(coefficient * color_length)
|
||||
color_coefficient = (coefficient - index / color_length) * color_length
|
||||
|
||||
return Color(rgb=[
|
||||
scale[m].rgb[i] + color_coefficient *
|
||||
(scale[m + 1].rgb[i] - scale[m].rgb[i]) for i in range(3)])
|
||||
scale[index].rgb[i] + color_coefficient *
|
||||
(scale[index + 1].rgb[i] - scale[index].rgb[i]) for i in range(3)])
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue