viewport.bmx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Incbin "gfx/bg.png"
  2. Incbin "gfx/boing.png"
  3. Graphics 640, 480 , 32
  4. AutoImageFlags MASKEDIMAGE|FILTEREDIMAGE
  5. SetMaskColor 255, 0, 255
  6. bg = LoadImage ("incbin::gfx/bg.png")
  7. bgw# = GraphicsWidth () / Float (ImageWidth (bg))
  8. bgh# = GraphicsHeight () / Float (ImageHeight (bg))
  9. image = LoadImage ("incbin::gfx/boing.png") ' My example is 256 x 256
  10. MidHandleImage image
  11. rotstep# = 1
  12. Repeat
  13. mx = MouseX (); my = MouseY ()
  14. SetViewport 0, 0, GraphicsWidth (), GraphicsHeight ()
  15. Cls
  16. SetViewport mx - 200, my - 150, 400, 300
  17. Cls
  18. ' ---------------------------------------------------------------
  19. ' Draw background...
  20. ' ---------------------------------------------------------------
  21. SetAlpha 1
  22. SetBlend MASKBLEND
  23. SetRotation 0; SetScale bgw, bgh
  24. DrawImage bg, 0, 0
  25. ' ---------------------------------------------------------------
  26. ' Draw image...
  27. ' ---------------------------------------------------------------
  28. rot# = rot + rotstep; If rot > 360 - rotstep Then rot = 0
  29. SetRotation rot
  30. scale# = 0.1 + Sin (rot / 2); If scale < 0 Then scale = -scale
  31. SetScale scale, scale
  32. SetBlend ALPHABLEND
  33. SetAlpha scale
  34. DrawImage image, mx, my
  35. Flip
  36. Until KeyHit (KEY_ESCAPE)
  37. End