DrawBlockRect image,x,y,rect_x,rect_y,rect_width,rect_height[,frame]
Parameters
|
image - handle of the image to draw from x - x position on the destination buffer to draw at y - y position on the destination buffer to draw at rect_x - x coordinate inside the image where the piece starts rect_y - y coordinate inside the image where the piece starts rect_width - width of the piece to draw, in pixels rect_height - height of the piece to draw, in pixels frame (optional) - frame of an animated image to draw from; 0 (default) |
Description
|
Draws a rectangular piece of an image solid, ignoring its mask colour. This is DrawImageRect with transparency switched off, or DrawBlock restricted to part of the picture. Every pixel in the chosen rectangle is written, mask colour included. It is the natural command for uncovering artwork a piece at a time - a QIX-style reveal, a scratch card, a wipe transition, or a loading bar cut from a single bar graphic. It is also handy for tile sheets and font sheets you have drawn yourself: keep everything in one big image and pull out the cell you want by its rectangle. rect_x,rect_y are measured from the top left of the image, and rect_width,rect_height are the size of the piece, not a second corner. Ask for a rectangle that runs past the edge of the image and only the part that exists is drawn. The destination x,y is measured from the image's handle and is relative to the current Origin, just as with the other drawing commands. See also: DrawImageRect, DrawBlock, TileBlock, MaskImage, CopyRect. |
Example
; DrawBlockRect Example ; --------------------- Graphics 640,480,0,2 SetBuffer BackBuffer() ; Explosion strip - 360x48, its background is the default black mask kaboom=LoadImage("media/kaboom.bmp") angle#=0 While Not KeyDown(1) Cls ; A 60x48 window drifts smoothly across the strip angle=angle+1 rx=150+150*Sin(angle) ; The whole image at the top, with the copied region boxed DrawImage kaboom,140,60 Color 255,255,0 Rect 140+rx,60,60,48,False ; An orange panel behind both draws shows the difference Color 200,90,0 Rect 170,220,300,120,True ; DrawImageRect keeps the mask; DrawBlockRect draws every pixel solid DrawImageRect kaboom,200,256,rx,0,60,48 DrawBlockRect kaboom,380,256,rx,0,60,48 Text 230,320,"DrawImageRect",True Text 410,320,"DrawBlockRect",True Text 0,0,"Esc: exit" Text 0,20,"DrawBlockRect kaboom,380,256,"+rx+",0,60,48" Text 0,40,"The sub-rectangle is drawn with NO transparency - black box included" Flip Wend End
Index