-
Notifications
You must be signed in to change notification settings - Fork 0
/
scihue.py
46 lines (37 loc) · 1.37 KB
/
scihue.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import streamlit as st
from colorutils.schemes import import_color_schemes
from colorutils.palette import generate_palette
from frontend import ui
# include predefinded color palettes from https://docs.bokeh.org/en/latest/docs/reference/palettes.html
# Constants
MAX_COLORS_IN_PALETTE = 8
DEFAULT_N_COLORS = 7
MIN_N_COLORS = 3
DEFAULT_MAIN_COLOR = "#6D0707"
def random_palette():
all_color_schemes = import_color_schemes()
scheme = ui.select_color_scheme(all_color_schemes)
hue_diff = ui.select_hue_difference(*scheme.hue_diff_settings)
st.divider()
main_hex_color, n_colors = ui.select_main_color_and_number_of_colors(
DEFAULT_MAIN_COLOR,
MIN_N_COLORS,
MAX_COLORS_IN_PALETTE,
DEFAULT_N_COLORS
)
st.divider()
color_palette = generate_palette(main_hex_color, n_colors, scheme.n_hues, hue_diff)
window_width = ui.get_window_width()
if window_width is not None:
n_cols = MAX_COLORS_IN_PALETTE + 1
col_width = ui.calculate_column_width(window_width, n_cols)
ui.show_color_palette(color_palette, n_cols, col_width)
ui.show_rerun_buttons()
ui.current_color_palette(color_palette)
ui.show_saved_color_palettes(col_width, n_cols)
def main():
ui.initialize_session_state()
st.header("Sci-Hue")
random_palette()
if __name__ == "__main__":
main()