diff options
author | David Thompson <dthompson2@worcester.edu> | 2020-10-11 21:30:58 -0400 |
---|---|---|
committer | David Thompson <dthompson2@worcester.edu> | 2020-10-11 21:30:58 -0400 |
commit | 016b5c714c575a0fb9cbf1da8bf7e4989ee32bc2 (patch) | |
tree | 0a9015b89640e75e2824858101abfff7cb517173 | |
parent | 8dc52be5f308e9b0b8f11eaf63e17a9a3724d479 (diff) |
graphics: texture: Add load-tileset procedure.
-rw-r--r-- | chickadee/graphics/texture.scm | 26 | ||||
-rw-r--r-- | doc/api.texi | 12 |
2 files changed, 37 insertions, 1 deletions
diff --git a/chickadee/graphics/texture.scm b/chickadee/graphics/texture.scm index 397ecc4..388149d 100644 --- a/chickadee/graphics/texture.scm +++ b/chickadee/graphics/texture.scm @@ -55,7 +55,8 @@ split-texture texture-atlas? texture-atlas-texture - texture-atlas-ref)) + texture-atlas-ref + load-tileset)) ;;; @@ -327,3 +328,26 @@ terrain." (x-loop (1+ x)))) (y-loop (1+ y)))) (%make-texture-atlas texture v))) + +(define* (load-tileset file-name tile-width tile-height #:key + (margin 0) + (spacing 0) + (min-filter 'nearest) + (mag-filter 'nearest) + (wrap-s 'repeat) + (wrap-t 'repeat) + transparent-color) + "Return a new texture atlas that splits the texture loaded from the +file FILE-NAME into a grid of TILE-WIDTH by TILE-HEIGHT rectangles. +See load-image and split-texture for information about all keyword +arguments." + (split-texture (load-image file-name + #:min-filter min-filter + #:mag-filter mag-filter + #:wrap-s wrap-s + #:wrap-t wrap-t + #:transparent-color transparent-color) + tile-width + tile-height + #:margin margin + #:spacing spacing)) diff --git a/doc/api.texi b/doc/api.texi index a227cdc..7a49c85 100644 --- a/doc/api.texi +++ b/doc/api.texi @@ -1848,6 +1848,18 @@ This type of texture atlas layout is very common for 2D tile maps. @xref{Tile Maps} for more information. @end deffn +@deffn {Procedure} load-tileset file-name tile-width tile-height @ + [#:margin 0] [#:spacing 0] @ + [#:min-filter nearest] @ + [#:mag-filter nearest] [#:wrap-s repeat] [#:wrap-t repeat] @ + [#:transparent-color] + +Return a new texture atlas that splits the texture loaded from the +file @var{file-name} into a grid of @var{tile-width} by +@var{tile-height} rectangles. See @code{load-image} and +@code{split-texture} for information about all keyword arguments. +@end deffn + @deffn {Procedure} texture-atlas? obj Return @code{#t} if @var{obj} is a texture atlas. @end deffn |