/* Circles ------- This script draws a bunch of colored circles to form a tileable texture. Author: Andreas Jonsson Created: April 23rd, 2003 Updated: July 28th, 2005 Texture Generator version 1.1.0 */ randomizer rnd; void circle(image @img, int cx, int cy, int r, int thickness, float red, float green, float blue) { int w = img.width; int h = img.height; int x, y, count; count = r + thickness; if( cx - count < 0 ) cx = cx + w; if( cy - count < 0 ) cy = cy + h; x = 0; while( x <= count ) { y = 0; while( y <= count ) { int pr = int(sqrt(float(x*x + y*y))); if( (pr < r + thickness/2) and (pr >= r - thickness/2) ) { int px, py; px = (cx+x)%w; py = (cy+y)%h; img.Pixel(px, py) = pixel(red, green, blue); px = (cx-x)%w; py = (cy+y)%h; img.Pixel(px, py) = pixel(red, green, blue); px = (cx-x)%w; py = (cy-y)%h; img.Pixel(px, py) = pixel(red, green, blue); px = (cx+x)%w; py = (cy-y)%h; img.Pixel(px, py) = pixel(red, green, blue); } y++; } x++; } } void main() { int m = 4; image @img = @image(m*256, m*256); int n = 0; while( n++ < 20 ) { circle(@img, m*int(256.0*rnd.getNumber()), m*int(256.0*rnd.getNumber()), m*int(20.0*rnd.getNumber())+10, m*int(10.0*rnd.getNumber())+1, rnd.getNumber(), rnd.getNumber(), rnd.getNumber()); } img.Resize(256, 256); img.Show(); }