Graphics Goodies #2 A Simple, Versatile Procedural Texture Lloyd Burchil l Simon Fraser Universit y Burnaby, BC, CANAD A (Lloydf-Burchill%SFU.MailneK?iurn.cc.uni/c/i .eclu > procedure main( ) for y= 0 to ysize- 1 for x = 0 to xsize- 1 color = texture(x,y ) plot<-on -screen(x,y,color ) endloo p endloo p retur n In this example, the display gets divided into man y overlapping zones of color. Note that the AND 255 limits th e sizes of the zones . Also, a time-consuming square-roo t function, as one might expect to have to use in a distanc e calculation, is not necessary, since only the order of distance s is of interest, not their actual values . From here, the algorithm can be endlessy modified t o produce many different patterns . For example : function texture(x,y ) diff = 0 diff2 = 0 least = highest for i = 0 to max-1 d o if x>h(i) then da = x-h(i ) else da = h(i)- x endi f if y>v(i) then db = y-v(i ) else db = v(i)- y endi f da = da-12 8 da = da AND 25 5 db=db-128 db = db AND 25 5
/lp/association-for-computing-machinery/graphics-goodies-2-a-simple-versatile-procedural-texture-ArxcF84CQH