summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2018-01-17 12:01:41 -0500
committerDavid Thompson <dthompson2@worcester.edu>2018-01-17 12:01:41 -0500
commitfedd9bca3d6397e22e5400e8653879bb77bbff2e (patch)
treeff358caf4fb550408685ce851ed4dd6b885a7c05 /doc
parent4912d9bd202115e6a2d2a22d3414310f8ac63ff2 (diff)
render: Refactor sprite rendering.
* chickadee/render/texture.scm (<texture-region>): Delete type. (<texture>)[width, height, gl-size]: Delete fields. [parent, rect, gl-rect]: Add fields. (texture-region?): Rewrite. (make-texture, null-texture): Use new texture constructor. (make-texture-region): Rewrite in terms of <texture> type. (list->texture-atlas, split-texture): Use new texture region constructor. * chickadee/render/sprite.scm (draw-sprite*): New procedure. (draw-sprite): Rewrite in terms of draw-sprite*. (draw-nine-patch*): New procedure. (draw-nine-patch): Rewrite in terms of draw-nine-patch*. * chickadee/render/font.scm (draw-text*): New procedure. (draw-text): Rewrite in terms of draw-text*. * doc/api.texi: Update draw-sprite, draw-nine-patch, and draw-text docs.
Diffstat (limited to 'doc')
-rw-r--r--doc/api.texi32
1 files changed, 23 insertions, 9 deletions
diff --git a/doc/api.texi b/doc/api.texi
index cb3c885..e2864a5 100644
--- a/doc/api.texi
+++ b/doc/api.texi
@@ -681,10 +681,26 @@ players, NPCs, items, particles, text, etc. In Chickadee, bitmaps are
stored in textures (@pxref{Textures}) and can be used to draw sprites
via the @code{draw-sprite} procedure.
-@deffn {Procedure} draw-sprite @var{texture} @var{region} @
- [#:scale] [#:rotation] [#:blend-mode alpha] [#:texcoords] @
- [#:shader]
+@deffn {Procedure} draw-sprite @var{texture} @var{position} @
+ [#:origin] [#:scale] [#:rotation] [#:blend-mode alpha] @
+ [#:rect] [#:shader]
+
+Draw @var{texture} at @var{position}.
+
+Optionally, other transformations may be applied to the sprite.
+@var{rotation} specifies the angle to rotate the sprite, in radians.
+@var{scale} specifies the scaling factor as a 2D vector. All
+transformations are applied relative to @var{origin}, a 2D vector,
+which defaults to the lower-left corner.
+
+Alpha blending is used by default but the blending method can be
+changed by specifying @var{blend-mode}.
+
+The area drawn to is as big as the texture, by default. To draw to an
+arbitrary section of the screen, specify @var{rect}.
+Finally, advanced users may specify @var{shader} to change the way the
+sprite is rendered entirely.
@end deffn
It's not uncommon to need to draw hundreds or thousands of sprites
@@ -740,10 +756,10 @@ interface widgets like buttons and dialog boxes. By using a nine
patch, they can be rendered at any size without unappealing scaling
artifacts.
-@deffn {Procedure} draw-nine-patch @var{texture} @var{region} @
+@deffn {Procedure} draw-nine-patch @var{texture} @var{rect} @
[#:margin 0] [#:top-margin margin] [#:bottom-margin margin] @
[#:left-margin margin] [#:right-margin margin] @
- [#:texture-region] [#:scale] [#:rotation] [#:blend-mode alpha] @
+ [#:origin] [#:scale] [#:rotation] [#:blend-mode alpha] @
[#:shader]
Draw a nine patch sprite. A nine patch sprite renders @var{texture}
@@ -809,9 +825,7 @@ rendering technique comes in. Introduced by
@url{http://www.valvesoftware.com/.../2007/SIGGRAPH2007_AlphaTestedMagnification.pdf,
Valve} in 2007, signed distance field fonts can be efficiently stored
in a bitmap and be rendered at arbitrary scale factors with good
-results. Chickadee can render both traditional bitmap fonts and
-signed distance field fonts. @emph{Signed distance field font
-rendering is not yet available, so be patient.}
+results.
While Chickadee does not yet offer a tool for converting TTF fonts
into FNT fonts, tools such as
@@ -851,7 +865,7 @@ Return @code{#t} if @var{font} is an italicized font.
@end deffn
@deffn {Procedure} draw-text @var{font} @var{text} @var{position}
- [#:scale] [#:rotation] [#:blend-mode]
+ [#:origin] [#:scale] [#:rotation] [#:blend-mode]
Draw the string @var{text} with the first character starting at
@var{position} using @var{font}.