MCPcopy Create free account
hub / github.com/geekcomputers/Python / simpleColor

Function simpleColor

Colors/primary_colors.py:8–167  ·  view source on GitHub ↗

simpleColor obtiene el nombre del color mas general al cual se acerca su formato R G B

(r, g, b)

Source from the content-addressed store, hash-verified

6
7
8def simpleColor(r, g, b):
9 """simpleColor obtiene el nombre del color mas general al cual se acerca su formato R G B"""
10 r = int(r)
11 g = int(g)
12 b = int(b)
13 bg = ir = 0 # TODO: Fix these variables
14 try:
15 # ROJO --------------------------------------------------
16 if r > g and r > b:
17 rg = diff(r, g) # distancia rojo a verde
18 rb = diff(r, b) # distancia rojo a azul
19
20 if g < 65 and b < 65 and rg > 60: # azul y verde sin luz
21 return "ROJO"
22
23 gb = diff(g, b) # distancia de verde a azul
24
25 if rg < rb: # Verde mayor que Azul
26 if gb < rg: # Verde mas cerca de Azul
27 if gb >= 30 and rg >= 80:
28 return "NARANJA"
29 elif gb <= 20 and rg >= 80:
30 return "ROJO"
31 elif gb <= 20 and b > 175:
32 return "CREMA"
33
34 else:
35 return "CHOCOLATE"
36 else: # Verde mas cerca de Rojo
37 if rg > 60:
38 return "NARANJA*"
39 elif r > 125:
40 return "AMARILLO"
41 else:
42 return "COCHOLATE"
43 elif rg > rb: # Azul mayor que verde
44 if bg < rb: # Verde mas cerca de Azul
45 if gb < 60:
46 if r > 150:
47 return "ROJO 2"
48 else:
49 return "MARRON"
50 elif g > 125:
51 return "ROSADO"
52 else:
53 return "ROJO 3"
54 else: # Verde mas cerca de Rojo
55 if rb < 60:
56 if r > 160:
57 return "ROSADO*"
58 else:
59 return "ROJO"
60 else:
61 return "ROJO"
62
63 else: # g y b iguales
64 if rg > 20:
65 if r >= 100 and b < 60:

Callers 1

primary_colors.pyFile · 0.85

Calls 1

diffFunction · 0.85

Tested by

no test coverage detected