pygame color picker

Solutions on MaxInterview for pygame color picker by the best coders in the world

showing results for - "pygame color picker"
Eric
08 Feb 2017
1from hooman import Hooman
2import pygame
3
4window_width, window_height = 500, 500
5hapi = Hooman(window_width, window_height)
6
7
8slider_options = {"value_range": [0, 255]}
9
10r_slider = hapi.slider(50, 300, 400, 10, slider_options)
11g_slider = hapi.slider(50, 330, 400, 10, slider_options)
12b_slider = hapi.slider(50, 360, 400, 10, slider_options)
13
14while hapi.is_running:
15    bg_col = (r_slider.value(), g_slider.value(), b_slider.value())
16    hapi.background(bg_col)
17
18    r_slider.update()
19    g_slider.update()
20    b_slider.update()
21
22    hapi.fill(hapi.color["black"])
23    r_text = "r:{}".format(r_slider.value())
24    hapi.text(r_text, 50, 280)
25    g_text = "g:{}".format(g_slider.value())
26    hapi.text(g_text, 50, 310)
27    b_text = "b:{}".format(b_slider.value())
28    hapi.text(b_text, 50, 340)
29
30    hapi.flip_display()
31    hapi.event_loop()
32
33pygame.quit()
34