0% found this document useful (0 votes)
68 views

Paleta de Colores Python

This document defines a palette of colors as NumPy arrays that are then used to draw rectangles on a Pygame window. It contains code for two different versions of a BarraHerramientas (toolbar) function, one that draws a 3x3 grid of colors and another that draws a continuous color spectrum plus grayscale values. The function is called within a game loop to continuously display the toolbar until the user quits.

Uploaded by

Daniela Marquez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views

Paleta de Colores Python

This document defines a palette of colors as NumPy arrays that are then used to draw rectangles on a Pygame window. It contains code for two different versions of a BarraHerramientas (toolbar) function, one that draws a 3x3 grid of colors and another that draws a continuous color spectrum plus grayscale values. The function is called within a game loop to continuously display the toolbar until the user quits.

Uploaded by

Daniela Marquez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

import pygame as pg

import numpy as np
'''este programa contiene los puntos 1 y 2 del
taller 4, aquí se define una paleta de colores que
luego son utilizados
para mostrar en pantalla y para cambiar entre 1 y
2 solo se debe descomentar uno y comentar el
otro'''

colorBlanco = np.array([255, 255, 255])


colorGris1 = np.array([225, 225, 225])
colorGris2 = np.array([200, 200, 200])
colorGris3 = np.array([175, 175, 175])
colorGris4 = np.array([150, 150, 150])
colorGris5 = np.array([125, 125, 125])
colorGris6 = np.array([100, 100, 100])
colorGris7 = np.array([75, 75, 75])
colorGris8 = np.array([50, 50, 50])
colorGris9 = np.array([25, 25, 25])
colorNegro = np.array([0, 0, 0])
colorAmarillo = np.array([255, 255, 0])
colorAzul = np.array([0, 0, 255])
colorRojo = np.array([255, 0, 0])
colorVerde = np.array([0, 255, 0])
colorNaranja = np.array([255, 127, 0])
colorMorado = np.array([163, 73, 164])
colorCian = np.array([0, 225, 225])
colorMagenta = np.array([255, 20, 147])
colorGris = np.array([150, 152, 154])
colorMarron = np.array([141, 73, 37])
#punto 1
"""def BarraHerramientas(miVentana):
#Area de colores
pg.draw.rect(miVentana, colorCian, [0, 0, 80,
80])
pg.draw.rect(miVentana, colorBlanco, [80, 0,
80, 80])
pg.draw.rect(miVentana, colorRojo, [160, 0,
80, 80])

pg.draw.rect(miVentana, colorMagenta, [0, 80,


80, 80])
pg.draw.rect(miVentana, colorGris, [80, 80,
80, 80])
pg.draw.rect(miVentana, colorVerde, [160, 80,
80, 80])

pg.draw.rect(miVentana, colorAmarillo, [0,


160, 80, 80])
pg.draw.rect(miVentana, colorNegro, [80, 160,
80, 80])
pg.draw.rect(miVentana, colorAzul, [160, 160,
80, 80])"""
#punto2
def BarraHerramientas(miVentana):
#Area de colores
pg.draw.rect(miVentana, colorAmarillo, [0, 0,
40, 300])
pg.draw.rect(miVentana, colorCian, [40, 0, 80,
300])
pg.draw.rect(miVentana, colorVerde, [120, 0,
80, 300])
pg.draw.rect(miVentana, colorMagenta, [200, 0,
80, 300])
pg.draw.rect(miVentana, colorRojo, [280, 0,
80, 300])
pg.draw.rect(miVentana, colorAzul, [360, 0,
80, 300])
pg.draw.rect(miVentana, colorBlanco, [0, 300,
40, 80])
pg.draw.rect(miVentana, colorGris1, [40, 300,
40, 80])
pg.draw.rect(miVentana, colorGris2, [80, 300,
40, 80])
pg.draw.rect(miVentana, colorGris3, [120, 300,
40, 80])
pg.draw.rect(miVentana, colorGris4, [160, 300,
40, 80])
pg.draw.rect(miVentana, colorGris5, [200, 300,
40, 80])
pg.draw.rect(miVentana, colorGris6, [240, 300,
40, 80])
pg.draw.rect(miVentana, colorGris7, [280, 300,
40, 80])
pg.draw.rect(miVentana, colorGris8, [320, 300,
40, 80])
pg.draw.rect(miVentana, colorGris9, [360, 300,
40, 80])
pg.draw.rect(miVentana, colorNegro, [400, 300,
40, 80])

if __name__ == "__main__":
miVentana = pg.display.set_mode((440, 380))
miVentana.fill(colorNegro)
runnig = True

while (runnig):
BarraHerramientas(miVentana)
pg.display.update()
for eventos in pg.event.get():

if (eventos.type == pg.QUIT):
runnig = False
exit()

You might also like