Image.rotateBlit

From Spheriki

Jump to: navigation, search

Draws the image onto the screen buffer like Image.blit(), but at an angle.


Contents

Usage

Image.rotateBlit(center_x, center_y, angle);
  • center_x Number. The x coordinate of the center of the drawing operation.
  • center_y Number. The y coordinate of the center of the drawing operation.
  • angle Number, between 0 and 2 * Math.PI. The angle to draw the image at, in radians.


Example

This script mostly works on its own, but will require the presence of "bleh.png" in the images/ directory of the game.

var img = LoadImage("bleh.png");
var x = GetScreenWidth() * 0.5;
var y = GetScreenHeight() * 0.5;
var angle = 0;

SetFrameRate(60);

while(!AreKeysLeft())
{
  angle = (angle + 0.1) % (2 * Math.PI);
  img.rotateBlit(x, y, angle);
  FlipScreen();
}

The above will show the image "bleh.png" rotating anticlockwise in the center of the screen until a key is pressed.


Notes

  • Like all Sphere functions that work with angles, the angle returned by this function is in the form of radians. To convert between radians and degrees, use Math.js (system script), or write your own simple routines.
  • Angles are measured as zero radians pointing to the right, and then increasing anticlockwise.
  • There are a number of other ways to draw Sphere Image objects, such as color masking, transforming and zooming.


See also

Personal tools