; WritePixel Example ; ------------------ Graphics 640,480,0,2 SetBuffer BackBuffer() ; Build a colour gradient image one pixel at a time. ; WritePixel needs no LockBuffer (see WritePixelFast for the fast version). img=CreateImage(128,128) For py=0 To 127 For px=0 To 127 ; Pack alpha, red, green and blue into one ARGB value argb=$FF000000 Or ((px*2) Shl 16) Or ((py*2) Shl 8) Or (px+py) ; Write straight into the image's buffer WritePixel px,py,argb,ImageBuffer(img) Next Next x#=100 y#=80 vx#=3 vy#=2 While Not KeyDown(1) Cls ; Bounce the finished gradient around the screen x=x+vx y=y+vy If x<0 Or x>512 Then vx=-vx If y<40 Or y>352 Then vy=-vy DrawImage img,x,y Text 0,0,"Esc: exit" Text 0,20,"This gradient was drawn with WritePixel, one pixel at a time" Flip Wend End