diff options
author | David Thompson <dthompson@member.fsf.org> | 2013-09-24 21:06:41 -0400 |
---|---|---|
committer | David Thompson <dthompson@member.fsf.org> | 2013-09-24 21:06:41 -0400 |
commit | 1f1deea662da4328bf588c0642c8a90c7b1f2144 (patch) | |
tree | a7973b46b580ca2a9e8fb65f459e0004ae87b64f /doc/graphics | |
parent | 7937b85219607a6e7755907e0752343344ed036c (diff) |
Rough draft of manual.
Diffstat (limited to 'doc/graphics')
-rw-r--r-- | doc/graphics/animation.texi | 84 | ||||
-rw-r--r-- | doc/graphics/color.texi | 64 | ||||
-rw-r--r-- | doc/graphics/font.texi | 70 | ||||
-rw-r--r-- | doc/graphics/sprite.texi | 121 | ||||
-rw-r--r-- | doc/graphics/texture.texi | 65 | ||||
-rw-r--r-- | doc/graphics/tileset.texi | 41 |
6 files changed, 445 insertions, 0 deletions
diff --git a/doc/graphics/animation.texi b/doc/graphics/animation.texi new file mode 100644 index 0000000..c872263 --- /dev/null +++ b/doc/graphics/animation.texi @@ -0,0 +1,84 @@ +@node Animations +@section Animations + +Animations are sequences of textures and/or texture regions. Common +uses for animations are to give the illusion that a character is +walking across the screen or swinging their sword at a +monster. Animator objects are used to control the playback of an +animation. + +@anchor{2d animation animation-frame-duration}@defspec animation-frame-duration +@end defspec + +@anchor{2d animation animation-frames}@defspec animation-frames +@end defspec + +@anchor{2d animation animation-loop?}@defspec animation-loop? +@end defspec + +@anchor{2d animation animation?}@defspec animation? +@end defspec + +@anchor{2d animation animator-animation}@defspec animator-animation +@end defspec + +@anchor{2d animation animator-frame}@defspec animator-frame +@end defspec + +@anchor{2d animation animator-playing?}@defspec animator-playing? +@end defspec + +@anchor{2d animation animator-time}@defspec animator-time +@end defspec + +@anchor{2d animation animator?}@defspec animator? +@end defspec + +@anchor{2d animation make-animation}@defspec make-animation +@end defspec + +@anchor{2d animation animation-duration}@defun animation-duration animation +Return the total duration of ANIMATION in ticks. + +@end defun + +@anchor{2d animation animation-frame}@defun animation-frame animation index +Return the texture for the given frame INDEX of ANIMATION. + +@end defun + +@anchor{2d animation animation-length}@defun animation-length animation +Return the number of frames in ANIMATION. + +@end defun + +@anchor{2d animation animator-frame-complete?}@defun animator-frame-complete? animator +Return #t when ANIMATOR is done displaying the current frame. + +@end defun + +@anchor{2d animation animator-next!}@defun animator-next! animator +Advance ANIMATOR to the next frame of its animation. + +@end defun + +@anchor{2d animation animator-next-frame}@defun animator-next-frame animator +Return the next frame index for ANIMATOR. + +@end defun + +@anchor{2d animation animator-texture}@defun animator-texture animator +Return a texture for the ANIMATOR's current frame. + +@end defun + +@anchor{2d animation animator-update!}@defun animator-update! animator +Increment the frame time for the ANIMATOR and advance to the next frame +when necessary. + +@end defun + +@anchor{2d animation make-animator}@defun make-animator animation +Create a new animator for ANIMATION. + +@end defun diff --git a/doc/graphics/color.texi b/doc/graphics/color.texi new file mode 100644 index 0000000..99e69ba --- /dev/null +++ b/doc/graphics/color.texi @@ -0,0 +1,64 @@ +@node Colors +@section Colors + +Colors store RGBA data in OpenGL format. Each color channel has a +value in the range [0, 1]. + +@anchor{2d color make-color}@defspec make-color +@end defspec + +@anchor{2d color color?}@defspec color? +@end defspec + +@anchor{2d color color-r}@defspec color-r +@end defspec + +@anchor{2d color color-g}@defspec color-g +@end defspec + +@anchor{2d color color-b}@defspec color-b +@end defspec + +@anchor{2d color color-a}@defspec color-a +@end defspec + +@anchor{2d color use-color}@defun use-color color +Set the current OpenGL color state to the contents of COLOR. + +@end defun + +A lot of people are used to working with colors as hexadecimal values, +so the following procedures are provided to convert hexadecimal color +codes into color objects. + +@anchor{2d color rgba}@defun rgba color-code +Translate an RGBA format string COLOR-CODE into a color object. For +example: #xffffffff will return a color with RGBA values 1, 1, 1, 1. + +@end defun + +@anchor{2d color rgb}@defun rgb color-code +Translate an RGB format string COLOR-CODE into a color object. For +example: #xffffff will return a color with RGBA values 1, 1, 1, 1. + +@end defun + +Commonly used colors are predefined for convenience. + +@anchor{2d color white}@defvar white +@end defvar + +@anchor{2d color black}@defvar black +@end defvar + +@anchor{2d color red}@defvar red +@end defvar + +@anchor{2d color green}@defvar green +@end defvar + +@anchor{2d color blue}@defvar blue +@end defvar + +@anchor{2d color magenta}@defvar magenta +@end defvar diff --git a/doc/graphics/font.texi b/doc/graphics/font.texi new file mode 100644 index 0000000..59057a2 --- /dev/null +++ b/doc/graphics/font.texi @@ -0,0 +1,70 @@ +@node Fonts +@section Fonts + +Guile-2D can render TTF fonts via the FTGL library. + +@anchor{2d font font-ftgl-font}@defspec font-ftgl-font +@end defspec + +@anchor{2d font font-size}@defspec font-size +@end defspec + +@anchor{2d font font?}@defspec font? +@end defspec + +@anchor{2d font make-font}@defspec make-font +@end defspec + +@anchor{2d font set-textbox-color!}@defspec set-textbox-color! +@end defspec + +@anchor{2d font set-textbox-position!}@defspec set-textbox-position! +@end defspec + +@anchor{2d font set-textbox-text!}@defspec set-textbox-text! +@end defspec + +@anchor{2d font textbox-alignment}@defspec textbox-alignment +@end defspec + +@anchor{2d font textbox-color}@defspec textbox-color +@end defspec + +@anchor{2d font textbox-font}@defspec textbox-font +@end defspec + +@anchor{2d font textbox-layout}@defspec textbox-layout +@end defspec + +@anchor{2d font textbox-line-length}@defspec textbox-line-length +@end defspec + +@anchor{2d font textbox-position}@defspec textbox-position +@end defspec + +@anchor{2d font textbox-text}@defspec textbox-text +@end defspec + +@anchor{2d font textbox?}@defspec textbox? +@end defspec + +@anchor{2d font draw-font}@defun draw-font font text +Renders the string text using the given font. + +@end defun + +@anchor{2d font draw-textbox}@defun draw-textbox textbox +Draw TEXTBOX. + +@end defun + +@anchor{2d font load-font}@defun load-font filename size +Load a font from FILENAME with the given SIZE in points. + +@end defun + +@anchor{2d font make-textbox}@defun make-textbox font text position color alignment line-length +Create a textbox that will draw TEXT with the given FONT, at vector +POSITION, with ALIGNMENT, and a maximum LINE-LENGTH. + +@end defun diff --git a/doc/graphics/sprite.texi b/doc/graphics/sprite.texi new file mode 100644 index 0000000..9b20e3f --- /dev/null +++ b/doc/graphics/sprite.texi @@ -0,0 +1,121 @@ +@node Sprites +@section Sprites + +Sprites are typically the most important part of a 2D game. Sprites +represent a texture with a specific color, position, rotation and +scale. Sprites can render texture objects or animations. + +@anchor{2d sprite set-sprite-batch-size!}@defspec set-sprite-batch-size! +@end defspec + +@anchor{2d sprite set-sprite-batch-texture!}@defspec set-sprite-batch-texture! +@end defspec + +@anchor{2d sprite set-sprite-drawable!}@defspec set-sprite-drawable! +@end defspec + +@anchor{2d sprite set-sprite-vertices!}@defspec set-sprite-vertices! +@end defspec + +@anchor{2d sprite sprite-anchor}@defspec sprite-anchor +@end defspec + +@anchor{2d sprite sprite-batch-max-size}@defspec sprite-batch-max-size +@end defspec + +@anchor{2d sprite sprite-batch-size}@defspec sprite-batch-size +@end defspec + +@anchor{2d sprite sprite-batch-texture}@defspec sprite-batch-texture +@end defspec + +@anchor{2d sprite sprite-batch-vertices}@defspec sprite-batch-vertices +@end defspec + +@anchor{2d sprite sprite-batch?}@defspec sprite-batch? +@end defspec + +@anchor{2d sprite sprite-color}@defspec sprite-color +@end defspec + +@anchor{2d sprite sprite-drawable}@defspec sprite-drawable +@end defspec + +@anchor{2d sprite sprite-position}@defspec sprite-position +@end defspec + +@anchor{2d sprite sprite-rotation}@defspec sprite-rotation +@end defspec + +@anchor{2d sprite sprite-scale}@defspec sprite-scale +@end defspec + +@anchor{2d sprite sprite-vertices}@defspec sprite-vertices +@end defspec + +@anchor{2d sprite sprite?}@defspec sprite? +@end defspec + +@anchor{2d sprite with-sprite-batch}@defspec with-sprite-batch batch body ... +@end defspec + +@anchor{2d sprite animated-sprite?}@defun animated-sprite? sprite +Return #t if SPRITE has an animation as its drawable object. + +@end defun + +@anchor{2d sprite draw-sprite}@defun draw-sprite sprite +Render SPRITE to the screen. A sprite batch will be used if one is +currently bound. + +@end defun + +@anchor{2d sprite load-sprite}@defun load-sprite filename [#:position] [#:scale] [#:rotation] [#:color] [#:anchor] +Load a sprite from the file at FILENAME. See make-sprite for optional +keyword arguments. + +@end defun + +@anchor{2d sprite make-sprite}@defun make-sprite drawable [#:position] [#:scale] [#:rotation] [#:color] [#:anchor] +Create a new sprite object. DRAWABLE is either a texture or animation +object. All keyword arguments are optional. POSITION is a vector2 +object with a default of (0, 0). SCALE is a vector2 object that +describes how much DRAWABLE should be strected on the x and y axes, with +a default of 1x scale. ROTATION is an angle in degrees with a default +of 0. COLOR is a color object with a default of white. ANCHOR is +either a vector2 that represents the center point of the sprite, or +'center which will place the anchor at the center of DRAWABLE. Sprites +are centered by default. + +@end defun + +@anchor{2d sprite make-sprite-batch}@defun make-sprite-batch [max-size] +Creates a new sprite batch. The default max-size is 1000. + +@end defun + +@anchor{2d sprite set-sprite-anchor!}@defun set-sprite-anchor! sprite value +@end defun + +@anchor{2d sprite set-sprite-color!}@defun set-sprite-color! sprite value +@end defun + +@anchor{2d sprite set-sprite-position!}@defun set-sprite-position! sprite value +@end defun + +@anchor{2d sprite set-sprite-rotation!}@defun set-sprite-rotation! sprite value +@end defun + +@anchor{2d sprite set-sprite-scale!}@defun set-sprite-scale! sprite value +@end defun + +@anchor{2d sprite sprite-batch-draw}@defun sprite-batch-draw . args +Add a textured quad to the current sprite batch. X, Y, WIDTH, and +HEIGHT represent the quad in pixels. ORIGIN-X and ORIGIN-Y represent +the center point of the quad which is used for rotation. SCALE-X and +SCALE-Y are the scaling factors for the x and y axis, respectively. +ROTATION is the angle in degrees to rotate the quad. U, V, U2, and V2 +represent the texture coordinate region to texture the quad with. COLOR +is a color object. + +@end defun diff --git a/doc/graphics/texture.texi b/doc/graphics/texture.texi new file mode 100644 index 0000000..2ac1503 --- /dev/null +++ b/doc/graphics/texture.texi @@ -0,0 +1,65 @@ +@node Textures +@section Textures + +Textures are images loaded in graphics memory. Guile-2D supports many +texture formats via the FreeImage library. A texture object can +describe a full image or a rectangular section of an image. + +@anchor{2d texture make-texture}@defun make-texture id parent width height s1 t1 s2 t2 +Create a new texture object. ID is the OpenGL texture id. PARENT is a +texture object (if this texture only represents a region of another +texture) or #f. WIDTH and HEIGHT are the texture dimensions in pixels. +S1, T1, S2, and T2 are the OpenGL texture coordinates representing the +area of the texture that will be rendered. + +@end defun + +@anchor{2d texture make-texture-region}@defun make-texture-region texture x y width height +Creates new texture region object. TEXTURE is the region's parent +texture. X, Y, WIDTH, and HEIGHT represent the region of the texture +that will be rendered, in pixels. + +@end defun + +@anchor{2d texture load-texture}@defun load-texture filename +Load a texture from an image file at FILENAME. + +@end defun + +@anchor{2d texture texture?}@defspec texture? +@end defspec + +@anchor{2d texture texture-region?}@defun texture-region? texture +Return #t if TEXTURE has a parent texture. + +@end defun + +@anchor{2d texture texture-id}@defspec texture-id +@end defspec + +@anchor{2d texture texture-width}@defspec texture-width +@end defspec + +@anchor{2d texture texture-height}@defspec texture-height +@end defspec + +@anchor{2d texture texture-s1}@defspec texture-s1 +@end defspec + +@anchor{2d texture texture-t1}@defspec texture-t1 +@end defspec + +@anchor{2d texture texture-s2}@defspec texture-s2 +@end defspec + +@anchor{2d texture texture-t2}@defspec texture-t2 +@end defspec + +@anchor{2d texture surface->texture}@defvar surface->texture +[unbound!] +@end defvar + +@anchor{2d texture draw-texture}@defun draw-texture texture x y [color] +Render a textured quad in GL immediate mode. + +@end defun diff --git a/doc/graphics/tileset.texi b/doc/graphics/tileset.texi new file mode 100644 index 0000000..1f229dc --- /dev/null +++ b/doc/graphics/tileset.texi @@ -0,0 +1,41 @@ +@node Tilesets +@section Tilesets + +In most 2D games, the game world is composed of many small, +rectangular pieces called tiles. In Guile-2D, tilesets are used to +encapsulate a group of uniformly sized texture regions that come from +a single parent texture. + +@anchor{2d tileset make-tileset}@defun make-tileset texture width height [#:margin] [#:spacing] +Return a new tileset that is built by splitting TEXTURE into tiles. + +@end defun + +@anchor{2d tileset load-tileset}@defun load-tileset filename width height [#:margin] [#:spacing] +Return a new tileset that is built by loading the texture at FILENAME +and splitting the texture into tiles. + +@end defun + +@anchor{2d tileset tileset?}@defspec tileset? +@end defspec + +@anchor{2d tileset tileset-tiles}@defspec tileset-tiles +@end defspec + +@anchor{2d tileset tileset-width}@defspec tileset-width +@end defspec + +@anchor{2d tileset tileset-height}@defspec tileset-height +@end defspec + +@anchor{2d tileset tileset-margin}@defspec tileset-margin +@end defspec + +@anchor{2d tileset tileset-spacing}@defspec tileset-spacing +@end defspec + +@anchor{2d tileset tileset-ref}@defun tileset-ref tileset i +Return the tile texture of TILESET at index I. + +@end defun |