Legacy:Image/zoomBlit

From Spherical
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Draw the image onto the screen with zooming.

Usage

image.zoomBlit(x, y, factor);


  • image Sphere Image object. The image to draw on screen.
  • x number. The x coordinate of the top-left corner of the drawn image.
  • y number. The y coordinate of the top-left corner of the drawn image.
  • factor number, floating-point. The amount of zooming applied. factor == 1 causes no zoom, 0 < factor < 1 causes the image to shrink, factor > 1 causes the image to enlarge.

Examples

This simple game will take an image and zoom it so that it is stretched to fit the screen.

function game()
{
  var w = GetScreenWidth();
  var h = GetScreenHeight();
  var img = LoadImage("my_test_image.png");
  
  // Calculate by how much to zoom.
  var factor = Math.min(w / img.width, h / img.height);
  
  img.zoomBlit(0, 0, factor);
  
  FlipScreen();
  GetKey();
}

Notes

  • Image.transformBlit() can also be used to achieve zooming, by picking the corner points manually.

See also


API:Image/navbox