Ejemplo n.º 1
0
 def manipulateACanvas(self, canvas):
     canvas.reposition(*rndpt(self.width, self.height))
     canvas.S = S = canvas.sound('http://localhost/amen.mp3')
     S.play(timesLoop=5)
     for x in range(random.randint(1, 4)):
         canvas.pen( 
             random.randint(1, 10),
             random.randint(0, 0xffffff),
             random.randint(0, 100))
         canvas.move(*rndpt(self.width, self.height))
         choice = random.randint(0, 4)
         if choice == 0:
             canvas.line(*rndpt(self.width, self.height))
         elif choice == 1:
             canvas.fill(random.randint(0, 0xffffff), random.randint(0, 100))
             for x in range(random.randint(3, 20)):
                 if random.randint(0, 1):
                     canvas.line(*rndpt(self.width, self.height))
                 else:
                     canvas.curve(*rndrct(self.width, self.height))
             canvas.close()
         elif choice == 2:
             canvas.curve(*rndrct(self.width, self.height))
         elif choice == 3:
             T = canvas.text(random.choice(self.original), *(0,0,400,100))
             # This is an example of how you can hold on to drawing objects and continue to
             # draw on them later, because the CanvasSocket holds itself open until done() is called
             Textorizer(T, self.width, self.height)
         else:
             # This demo requires a folder of images which I don't want to put in
             # the nevow source. Hooking this up is left as an exercise for the reader.
             continue
             imgname = random.choice(os.listdir("flsh/images"))
             I = canvas.image('/images/%s' % imgname)
             I.scale(*rndp())
             I.alpha(random.randint(0, 100))
             rotate = random.randint(-180, 180)
             I.rotate(rotate)
             I.move(*rndpt(self.width, self.height))
Ejemplo n.º 2
0
 def manipulateACanvas(self, canvas):
     canvas.reposition(*rndpt(self.width, self.height))
     canvas.S = S = canvas.sound('http://localhost/amen.mp3')
     S.play(timesLoop=5)
     for x in range(random.randint(1, 4)):
         canvas.pen( 
             random.randint(1, 10),
             random.randint(0, 0xffffff),
             random.randint(0, 100))
         canvas.move(*rndpt(self.width, self.height))
         choice = random.randint(0, 4)
         if choice == 0:
             canvas.line(*rndpt(self.width, self.height))
         elif choice == 1:
             canvas.fill(random.randint(0, 0xffffff), random.randint(0, 100))
             for x in range(random.randint(3, 20)):
                 if random.randint(0, 1):
                     canvas.line(*rndpt(self.width, self.height))
                 else:
                     canvas.curve(*rndrct(self.width, self.height))
             canvas.close()
         elif choice == 2:
             canvas.curve(*rndrct(self.width, self.height))
         elif choice == 3:
             T = canvas.text(random.choice(self.original), *(0,0,400,100))
             # This is an example of how you can hold on to drawing objects and continue to
             # draw on them later, because the CanvasSocket holds itself open until done() is called
             Textorizer(T, self.width, self.height)
         else:
             # This demo requires a folder of images which I don't want to put in
             # the nevow source. Hooking this up is left as an exercise for the reader.
             continue
             imgname = random.choice(os.listdir("flsh/images"))
             I = canvas.image('/images/%s' % imgname)
             I.scale(*rndp())
             I.alpha(random.randint(0, 100))
             rotate = random.randint(-180, 180)
             I.rotate(rotate)
             I.move(*rndpt(self.width, self.height))
Ejemplo n.º 3
0
 def onKeyDown(self, canvas, key):
     if hasattr(canvas, 'x'):
         T = canvas.text(key, canvas.x, canvas.y, 200, 200)
         T.size(random.randint(9, 48))
         T.listFonts().addCallback(lambda fnts: T.font(random.choice(fnts)))
         canvas.x += 15
Ejemplo n.º 4
0
 def onKeyDown(self, canvas, key):
     if hasattr(canvas, 'x'):
         T = canvas.text(key, canvas.x, canvas.y, 200, 200)
         T.size(random.randint(9, 48))
         T.listFonts().addCallback(lambda fnts: T.font(random.choice(fnts)))
         canvas.x += 15