ich habe vor mir ein kleines Info-Display zu schreiben, welches mir Wetter und ein paar andere Dinge anzeigen soll.
Das Interface wollte ich in Pygame gestalten, ich brauche keine Userinteraktion und 2 Frames pro Sekunde reichen auch.
Beim Versuch auf ein Hintergrundbild eine weiße leicht transparente Uhrzeit zu zeichnen, bin ich jedoch gescheitert.
Code: Alles auswählen
import os.path
import time
import pygame
pygame.init()
pygame.display.set_caption('Infoframe')
screen = pygame.display.set_mode((1024, 768))
background = pygame.transform.smoothscale(pygame.image.load(os.path.join('data', 'background.jpg')), (screen.get_width(), screen.get_height())).convert()
font = pygame.font.Font(pygame.font.get_default_font(), 90)
text = font.render(time.strftime('%H : %M : %S'), True, (255, 255, 255))
text.set_alpha(100)
screen.blit(background, (0, 0))
screen.blit(text, (0, 0))
pygame.display.flip()
time.sleep(5)
Die Pygame Dokumentation sagt dazu:
Ich denke also, das ich diese pro Pixel Transparenz habe.Set the current alpha value fo r the Surface. When blitting this Surface onto a destination, the pixels will be drawn slightly transparent. The alpha value is an integer from 0 to 255, 0 is fully transparent and 255 is fully opaque. If None is passed for the alpha value, then the Surface alpha will be disabled.
This value is different than the per pixel Surface alpha. If the Surface format contains per pixel alphas, then this alpha value will be ignored. If the Surface contains per pixel alphas, setting the alpha value to None will disable the per pixel transparency.
Wenn ich den Text mit convert() oder convert_alpha() konvertiere, dann bekomme ich einen transparenten weißen Balken.
Es muss doch irgendwie möglich sein einen Text transparent zu machen, oder?
Als Hintergrundbild verwende ich folgendes:
http://gnome-look.org/content/show.php/ ... tent=68175
Viele Grüße und vielen Dank
Maxi