#A canvas is created offscreen and a gradient of lines is scattered #over it, shading from white to black from left to right. #there are a couple of other bands of shading: a rectangular #region near the top and a sinusoidal curve of circles. import math def putCanvas(c): xList = range(0,101) xList.reverse() for x in xList: for y in range(0,101): g.setPixel(x,y,canvas[x][y]) def sqr(val): return val*val SEED = 343545 def nextRand(val): return (val*3 + 234955457) % 12345676 def random(seedValue, maxVal): return (seedValue % maxVal) def PUTPixel(x, y, color): if int(1234567 * math.sqrt((x%(y+1))+(y%(x+1))+(3*x)+(3*y)+sqr(100-x)+sqr(100-y)))%100 <= canvas[x][y]: g.setPixel(x,y,100) else: g.setPixel(x,y,0) def putCanvasSpeckled(c): for x in range(0,101): for y in range(0,101): PUTPixel(x,y,c[x][y]) def c_setPixel(c, x, y, color): if x >= 0: if x <= 100: if y >= 0: if y <= 100: c[x][y] = color return c def c_grabScreen(): c = [] for i in range(0,101): c.append(range(0,101)) for x in range(0,101): for y in range(0,101): c[x][y] = g.getPixel(x,y) return c def c_line(c, x1,y1,x2,y2, color): if x1 == x2: if y1 > y2: t = y1 y1 = y2 y2 = t for y in range(y1,y2): c = c_setPixel(c, x1,y, color) return c if x1 > x2: t = x1 x1 = x2 x2 = t t = y1 y1 = y2 y2 = t if y1 == y2: for x in range(x1,x2): c = c_setPixel(c, x,y1, color) return c cx = x1 cy = y1 yi = 0 if y1 > y2: while cx <= x2: yi = yi + (y1-y2) while yi > (x2-x1): cy = cy - 1 c = c_setPixel(c, cx, cy, color) yi = yi - (x2-x1) cx = cx + 1 else: while cx <= x2: yi = yi + (y2-y1) while yi > (x2-x1): cy = cy + 1 c = c_setPixel(c, cx, cy, color) yi = yi - (x2-x1) cx = cx + 1 return c def c_circle(c, cx, cy, rad, color): for x in range(cx-rad, cx+rad+1): yRad = int(math.sqrt(sqr(rad)-sqr(x-cx))+0.5) for y in range(cy-yRad, cy+yRad): c = c_setPixel(c,x,y,color) return c def c_thickLine(c, x1,y1,x2,y2, color): c_line(c, x1,y1,x2,y2, color) c_line(c, x1-1,y1,x2-1,y2, color) c_line(c, x1,y1-1,x2,y2-1, color) c_line(c, x1+1,y1,x2+1,y2, color) c_line(c, x1,y1+1,x2,y2+1, color) return c g.field(0,0,101,101,50) canvas = c_grabScreen() for i in range(0, 150): SEED = nextRand(SEED) x1 = random(SEED, 200) - 50 SEED = nextRand(SEED) y1 = random(SEED, 200) - 50 SEED = nextRand(SEED) x2 = random(SEED, 200) - 50 SEED = nextRand(SEED) y2 = random(SEED, 200) - 50 canvas = c_thickLine(canvas, x1,y1,x2,y2,(x1+x2)/2) for x in range(0, 101): canvas = c_line(canvas, x,101-(x*4/10),x,101, x) for a in range(0, 40): canvas = c_circle(canvas, 40+a*2, 15+int(20-20*math.sin(a/4.0)), a/2, a*100/40) for a in range(0, 40): canvas = c_circle(canvas, 40-a*2, 15+int(20-20*math.sin(a/4.0)), a/2, 0) putCanvas(canvas) putCanvasSpeckled(canvas)