Ich habe ein Feld mit RectNodes (libavg) und würde diese gerne für eine gewisse Zeit aufleuchten lassen, sprich in einer anderen Farbe darstellen. Außerdem würde ich diese Farbänderung gerne mit einem Fade-In/Out realisieren, habe aber keine Ahnung, wie ich das realisieren soll und google war da auch nicht sonderlich erfolgreich.
Mein Code ist momentan folgender:
Code: Alles auswählen
from libavg import *
from PIL. ExifTags import TAGS
from PIL import *
import sys
import os
from Xlib import *
import pygame
class design(object):
def __init__(self):
player = avg.Player.get()
pygame.init()
screenwidth = pygame.display.list_modes()[0][0]
screenheight = pygame.display.list_modes()[0][1]
print(screenwidth)
print(screenheight)
self.x = 1066
self.y = 600
#self.x = screenwidth
#self.y = screenheight
self.wire = self.x/16
self.heire = self.y/9
self.bgcolorb = "A4A4A4"
#"BE4F4F"
self.bgcolorn = "313F89"
self.outlc = "000000"
canvas = player.createMainCanvas(size=(self.x,self.y))
self.RootNode = canvas.getRootNode()
self.left = avg.DivNode(size=(self.x,self.y), pos=(0,0), crop=False, elementoutlinecolor="123456", parent=self.RootNode)
bg = avg.ImageNode(pos=(0,0), size=(self.x,self.y), href="./img1.jpg", parent=self.RootNode)
#auswahl-rects
r1 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(0,0), color=self.outlc, fillcolor=self.bgcolorn, fillopacity=0, parent=self.RootNode)
r2 = avg.RectNode(size=(2*self.wire,3*self.heire), pos=(0,3*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r3 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(0,7*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r4 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(2*self.wire,self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r5 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(2*self.wire,6*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r6 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(4*self.wire,2*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r7 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(4*self.wire,5*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r8 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(5*self.wire,0*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r9 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(5*self.wire,7*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r10 = avg.RectNode(size=(2*self.wire,3*self.heire), pos=(6*self.wire,3*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r11 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(7*self.wire,0), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r12 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(7*self.wire,7*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r13 = avg.RectNode(size=(2*self.wire,3*self.heire), pos=(8*self.wire,3*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r14 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(9*self.wire,0), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r15 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(9*self.wire,7*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r16 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(10*self.wire,2*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r17 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(10*self.wire,5*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r18 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(12*self.wire,self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r19 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(12*self.wire,6*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r20 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(14*self.wire,0), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r21 = avg.RectNode(size=(2*self.wire,3*self.heire), pos=(14*self.wire,3*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
r22 = avg.RectNode(size=(2*self.wire,2*self.heire), pos=(14*self.wire,7*self.heire), opacity=1, color=self.outlc, fillcolor=self.bgcolorn, fillopacity=1, parent=self.RootNode)
#bg-rects, verschwinden/fallen am ende des levels (runter)/werden ausgeblendet...
f1 = avg.RectNode(size=(2*self.wire,self.heire), pos=(0,2*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=50, parent=self.RootNode)
f2 = avg.RectNode(size=(2*self.wire,self.heire), pos=(0,6*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f3 = avg.RectNode(size=(2*self.wire,self.heire), pos=(2*self.wire,0), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f4 = avg.RectNode(size=(self.wire,2*self.heire), pos=(4*self.wire,0), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f5 = avg.RectNode(size=(2*self.wire,self.heire), pos=(2*self.wire,3*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f6 = avg.RectNode(size=(2*self.wire,self.heire), pos=(2*self.wire,4*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f7 = avg.RectNode(size=(2*self.wire,self.heire), pos=(2*self.wire,5*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f8 = avg.RectNode(size=(2*self.wire,self.heire), pos=(4*self.wire,4*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f9 = avg.RectNode(size=(2*self.wire,self.heire), pos=(2*self.wire,8*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f10 = avg.RectNode(size=(self.wire,2*self.heire), pos=(4*self.wire,7*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f11 = avg.RectNode(size=(2*self.wire,self.heire), pos=(6*self.wire,2*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f12 = avg.RectNode(size=(2*self.wire,self.heire), pos=(8*self.wire,2*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f13 = avg.RectNode(size=(2*self.wire,self.heire), pos=(6*self.wire,6*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f14 = avg.RectNode(size=(2*self.wire,self.heire), pos=(8*self.wire,6*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f15 = avg.RectNode(size=(self.wire,2*self.heire), pos=(11*self.wire,0), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f16 = avg.RectNode(size=(2*self.wire,self.heire), pos=(12*self.wire,0), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f17 = avg.RectNode(size=(2*self.wire,self.heire), pos=(10*self.wire,4*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f18 = avg.RectNode(size=(2*self.wire,self.heire), pos=(12*self.wire,3*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f19 = avg.RectNode(size=(2*self.wire,self.heire), pos=(12*self.wire,4*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f20 = avg.RectNode(size=(2*self.wire,self.heire), pos=(12*self.wire,5*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f21 = avg.RectNode(size=(self.wire,2*self.heire), pos=(11*self.wire,7*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f22 = avg.RectNode(size=(2*self.wire,self.heire), pos=(12*self.wire,8*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f23 = avg.RectNode(size=(2*self.wire,self.heire), pos=(14*self.wire,2*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
f24 = avg.RectNode(size=(2*self.wire,self.heire), pos=(14*self.wire,6*self.heire), color=self.outlc, fillcolor=self.bgcolorb, fillopacity=1, parent=self.RootNode)
player.play()
design()
Hat jmd. Ideen?
MfG
meischder