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)
(added navbox)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 
Draw the image onto the screen with zooming.
 
Draw the image onto the screen with zooming.
  
=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.
 
* '''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.
  
* [[Image.transformBlit]]() can also be used to achieve zooming, by picking the corner points manually.
+
==See also==
  
 +
* Sphere [[API:Image|Image]] object
 +
* [[API:Image/blit|Image.blit]]()
 +
* [[API:Image/transformBlit|Image.transformBlit]]()
 +
* [[API:Image/transformBlitMask|Image.transformBlitMask]]()
  
=See also=
+
* [[API:FlipScreen|FlipScreen]]()
 +
* [[API:GetKey|GetKey]]()
 +
* [[API:GetScreenHeight|GetScreenHeight]]()
 +
* [[API:GetScreenWidth|GetScreenWidth]]()
 +
* [[API:LoadImage|LoadImage]]()
  
* Sphere [[Image]] object
 
  
* [[Image.blit]]()
 
* [[Image.transformBlit]]()
 
* [[Image.transformBlitMask]]()
 
  
* [[FlipScreen]]()
+
{{API:Image/navbox}}
* [[GetKey]]()
 
* [[GetScreenHeight]]()
 
* [[GetScreenWidth]]()
 
* [[LoadImage]]()
 

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