Next: Excuses, Previous: Miscellaneous Utilities, Up: The (sdl *) Modules [Contents][Index]
This chapter documents module (sdl simple)
.
This module provides some simple abstractions to introduce common Guile-SDL programming idioms. Although the interfaces are documented, they are permanently alpha, that is, subject to change w/o notice. Instead of relying on the stability of the interface, you are encouraged to look at the implementation as a model for creating customized abstractions.
Return a canvas closure that accepts a few simple messages.
If init? is non-#f
, initalize the SDL video subsystem first.
w, h, and bpp specify the width, height, and
bits-per-pixel, respectively.
flags are symbols to set the video mode. If omitted, the
default is hw-surface
and doublebuf
.
The closure, if called without arguments, returns the video surface. Otherwise, the following messages are recognized:
#:rect
Return a rectangle the width and height of the canvas.
#:set-bg! r g b
Set the background color (used for clearing) to the color specified by r, g and b (integers 0-255), respectively. By default it is black (all values zero).
#:clear!
Fill the canvas with the background color.
#:w
#:h
#:w/h
Return width, height, or a cons of width and height, respectively.
#:resize! new-width new-height
Request that the canvas dimension be changed to new-width by new-height. Return a rect that reflects the actual dimension.
Return a stylus closure that accepts a few simple messages.
If init? is non-#f
, initialize the SDL TTF support first.
filename specifes the .ttf file to load and size
the size.
r, g and b are integers (0-255) specifying the color.
The closure recognizes the following messages:
#:set-font! filename size
#:set-color! r g b
Change the font or color, respectively.
#:set-canvas! surface
Set the surface on which the #:write!
command renders.
#:render text [color [bg]]
Return a surface of text rendered using the default
font, size, color and size. Optional second arg color
specifies another color to use. Optional third arg bg
specifies a background mode: #f
(default) for “solid”;
#t
for “blended”; a color to use that color.
#:write! where text [color [bg]]
Similar to #:render, but also blit the surface onto the canvas at the rectangle position specified by where. The width and height components of where are updated by side effect.
Return a vpacked image closure that accepts a few simple messages. "Vpacked" means multiple vertically-abutted images of dimensions NxN (at the top) through Nx1 (at the bottom), stored in a single image file. filename specifies the file and optional arg canvas specifies a surface for blitting. The closure recognizes the following messages:
#:set-canvas! surface
Change the canvas.
#:rects
Return the vector of rectangles of length N+1 (the element at index
zero is #f
) corresponding to areas on the image representing
the smaller sub-images. The element at index I is a rectangle of
dimension IxI.
#:blit! i rect
Blit the sub-image i (an integer 1 <= I <= N), onto the canvas. rect specifies a rectangle to blit to.
Next: Excuses, Previous: Miscellaneous Utilities, Up: The (sdl *) Modules [Contents][Index]