Difference between revisions of "Legacy:Image/zoomBlit"

From Spherical
Jump to: navigation, search
m (Apollolux moved page Image.zoomBlit to API:Image/zoomBlit: API convention)
(API convention)
Line 2: Line 2:
  
 
=Usage=
 
=Usage=
::''image''.zoomBlit(''x'', ''y'', ''factor'');
+
{{Usage|object=image|func=zoomBlit|params=x, y, factor}}
  
* '''image''' Sphere [[Image]] object. The image to draw on screen.
+
* '''image''' Sphere [[API:Image|Image]] object. The image to draw on screen.
 
* '''x''' number. The x coordinate of the top-left corner of the drawn image.
 
* '''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.
 
* '''y''' number. The y coordinate of the top-left corner of the drawn image.
Line 35: Line 35:
 
=Notes=
 
=Notes=
  
* [[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 [[Image]] object  
+
* Sphere [[API:Image|Image]] object  
  
* [[Image.blit]]()
+
* [[API:Image/blit|Image.blit]]()
* [[Image.transformBlit]]()
+
* [[API:Image/transformBlit|Image.transformBlit]]()
* [[Image.transformBlitMask]]()
+
* [[API:Image/transformBlitMask|Image.transformBlitMask]]()
  
* [[FlipScreen]]()
+
* [[API:FlipScreen|FlipScreen]]()
* [[GetKey]]()
+
* [[API:GetKey|GetKey]]()
* [[GetScreenHeight]]()
+
* [[API:GetScreenHeight|GetScreenHeight]]()
* [[GetScreenWidth]]()
+
* [[API:GetScreenWidth|GetScreenWidth]]()
* [[LoadImage]]()
+
* [[API:LoadImage|LoadImage]]()
 +
 
 +
[[Category:Functions]]

Revision as of 18:30, 21 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