def setup(): size(500, 500, P2D) import random def draw (): Evaporation(15, 15, [128,128,128], [100,100,100], 1, 20, 10, 2) def RGBValue (r): # Makes sure r is in the correct range (that is, between 0 and 1). if r < 0: return 0 else: if r > 255: return 255 else: return r def RandomColor(base, rgbvar, tolerance): import random mycolor = [RGBValue(base[count] + tolerance * random.random() * rgbvar[count]) for count in range(3)] return color(mycolor[0], mycolor[1], mycolor[2]) # Parameters which may be changed: ## width : (number of circles) ## height: (number of circles) ## color : in RGB values ## exp : the exponent for the gradient (1 for linear, 2 for quadratic, etc.) ## r : base radius for circles ## rvar : how much randomness to add to circle radii ## seed : random number seed - keep track of this, since it really does affect your image! def Evaporation(width, height, color, rgbvar, exp, r, rvar, rseed): import random disks = [] # Saves the points in the final image. random.seed(rseed) for i in range(width): for j in range(height): stroke(RandomColor(color, rgbvar, ((height-j)/height)^exp)) strokeWeight(r + rvar * random.random()) point(50 + 30*i, 450 - 30*j)