コード例 #1
0
 def random_circles(cls, n=50, rmin=5, rmax=50, background=BGCOLOR, pcolor=None):
     """ Return a canvas populated with n randomly positioned circles.  
     Radius ranges vary randomly between 5 and 50."""
     from random import randint as RIT
                    
     particles = ParticleManager()            
     # Randomize particle centers within the image default dimensions
     for i in range(n):
         cx, cy = RIT(0, BGRES[0]), RIT(0, BGRES[1])
         radius = RIT(rmin,rmax)
         particles.add('circle', center=(cx,cy), radius=radius, 
                       color=to_normrgb(pcolor))
     
     # Use default resolution and grid
     return cls(background=background, particles=particles)
コード例 #2
0
 def random_triangles(cls, n=50, lmin=5, lmax=50, background=BGCOLOR, pcolor=None):
     """ Return a canvas populated with n randomly positioned circles.  
     Radius ranges vary randomly between 5 and 50."""
     from random import randint as RIT
                    
     particles = ParticleManager()            
     # Randomize particle centers within the image default dimensions
     for i in range(n):
         # ADD PADDING ADHOC AT THE MOMENT!!
         PAD = 2*lmax
         cx, cy = RIT(0+PAD, BGRES[0]-PAD), RIT(0+PAD, BGRES[1]-PAD)
         length = RIT(lmin,lmax)
         particles.add('triangle', center=(cx,cy), length=length, 
                       color=to_normrgb(pcolor))
     
     # Use default resolution and grid
     return cls(background=background, particles=particles)