Difference between revisions of "Legacy:Image/zoomBlit"

From Spherical
Jump to: navigation, search
(API convention)
(added navbox)
 
Line 1: Line 1:
 
Draw the image onto the screen with zooming.
 
Draw the image onto the screen with zooming.
  
=Usage=
+
==Usage==
 
{{Usage|object=image|func=zoomBlit|params=x, y, factor}}
 
{{Usage|object=image|func=zoomBlit|params=x, y, factor}}
  
Line 9: Line 9:
 
* '''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.  
 
* '''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==
=Examples=
 
  
 
This simple game will take an image and zoom it so that it is stretched to fit the screen.
 
This simple game will take an image and zoom it so that it is stretched to fit the screen.
Line 32: Line 31:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
+
==Notes==
=Notes=
 
  
 
* [[API:Image/transformBlit|Image.transformBlit]]() can also be used to achieve zooming, by picking the corner points manually.  
 
* [[API:Image/transformBlit|Image.transformBlit]]() can also be used to achieve zooming, by picking the corner points manually.  
  
 
+
==See also==
=See also=
 
  
 
* Sphere [[API:Image|Image]] object  
 
* Sphere [[API:Image|Image]] object  
 
 
* [[API:Image/blit|Image.blit]]()
 
* [[API:Image/blit|Image.blit]]()
 
* [[API:Image/transformBlit|Image.transformBlit]]()
 
* [[API:Image/transformBlit|Image.transformBlit]]()
Line 52: Line 48:
 
* [[API:LoadImage|LoadImage]]()
 
* [[API:LoadImage|LoadImage]]()
  
[[Category:Functions]]
+
 
 +
 
 +
{{API:Image/navbox}}

Latest revision as of 18:22, 22 May 2013

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