thrungames

Drawing

Thrunium have simplified drawing. We have extended the normal way to draw on the 2d context canvas.

drawLine(x1, y1, x2, y2)

x1 Number
y1 Number
x2 Number
y2 Number

Draws a line from (x1, y1) to (x2, y2) on the 2d context canvas.

var game = new THRUNIUM.Game(400, 400);
game.drawLine(100, 100, 200, 200);
// draws a diagonal line

drawText(text, x, y)

text String
x Number
y Number

Draws text at (x, y) on 2d context canvas.

var game = new THRUNIUM.Game(400, 400);
game.drawText("Hello World!", 100, 100);
// draws text on the canvas

drawRect(x, y, width, height)

x Number
y Number
width Number
height Number

Draws rectangle at (x, y) with dimension (width, height) on 2d context canvas.

var game = new THRUNIUM.Game(400, 400);
game.drawRect(100, 100, 20, 20);
// draws rectangle on the canvas

drawCircle(x, y, radius)

x Number
y Number
radius Number

Draws circle at (x, y) with dimension (radius) on 2d context canvas.

var game = new THRUNIUM.Game(400, 400);
game.drawCircle(100, 100, 20);
// draws circle on the canvas

drawImage(img, x, y [, width, height])

img Object
x Number
y Number
(Optional)
width Number
height Number

Draws a image with data from (img) at (x, y) with dimension (width, height) on 2d context canvas.

var game = new THRUNIUM.Game(400, 400);
game.assets = ['image.png'];
game.init();
game.drawImage(game.assets['image.png'], 100, 100);
game.drawImage(game.assets['image.png'], 100, 100, 200, 200);
// draws text on the canvas