DrawImageRect.htm 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <html>
  2. <head>
  3. <title>Blitz3D Docs</title>
  4. <link rel=stylesheet href=../css/commands.css type=text/css>
  5. </head>
  6. <body>
  7. <h1>DrawImageRect image,x,y,rect_x,rect_y,rect_width,rect_height,[frame]</h1>
  8. <h1>Parameters</h1>
  9. <table>
  10. <tr>
  11. <td>
  12. image = variable holding the image handle <br />
  13. x = x location on the screen to draw the image <br />
  14. y = y location on the screen to draw the image <br />
  15. rect_x = starting x location within the image to draw <br />
  16. rect_y = starting y location within the image to draw <br />
  17. rect_width = the height of the area to draw <br />
  18. rect_height = the width of the area to draw <br />
  19. frame = optional frame number of image to draw
  20. </td>
  21. </tr>
  22. </table>
  23. <h1>Description</h1>
  24. <table>
  25. <tr>
  26. <td>
  27. This command will let you draw a rectangular PORTION of an image to the designated location on the screen. The transparent/masked portions of the original image will be drawn transparent, just as you normally would draw an image. <br />
  28. <br />
  29. This is handy if you are doing something like revealing part of a screen when the player uncovers something (think QIX). You could load the 'picture' into an image, then when the player clears a rectangular region, you could paste that portion of the final image onto the playfield. If you want to draw the image portion with no transparency or mask, use DrawBlockRect instead.
  30. </td>
  31. </tr>
  32. </table>
  33. <h1><a href=../2d_examples/DrawImageRect.bb>Example</a></h1>
  34. <table>
  35. <tr>
  36. <td>
  37. ; DrawImageRect Example <br />
  38. <br />
  39. ; Turn on graphics mode <br />
  40. Graphics 640,480,16 <br />
  41. <br />
  42. ; Create new empty graphic to store our circle in <br />
  43. gfxCircle=CreateImage(50,50) <br />
  44. <br />
  45. ; Draw the circle image <br />
  46. ; Set drawing operations to point to our new empty graphic <br />
  47. SetBuffer ImageBuffer(gfxCircle) <br />
  48. Color 255,0,0 <br />
  49. ; Note the extra space between the circle and the edge of the graphic <br />
  50. Oval 10,10,30,30,1 <br />
  51. SetBuffer FrontBuffer() <br />
  52. <br />
  53. <br />
  54. ; Let's draw portions of the circle randomly <br />
  55. While Not KeyHit(1) <br />
  56. ; We take random sized portions of the circle and put them <br />
  57. ; at a random location ... wash, rinse, and repeat <br />
  58. DrawImageRect gfxCircle,Rnd(640),Rnd(480),0,0,Rnd(50),Rnd(50),0 <br />
  59. Delay 100 <br />
  60. Wend <br />
  61. </td>
  62. </tr>
  63. </table>
  64. <br>
  65. <a target=_top href=../index.htm>Index</a><br>
  66. <br>
  67. Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=DrawImageRect&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
  68. </html>