From e67d9a67574106b3ca5f63eb0cd9f7ef1ef9e87a Mon Sep 17 00:00:00 2001 From: Matthias Richter Date: Thu, 1 Nov 2012 18:57:35 +0100 Subject: [PATCH] Document camera:zoom[To]() --- README.md | 147 ++++++++++++++++++++++++++++++++++------------------- index.html | 81 ++++++++++++++++++----------- 2 files changed, 145 insertions(+), 83 deletions(-) diff --git a/README.md b/README.md index a02e7e1..50718e8 100644 --- a/README.md +++ b/README.md @@ -1906,7 +1906,7 @@ worry about that. ### function new(x,y, zoom, rot) [Create a new camera.] Creates a new camera. You can access the camera position using `camera.x, -camera.y`, the zoom using `camera.zoom` and the rotation using `camera.rot`. +camera.y`, the zoom using `camera.scale` and the rotation using `camera.rot`. The module variable name can be used at a shortcut to `new()`. @@ -1932,57 +1932,6 @@ The module variable name can be used at a shortcut to `new()`. cam = camera(100,100, 2, math.pi/2) -### function camera:rotate(angle) [Rotate camera.] - -Rotate the camera by some angle. To set the angle use `camera.rot = new_angle`. - -This function is shortcut to `camera.rot = camera.rot + angle`. - -#### Parameters: - -=number angle= - Rotation angle in radians - -#### Returns: - -=camera= - The camera. - -#### Example: - - function love.update(dt) - camera:rotate(dt) - end - -#### Example: - - function love.update(dt) - camera:rotate(dt):move(dt,dt) - end - - -### function camera:rotation(angle) [Get or set camera rotation.] - -Returns `camera.rot`. - -If given an angle, set rotation: `camera.rot = angle`. - -#### Parameters: - -=number angle (optional)= - Rotation angle in radians - -#### Returns: - -=number= - Rotation angle in radians. - -#### Example: - - love.graphics.print(camera:rotation(), 10, 10) - camera:rotation(math.pi/2) - - ### function camera:move(dx,dy) [Move camera.] Move the camera *by* some vector. To set the position, use @@ -2066,6 +2015,100 @@ Returns `camera.x, camera.y`. end +### function camera:rotate(angle) [Rotate camera.] + +Rotate the camera by some angle. To set the angle use `camera.rot = new_angle`. + +This function is shortcut to `camera.rot = camera.rot + angle`. + +#### Parameters: + +=number angle= + Rotation angle in radians + +#### Returns: + +=camera= + The camera. + +#### Example: + + function love.update(dt) + camera:rotate(dt) + end + +#### Example: + + function love.update(dt) + camera:rotate(dt):move(dt,dt) + end + + +### function camera:rotateTo(angle) [Set camera rotation.] + +Set rotation: `camera.rot = angle`. + +#### Parameters: + +=number angle= + Rotation angle in radians + +#### Returns: + +=number= + The camera. + +#### Example: + + camera:rotateTo(math.pi/2) + + +### function camera:zoom(mul) [Change zoom.] + +*Multiply* zoom: `camera.scale = camera.scale * mul`. + +#### Parameters: + +=number mul= + Zoom change. Should be > 0. + +#### Returns: + +=number= + The camera. + +#### Example: + + camera:zoom(2) -- make everything twice as big + +#### Example: + + camera:zoom(0.5) -- ... and back to normal + +#### Example: + + camera:zoom(-1) -- flip everything + + +### function camera:zoomTo(zoom) [Set zoom.] + +Set zoom: `camera.scale = zoom`. + +#### Parameters: + +=number zoom= + New zoom. + +#### Returns: + +=number= + The camera. + +#### Example: + + camera:zoomTo(1) + + ### function camera:attach() [Attach camera.] Start looking through the camera. diff --git a/index.html b/index.html index 0a50353..dfb9eee 100644 --- a/index.html +++ b/index.html @@ -1281,8 +1281,8 @@ function love.update(dt) cam:move(dx/2, dy/2) end -

Module overview

new()
Create a new camera.
camera:rotate()
Rotate camera.
camera:rotation()
Get or set camera rotation.
camera:move()
Move camera.
camera:lookAt()
Move camera to position.
camera:pos()
Get camera position.
camera:attach()
Attach camera.
camera:detach()
Detach camera.
camera:draw()
Attach, draw, then detach.
camera:worldCoords()
Convert point to world coordinates.
camera:cameraCoords()
Convert point to camera coordinates.
camera:mousepos()
Get mouse position in world coordinates.

function new(x,y, zoom, rot)^top

Creates a new camera. You can access the camera position using camera.x, -camera.y, the zoom using camera.zoom and the rotation using camera.rot.

+

Module overview

new()
Create a new camera.
camera:move()
Move camera.
camera:lookAt()
Move camera to position.
camera:pos()
Get camera position.
camera:rotate()
Rotate camera.
camera:rotateTo()
Set camera rotation.
camera:zoom()
Change zoom.
camera:zoomTo()
Set zoom.
camera:attach()
Attach camera.
camera:detach()
Detach camera.
camera:draw()
Attach, draw, then detach.
camera:worldCoords()
Convert point to world coordinates.
camera:cameraCoords()
Convert point to camera coordinates.
camera:mousepos()
Get mouse position in world coordinates.

function new(x,y, zoom, rot)^top

Creates a new camera. You can access the camera position using camera.x, +camera.y, the zoom using camera.scale and the rotation using camera.rot.

The module variable name can be used at a shortcut to new().

Parameters:
@@ -1297,35 +1297,6 @@ camera.y, the zoom using camera.zoom and the rot -- camera looking at (100,100) with zoom 2 and rotated by 45 degrees cam = camera(100,100, 2, math.pi/2) -

function camera:rotate(angle)^top

Rotate the camera by some angle. To set the angle use camera.rot = new_angle.

- -

This function is shortcut to camera.rot = camera.rot + angle.

-
Parameters:
-
number angle
-
Rotation angle in radians
-
Returns:
-
camera
-
The camera.
-
Examples:
function love.update(dt)
-    camera:rotate(dt)
-end
-
-
function love.update(dt)
-    camera:rotate(dt):move(dt,dt)
-end
-
-

function camera:rotation(angle)^top

Returns camera.rot.

- -

If given an angle, set rotation: camera.rot = angle.

-
Parameters:
-
number angle (optional)
-
Rotation angle in radians
-
Returns:
-
number
-
Rotation angle in radians.
-
Example:
love.graphics.print(camera:rotation(), 10, 10)
-camera:rotation(math.pi/2)
-

function camera:move(dx,dy)^top

Move the camera by some vector. To set the position, use camera:lookAt(x,y).

@@ -1378,6 +1349,54 @@ function love.update(dt) camera:move(dx * dt, dy * dt) end +

function camera:rotate(angle)^top

Rotate the camera by some angle. To set the angle use camera.rot = new_angle.

+ +

This function is shortcut to camera.rot = camera.rot + angle.

+
Parameters:
+
number angle
+
Rotation angle in radians
+
Returns:
+
camera
+
The camera.
+
Examples:
function love.update(dt)
+    camera:rotate(dt)
+end
+
+
function love.update(dt)
+    camera:rotate(dt):move(dt,dt)
+end
+
+

function camera:rotateTo(angle)^top

Set rotation: camera.rot = angle.

+
Parameters:
+
number angle
+
Rotation angle in radians
+
Returns:
+
number
+
The camera.
+
Example:
camera:rotateTo(math.pi/2)
+
+

function camera:zoom(mul)^top

Multiply zoom: camera.scale = camera.scale * mul.

+
Parameters:
+
number mul
+
Zoom change. Should be > 0.
+
Returns:
+
number
+
The camera.
+
Examples:
camera:zoom(2)   -- make everything twice as big
+
+
camera:zoom(0.5) -- ... and back to normal
+
+
camera:zoom(-1)  -- flip everything
+
+

function camera:zoomTo(zoom)^top

Set zoom: camera.scale = zoom.

+
Parameters:
+
number zoom
+
New zoom.
+
Returns:
+
number
+
The camera.
+
Example:
camera:zoomTo(1)
+

function camera:attach()^top

Start looking through the camera.

Apply camera transformations, i.e. move, scale and rotate everything until