All Downloads are FREE. Search and download functionalities are using the official Maven repository.

Demo.awt.Colors.py Maven / Gradle / Ivy

There is a newer version: 2.7.1.1
Show newest version
"""\
Create a panel showing all of the colors defined in the pawt.colors module
Display the names of bright colors in black and of dark colors in white
"""

from java import awt
from pawt import colors, test
from math import sqrt

p = awt.Panel()
for name in dir(colors):
	color = getattr(colors, name)
	if isinstance(color, awt.Color):
		l = awt.Label(name, awt.Label.CENTER, background=color)
		intensity = sqrt(color.red**2 + color.green**2 + color.blue**2)/3		
		if intensity < 90: l.foreground = colors.white
		p.add(l)

test(p, size=(700,500))




© 2015 - 2025 Weber Informatics LLC | Privacy Policy