gamvas.Image

Description

A plain image with methods to move, rotate and zoom.

Use this if you need performance and are sure that the image is never needed as logic or physics element, otherwise use gamvas.Actor

Constructur

new gamvas.Image(file, x, y, cx, cy);

Parameters

filea JavaScript Image object (see gamvas.Resource)
x/ythe position of the image (optional)
cx/cythe center of rotation of the image (optional)

See

gamvas.Actor

Summary
gamvas.ImageA plain image with methods to move, rotate and zoom.
Functions
setRotationSet certain rotation of the image in radians
rotateRotate the image
setPositionSet the position of a image
moveMove the image
setScaleSet a certain scale factor
scaleScale the image
setScaleXYSet a different scale for x and y axis
setCenterSet the center for an Image.
setFileSets the image
drawdraws the image, using its position, rotation and scale information
setClipRectSets the clipping rectangle of a image
getClipRectGets the clipping rectangle of a image as gamvas.Rect

Functions

setRotation

this.setRotation = function(r)

Description

Set certain rotation of the image in radians

Parameters

rthe rotation in radians

See

gamvas.Image.rotate http://en.wikipedia.org/wiki/Radians

rotate

this.rotate = function(r)

Description

Rotate the image

Parameters

rthe amount to rotate the image in radians

See

gamvas.Image.setRotation http://en.wikipedia.org/wiki/Radians

setPosition

this.setPosition = function(x,
y)

Description

Set the position of a image

Parameters

x/ythe position of the image in pixels

See

gamvas.Image.move

move

this.move = function(x,
y)

Description

Move the image

Parameters

x/ythe pixels to move the image

See

gamvas.Image.setPosition

setScale

this.setScale = function(s)

Description

Set a certain scale factor

Parameters

sthe scale value (1 = no scale, < 1 = smaller, > 1 = bigger)

See

gamvas.Image.scale gamvas.Image.setScaleXY

scale

this.scale = function(s)

Description

Scale the image

Parameters

sthe scale factor (< 0 = shrink, > 0 = enlarge)

See

gamvas.Image.setScale

setScaleXY

this.setScaleXY = function(x,
y)

Description

Set a different scale for x and y axis

Parameters

xthe scale of the x axis (1 = no scale, < 1 = smaller, > 1 = bigger)
ythe scale of the y axis (1 = no scale, < 1 = smaller, > 1 = bigger)

See

gamvas.Image.setScale

setCenter

this.setCenter = function(x,
y)

Description

Set the center for an Image.  If you have a round object for example with a size of 64 by 64 pixels and you want to rotate it around the center, you would use myObject.setCenter(32, 32);

Parameters

x/ythe center, as seen of the upper left corner of the object

setFile

this.setFile = function(f)

Description

Sets the image

Parameters

imagea JavaScript Image object

draw

this.draw = function()

Description

draws the image, using its position, rotation and scale information

setClipRect

this.setClipRect = function(rx,
y,
w,
h)

Sets the clipping rectangle of a image

A clipping rectangle defines which portion of the image will be drawn.  It has to be inside the image and is specified by its top left corner and a width and height.

By default, a clipping rectange of x/y = 0/0 and width/height = image width and height is used

Parameters

rxeither a gamvas.Rect object or the x coordinate of the upper left corner
ythe y coordinate of the uppder left corner (if rx is not a gamvas.Rect object)
wthe width of the clipping rectangle (if rx is not a gamvas.Rect object)
hthe height of the clipping rectangle (if rx is not a gamvas.Rect object)

See

gamvas.Image.getClipRect

getClipRect

this.getClipRect = function()

Gets the clipping rectangle of a image as gamvas.Rect

See

gamvas.Image.setClipRect gamvas.Rect

this.setRotation = function(r)
Set certain rotation of the image in radians
this.rotate = function(r)
Rotate the image
this.setPosition = function(x,
y)
Set the position of a image
this.move = function(x,
y)
Move the image
this.setScale = function(s)
Set a certain scale factor
this.scale = function(s)
Scale the image
this.setScaleXY = function(x,
y)
Set a different scale for x and y axis
this.setCenter = function(x,
y)
Set the center for an Image.
this.setFile = function(f)
Sets the image
this.draw = function()
draws the image, using its position, rotation and scale information
this.setClipRect = function(rx,
y,
w,
h)
Sets the clipping rectangle of a image
this.getClipRect = function()
Gets the clipping rectangle of a image as gamvas.Rect
Holds position and width information of a rectangle
The actor class is the most important class in gamvas.
Class for resource handling, aka loading images and other game data
Close