Diferències

Ací es mostren les diferències entre la revisió seleccionada i la versió actual de la pàgina.

Enllaç a la visualització de la comparació

info:cursos:pue:python-pcpp1:m3:1.4 [23/12/2023 20:01] – creat mateinfo:cursos:pue:python-pcpp1:m3:1.4 [23/12/2023 20:05] (actual) mate
Línia 79: Línia 79:
 {{ :info:cursos:pue:python-pcpp1:m3:pasted:20231223-110114.png }} {{ :info:cursos:pue:python-pcpp1:m3:pasted:20231223-110114.png }}
  
-Setting non-zero values for more than one component produces intermediate colors, e.g. red and blue set to 255 with green set to 0 gives the violet.+Setting non-zero values for more than one component produces **intermediate colors**, e.g. red and blue set to 255 with green set to 0 gives the **violet**.
  
 {{ :info:cursos:pue:python-pcpp1:m3:pasted:20231223-110141.png }} {{ :info:cursos:pue:python-pcpp1:m3:pasted:20231223-110141.png }}
  
 +It seems clear, doesn't it?
 +
 +OK, but how to specify all these (more than 16 million) mixes in a comprehensive way?
 +
 +It's is done by a trick used extensively in web pages – as a **string** starting with a **hash** (#) followed by **6 hexadecimal** digits. Each p**air of the digits** forms the value from range **0x00..0xFF** (0..255) what determines the specific component level.
 +
 +This is how it works:
 +
 +{{ :info:cursos:pue:python-pcpp1:m3:pasted:20231223-110314.png }}
 +
 +All three pairs (RR, GG and GG) are **two-digit hexadecimal number** so:
 +
 +  * #000000 is **black**
 +  * #FFFFFF is **white**
 +  * #FF0000 is **red**
 +  * #00FF00 is **green**
 +  * #0000FF is **blue**
 +  * #00FFFF is **turquoise**
 +  * #FF00FF is **violet**
 +  * ...
 +
 +
 +Please, forgive us that we made that list so short. To tell the truth, we have no idea how to name each of these 16 million colors – do you?
 +
 +Note: when all the components are set to the **same value**, equal neither to zero nor to 0xFF (e.g. #0F0F0F0), you will get **254 shades of gray**.
 +
 +Look at the code in the editor. We want to show you a little test showing how the RGB works:
 +
 +<code python>
 +import tkinter as tk
 +
 +window = tk.Tk()
 +button = tk.Button(window, text="Button #1",
 +                   bg="#9370DB",
 +                   fg="#FFA07A",
 +                   activeforeground="#FFF0F5",
 +                   activebackground="#FF69B4")
 +button.pack()
 +window.mainloop()
 +
 +</code>
 +
 +Do the colors look the same as in the previous code?
 +
 +They should look the same as we used RGB equivalents of the previously used ''tkinter'' color names.
 +
 +Now try to find RGB codes for all your favorite colors. There are so many choices – don't feel lost!
  • info/cursos/pue/python-pcpp1/m3/1.4.1703358110.txt.gz
  • Darrera modificació: 06/07/2026 18:29
  • (edició externa)