diff options
-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 |