'Library of scaled drawing functions for high-resolution images 'M. Eric Carr / Paleotechnologist.Net 'eric (at) the above domain 'Code provided under a Creative Commons (BY-NC-SA) license 'Set up the image size. HD image is scaled up in both X and Y by SCALEFACTOR. const XSIZE=800 const YSIZE=600 const SCALEFACTOR = 2 'High-res image is this many times larger in X and Y. 'Function declarations declare sub scaledPset(x as double, y as double, pcolor as integer, target as any ptr) declare sub scaledLine(x as double, y as double, a as double, b as double, pcolor as integer, target as any ptr) declare sub scaledRect(x as double, y as double, a as double, b as double, pcolor as integer, target as any ptr) declare sub scaledRectFilled(x as double, y as double, a as double, b as double, pcolor as integer, target as any ptr) declare sub scaledCircle(x as double, y as double, radius as double, pcolor as integer, target as any ptr) declare sub scaledCircleFilled(x as double, y as double, radius as double, pcolor as integer, target as any ptr) 'Initialize graphics for the visible image screenres XSIZE,YSIZE,24 'Create an image buffer for the HD image dim as any ptr image image = ImageCreate(XSIZE*SCALEFACTOR,YSIZE*SCALEFACTOR,rgb(0,0,0)) 'Variables for drawing the image dim as double ax,ay,bx,by dim as integer mycolor 'Main loop while inkey$="" 'Pick the endpoints for a rectangle. '(These are type double; draw on the screen as usual, but you can use ' non-integer values, which will be scaled up for the HD image.) ax=rnd*XSIZE ay=rnd*YSIZE bx=rnd*XSIZE by=rnd*YSIZE 'Color based on rectangle position, to give it an overall pattern mycolor=rgb(255*(ay/2+ax/2)/YSIZE,255*bx/XSIZE,255*ax/XSIZE) 'One function call to do both onscreen and high-res image scaledRect(ax,bx,ay,by,mycolor,image) wend 'Save the completed HD image from the buffer bsave "HD_image.bmp", image 'Save the completed lower-res onscreen image, for comparison bsave "image.bmp",0 sleep end sub scaledPset(x as double, y as double, pcolor as integer, target as any ptr) pset(x,y),pcolor pset target,(x*SCALEFACTOR,y*SCALEFACTOR),pcolor end sub sub scaledLine(x as double, y as double, a as double, b as double, pcolor as integer, target as any ptr) line(x,y)-(a,b),pcolor line target,(x*SCALEFACTOR,y*SCALEFACTOR)-(a*SCALEFACTOR,b*SCALEFACTOR),pcolor end sub sub scaledRect(x as double, y as double, a as double, b as double, pcolor as integer, target as any ptr) line(x,y)-(a,b),pcolor,B line target,(x*SCALEFACTOR,y*SCALEFACTOR)-(a*SCALEFACTOR,b*SCALEFACTOR),pcolor,B end sub sub scaledRectFilled(x as double, y as double, a as double, b as double, pcolor as integer, target as any ptr) line(x,y)-(a,b),pcolor,BF line target,(x*SCALEFACTOR,y*SCALEFACTOR)-(a*SCALEFACTOR,b*SCALEFACTOR),pcolor,BF end sub sub scaledCircle(x as double, y as double, radius as double, pcolor as integer, target as any ptr) circle (x,y),radius, pcolor circle target,(x*SCALEFACTOR,y*SCALEFACTOR), radius*SCALEFACTOR, pcolor end sub sub scaledCircleFilled(x as double, y as double, radius as double, pcolor as integer, target as any ptr) circle (x,y),radius, pcolor,,,,F circle target,(x*SCALEFACTOR,y*SCALEFACTOR), radius*SCALEFACTOR, pcolor,,,,F end sub