LISPBUILDER-SDL-GFX -


 

Abstract

LISPBUILDER-SDL-GFX provides a Lisp wrapper for the SDL_gfx library, and provides support for renering several graphics primitives directly to SDL surfaces. LISPBUILDER-SDL-GFX has a dependency on the LISPBUILDER-SDL package. LISPBUILDER-SDL-GFX is distributed under the MIT-style license.

Current Version: The current version of LISPBUILDER-SDL-GFX is version 0.2.


 

Package Overview

Functions and symbols exported from the LISPBUILDER-SDL-GFX package are accessible from the LISPBUILDER-SDL-GFX: prefix or the shorter form SDL-GFX: nickname.


 

Simple Example

This example was created with the following code:

Width and Height

(defun width-height ()
  (let ((width 200) (height 200))
    (sdl:with-init ()
      (sdl:window width height :title-caption "Width and Height, from Processing.org")
      (sdl:clear-display (sdl:color :r 127 :g 127 :b 127))
      (loop for i from 0 to height by 20
	 do (progn (sdl-gfx:draw-box (sdl:rectangle :x 0 :y i :w 200 :h 10)
				     :color sdl:*black*)
		   (sdl-gfx:draw-box (sdl:rectangle :x i :y 0 :w 10 :h 200)
				     :color sdl:*white*)))
      (sdl:with-events ()
	(:quit-event () t)
	(:video-expose-event () (sdl:update-display))))))
      
  1. LISPBUILDER-SDL-GFX
    1. Abstract
    2. Package Overview
    3. Simple Example
    4. Compatibility
    5. Download
    6. Installation
    7. Usage
    8. Examples
    9. Dependencies
    10. License
    11. LISPBUILDER-SDL-GFX dictionary
      1. INDEX
    12. Acknowledgements

 

The LISPBUILDER-SDL-GFX dictionary Index

  1. *default-font*
  2. *font-10x20*
  3. *font-5x7*
  4. *font-5x8*
  5. *font-6x10*
  6. *font-6x12*
  7. *font-6x13*
  8. *font-6x13b*
  9. *font-6x13o*
  10. *font-6x9*
  11. *font-7x13*
  12. *font-7x13b*
  13. *font-7x13o*
  14. *font-7x14*
  15. *font-7x14b*
  16. *font-8x13*
  17. *font-8x13b*
  18. *font-8x13o*
  19. *font-8x8*
  20. *font-9x15*
  21. *font-9x15b*
  22. *font-9x18*
  23. *font-9x18b*
  24. draw-aa-circle
  25. draw-aa-circle-*
  26. draw-aa-ellipse
  27. draw-aa-ellipse-*
  28. draw-aa-line
  29. draw-aa-line-*
  30. draw-aa-polygon
  31. draw-aa-trigon
  32. draw-bezier
  33. draw-box
  34. draw-box-*
  35. draw-character-shaded
  36. draw-character-shaded-*
  37. draw-character-solid
  38. draw-character-solid-*
  39. draw-circle
  40. draw-circle-*
  41. draw-curve
  42. draw-ellipse
  43. draw-ellipse-*
  44. draw-filled-circle
  45. draw-filled-circle-*
  46. draw-filled-ellipse
  47. draw-filled-ellipse-*
  48. draw-filled-pie
  49. draw-filled-pie-*
  50. draw-filled-polygon
  51. draw-filled-trigon
  52. draw-font
  53. draw-font
  54. draw-font-at
  55. draw-font-at-*
  56. draw-hline
  57. draw-line
  58. draw-line-*
  59. draw-pie
  60. draw-pie-*
  61. draw-pixel
  62. draw-pixel-*
  63. draw-polygon
  64. draw-rectangle
  65. draw-rectangle-*
  66. draw-shape
  67. draw-string-shaded
  68. draw-string-shaded-*
  69. draw-string-solid
  70. draw-string-solid-*
  71. draw-trigon
  72. draw-vline
  73. font
  74. font-height
  75. font-width
  76. free-font
  77. initialise-default-font
  78. initialise-font
  79. render-string-shaded
  80. render-string-solid
  81. roto-zoom-size
  82. roto-zoom-size-xy
  83. roto-zoom-xy
  84. set-default-font
  85. with-bezier
  86. with-curve
  87. with-shape
  88. zoom-surface
  89. zoom-surface-size

 

Compatibility

The following table describes the status of the Lisp implementations that have been tested with LISPBUILDER-SDL-GFX:

Lisp Implementation LISPBUILDER-SDL-GFX Status Comments
Win32 Linux MacOS
CLISP v2.38 Working Working No
Lispworks v4.4.6 Personal Working Working No
Allegro Express 8.0 Unknown Unknown No
OpenMCL NA NA Unknown
SBCL Working Working No

 

Download


 

Installation

See the LISPBUILDER documentation for installation instructions.


 

Using LISPBUILDER-SDL-GFX

See the LISPBUILDER documentation for Usage instructions.


 

Running Examples in LISPBUILDER-SDL-GFX-EXAMPLES

Enter the following at the REPL to load the examples included in the LISPBUILDER-SDL-GFX-EXAMPLES package:

	  (asdf:operate 'asdf:load-op :lispbuilder-sdl-gfx-examples)
	

Run the examples by entering any of the following at the REPL:


 

Dependencies

LISPBUILDER-SDL-GFX has a dependency on LISPBUILDER-SDL.


 

License

LISPBUILDER-SDL-GFX is distributed under the MIT-style license.


 

The LISPBUILDER-SDL-GFX dictionary


[Special variable]
*default-font*


When a LISPBUILDER-SDL-GFX function or macro has an OPTIONAL or KEYword argument FONT, the default action is to bind to *DEFAULT-FONT*.*DEFAULT-FONT* is set to NIL initially. A font must be initialized by calling INITIALISE-DEFAULT-FONT prior to use.


[Special variable]
*font-10x20*


Contains the font data for an 10x20 bitmap font.


[Special variable]
*font-5x7*


Contains the font data for an 5x7 bitmap font.


[Special variable]
*font-5x8*


Contains the font data for an 5x8 bitmap font.


[Special variable]
*font-6x10*


Contains the font data for an 6x10 bitmap font.


[Special variable]
*font-6x12*


Contains the font data for an 6x12 bitmap font.


[Special variable]
*font-6x13*


Contains the font data for an 6x13 bitmap font.


[Special variable]
*font-6x13b*


Contains the font data for an 6x13 bitmap font.


[Special variable]
*font-6x13o*


Contains the font data for an 6x13 bitmap font.


[Special variable]
*font-6x9*


Contains the font data for an 6x9 bitmap font.


[Special variable]
*font-7x13*


Contains the font data for an 7x13 bitmap font.


[Special variable]
*font-7x13b*


Contains the font data for an 7x13 bitmap font.


[Special variable]
*font-7x13o*


Contains the font data for an 7x13 bitmap font.


[Special variable]
*font-7x14*


Contains the font data for an 7x14 bitmap font.


[Special variable]
*font-7x14b*


Contains the font data for an 7x14 bitmap font.


[Special variable]
*font-8x13*


Contains the font data for an 8x13 bitmap font.


[Special variable]
*font-8x13b*


Contains the font data for an 8x13 bitmap font.


[Special variable]
*font-8x13o*


Contains the font data for an 8x13 bitmap font.


[Special variable]
*font-8x8*


Contains the font data for an 8x8 bitmap font.


[Special variable]
*font-9x15*


Contains the font data for an 9x15 bitmap font.


[Special variable]
*font-9x15b*


Contains the font data for an 9x15 bitmap font.


[Special variable]
*font-9x18*


Contains the font data for an 9x18 bitmap font.


[Special variable]
*font-9x18b*


Contains the font data for an 9x18 bitmap font.


[Function]
draw-aa-circle p1 r &key surface color => result


See DRAW-AA-CIRCLE-*.

Parameters


[Function]
draw-aa-circle-* x y r &key surface color => result


Draws the circumference of a circle of color COLOR to the surface SURFACE using anti-aliasing. Use DRAW-FILLED-CIRCLE-* to draw a filled circle.

Parameters


[Function]
draw-aa-ellipse p1 rx ry &key surface color => result


See DRAW-AA-ELLIPSE-*.

Parameters


[Function]
draw-aa-ellipse-* x y rx ry &key surface color => result


Draws the circumference of an ellipse of color COLOR to the surface SURFACE using anti-aliasing. Use DRAW-FILLED-ELLIPSE-* to draw a filled ellipse.

Parameters


[Function]
draw-aa-line point1 point2 &key surface color => result


See DRAW-AA-LINE-*-*

Parameters


[Function]
draw-aa-line-* x1 y1 x2 y2 &key surface color => result


Draws an antialiased line of color COLOR to the surface SURFACE.

Parameters


[Function]
draw-aa-polygon points &key surface color => result


Draw the circumference of a polygon of color COLOR to surface SURFACE using the vertices in POINTS. The polygon is anti-aliased. Use DRAW-FILLED-POLYGON-* to draw a filled polygon.

Parameters


[Function]
draw-aa-trigon point1 point2 point3 &key surface color => result


Draw the outline of a trigon or triangle, of color COLOR to surface SURFACE using anti-aliasing. Use DRAW-FILLED-TRIGON-* to draw a filled trigon.

Parameters


[Function]
draw-bezier points steps &key surface color => result


Draw a bezier curve of color COLOR to the surface SURFACE. The shape of the Bezier curve is defined by several control points. A control point is a vertex containing an X and Y coordinate pair.

Parameters
Example
(DRAW-BEZIER (LIST (SDL:POINT :X 60  :Y 40)
                     (SDL:POINT :X 160 :Y 10)
                     (SDL:POINT :X 170 :Y 150)
                     (SDL:POINT :X 60 :Y 150))
               10)


[Function]
draw-box rect &key surface color => result


See DRAW-BOX-*.

Parameters


[Function]
draw-box-* x y w h &key surface color => result


Draws a filled rectangle of color COLOR to surface SURFACE.

Parameters


[Function]
draw-character-shaded c p1 fg-color bg-color &key font surface => result


See DRAW-CHARACTER-SHADED-*.

Parameters


[Function]
draw-character-shaded-* c x y fg-color bg-color &key font surface => result


Draw the character C at location XY using font FONT with text color FG-COLOR and background color BG-COLOR onto surface SURFACE. The surface background is filled with BG-COLOR so the surface cannot be keyed over other surfaces.

Returns
Example
(DRAW-CHARACTER-SHADED-* "Hello World!" 0 0 F-COLOR B-COLOR :SURFACE A-SURFACE)


[Function]
draw-character-solid c p1 &key font surface color => result


See DRAW-CHARACTER-SOLID-*.

Parameters


[Function]
draw-character-solid-* c x y &key font surface color => result


Draw character C at location XY using font FONT with text color COLOR onto surface SURFACE. The character is keyed onto SURFACE.

Parameters
Returns
Example
(DRAW-CHARACTER-SOLID-* "Hello World!" 0 0 :SURFACE A-SURFACE :COLOR A-COLOR)


[Function]
draw-circle p1 r &key surface color => result


See DRAW-CIRCLE-*.

Parameters


[Function]
draw-circle-* x y r &key surface color => result


Draws a circle circumference of color COLOR to the surface SURFACE. Use DRAW-FILLED-CIRCLE-* to draw a filled circle.

Parameters


[Function]
draw-curve points type segments &key surface color => result


Draw a Cattmul-Rom spline using color COLOR to the surface SURFACE. The shape of the curve is defined by waypoints. A waypoint is a vertex containing an X and Y coordinate pair.

Parameters
Example
(DRAW-CURVE (LIST (SDL:POINT :X 60  :Y 40)
    	  (SDL:POINT :X 160 :Y 10)
	  (SDL:POINT :X 170 :Y 150)
	  (SDL:POINT :X 60  :Y 150))
    :LINE-STRIP
    10)


[Function]
draw-ellipse p1 rx ry &key surface color => result


See DRAW-ELLIPSE-*.

Parameters


[Function]
draw-ellipse-* x y rx ry &key surface color => result


Draws an ellipse circumference of color COLOR to the surface SURFACE. Use DRAW-FILLED-ELLIPSE-* to draw a filled ellipse.

Parameters


[Function]
draw-filled-circle p1 r &key surface color => result


See DRAW-FILLED-CIRCLE-*.

Parameters


[Function]
draw-filled-circle-* x y r &key surface color => result


Draws a filled circle of color COLOR to the surface SURFACE.

Parameters


[Function]
draw-filled-ellipse p1 rx ry &key surface color => result


See DRAW-FILLED-ELLIPSE-*.

Parameters


[Function]
draw-filled-ellipse-* x y rx ry &key surface color => result


Draws a filled ellipse of color COLOR to the surface SURFACE.

Parameters


[Function]
draw-filled-pie p1 rad start end &key surface color => result


See DRAW-FILLED-PIE-*.

Parameters


[Function]
draw-filled-pie-* x y rad start end &key surface color => result


Draws a filled pie of color COLOR to the surface SURFACE.

Parameters


[Function]
draw-filled-polygon points &key surface color => result


Draw a filled polygon, of color COLOR to surface SURFACE.

Parameters


[Function]
draw-filled-trigon point1 point2 point3 &key surface color => result


Draw a filled trigon, of color COLOR to surface SURFACE.

Parameters


[Generic function]
draw-font &key font surface => result


Blit the cached SURFACE in FONT to the destination surface SURFACE. The cached surface is created during a previous call to any of the DRAW-STRING* functions. Uses POSITION in the cached SURFACE to render to the X/Y coordinates on the destination SURFACE.

This function can speed up blitting when the text remains unchanged between screen updates.


[Function]
draw-font &key font surface => result



[Generic function]
draw-font-at position &key font surface => result


See DRAW-FONT. POINT is used to position the cached SURFACE, where POINT is of type SDL:POINT.


[Method]
draw-font-at position &key font surface => result



[Generic function]
draw-font-at-* x y &key font surface => result


See DRAW-FONT. X and Y are used to position the cached SURFACE, where X and Y are INTEGERS.


[Method]
draw-font-at-* x y &key font surface => result



[Function]
draw-hline x1 x2 y &key surface color => result


Draw a horizontal line of color COLOR from X1 to X2 through Y onto the surface SURFACE.

Parameters


[Function]
draw-line point1 point2 &key surface color => result


See DRAW-LINE-*.

Parameters


[Function]
draw-line-* x1 y1 x2 y2 &key surface color => result


Draws a line of color COLOR to the surface SURFACE.

Parameters


[Function]
draw-pie p1 rad start end &key surface color => result


See DRAW-PIE-*.

Parameters


[Function]
draw-pie-* x y rad start end &key surface color => result


Draws a pie of color COLOR to the surface SURFACE. Use DRAW-FILLED-PIE-* to draw a filled pie.

Parameters


[Function]
draw-pixel position &key surface color => result


See DRAW-PIXEL-*.

Parameters


[Function]
draw-pixel-* x y &key surface color => result


Draw a single pixel of color COLOR to the surface SURFACE at the specified X and Y coordiates.

Parameters


[Function]
draw-polygon points &key surface color => result


Draw the circumference of a polygon of color COLOR to surface SURFACE using the vertices in POINTS. Use DRAW-FILLED-POLYGON-* to draw a filled polygon.

Parameters


[Function]
draw-rectangle rect &key surface color => result


See DRAW-RECTANGLE-*.

Parameters


[Function]
draw-rectangle-* x y w h &key surface color => result


Draw a rectangle outline of color COLOR to the surface SURFACE.

Parameters


[Function]
draw-shape points type &key surface color => result


Draw a polygon of color COLOR to the surface SURFACE using the vertices in POINTS.

Parameters
Example
(DRAW-SHAPE (LIST (SDL:POINT :X 60  :Y 40)
	    (SDL:POINT :X 160 :Y 10)
	    (SDL:POINT :X 170 :Y 150)
	    (SDL:POINT :X 60  :Y 150))
    :LINE-STRIP)


[Function]
draw-string-shaded c p1 fg-color bg-color &key font surface => result


See DRAW-STRING-SHADED-*.

Parameters


[Function]
draw-string-shaded-* c x y fg-color bg-color &key font surface => result


Draw text C using at location XY using font FONT with text color FG-COLOR and background color BG-COLOR onto surface SURFACE. The surface background is filled with BG-COLOR so the surface cannot be keyed over other surfaces.

Returns
Example
(DRAW-STRING-SHADED-* "Hello World!" 0 0 F-COLOR B-COLOR :SURFACE A-SURFACE)


[Function]
draw-string-solid c p1 &key font surface color => result


See DRAW-STRING-SOLID-*.

Parameters


[Function]
draw-string-solid-* c x y &key font surface color => result


Draw text C at location XY using font FONT with color COLOR onto surface SURFACE. The text is keyed onto SURFACE.

Parameters
Returns
Example
(DRAW-STRING-SOLID-* "Hello World!" 0 0 :SURFACE A-SURFACE :COLOR A-COLOR)


[Function]
draw-trigon point1 point2 point3 &key surface color => result


Draw the outline of a trigon or triangle, of color COLOR to surface SURFACE. Use DRAW-FILLED-TRIGON-* to draw a filled trigon.

Parameters


[Function]
draw-vline x y1 y2 &key surface color => result


Draw a vertical line of color COLOR from Y1 to Y2 through X onto the surface SURFACE.

Parameters


[Standard class]
font


A FONT object manages the resources for the font. These resources include any cached surface as well as the foreign array containing the font data.

The cached surface is created by a call to any of the RENDER-STRING* functions. Use DRAW-FONT, DRAW-FONT-AT or DRAW-FONT-AT-* to draw the cached surface.

Prior to the first call to a RENDER-STRING* function, the cached surface is NIL.


[Generic function]
font-height font => result



[Method]
font-height (font font) => result



[Generic function]
font-width font => result



[Method]
font-width (font font) => result



[Generic function]
free-font font => result



[Method]
free-font (font font) => result


Free resources associated with the font FONT. This includes freeing the cached surface and the foreign array containing the font data.


[Function]
initialise-default-font &optional font-definition => result


Creates a new FONT object from the font definition in FONT-DEFINITION. Sets the font FONT as the default font to be used for subsequent font rendering or drawing operations.

Binds the symbol *DEFAULT-FONT* to font. Functions that take a FONT argument use *DEFAULT-FONT* unless otherwise specified. Returns a new FONT, or NIL if unsuccessful.


[Function]
initialise-font font-definition => result


Creates a new FONT object from the font data in FONT-DEFINITION. Returns a new FONT, or NIL if unsuccessful.


[Function]
render-string-shaded string fg-color bg-color &key font free cache => result


Render the string STRING using font FONT with text color FG-COLOR and background color BG-COLOR to a new SURFACE. The dimensions of the new surface are height == FONT height, and width == FONT width * STRING length. The surface background is filled with BG-COLOR so the surface cannot be keyed over other surfaces. Use :CACHE T to cache the new surface in the FONT object. When :FREE T any exisiting cached surface in FONT is automatically freed. When :FREE NIL the caller is responsible for freeing any existing cached surface in FONT.

Parameters
Returns
Example
(DRAW-STRING-SHADED "Hello World!" F-COLOR B-COLOR)


[Function]
render-string-solid string &key font color free cache => result


Render the string STRING using font FONT with text color COLOR to a new SURFACE. The dimensions of the new surface are height == FONT height, and width == FONT width * STRING length. The surface background is transparent and therefore can be keyed over other surfaces. Use :CACHE T to cache the new surface in the FONT object. When :FREE T any exisiting cached surface in FONT is automatically freed. When :FREE NIL the caller is responsible for freeing any existing cached surface in FONT.

Parameters
Returns
Example
(DRAW-STRING-SOLID "Hello World!" :COLOR A-COLOR)


[Function]
roto-zoom-size width height angle zoom => result



[Function]
roto-zoom-size-xy width height angle zoomx zoomy => result



[Function]
roto-zoom-xy angle zoomx zoomy smooth &key surface => result



[Function]
set-default-font font => result


Sets the font FONT as the default font to be used for subsequent font rendering or drawing operations. Binds the symbol *DEFAULT-FONT* to font. Functions that take a FONT argument use *DEFAULT-FONT* unless otherwise specified. Returns a new FONT, or NIL if unsuccessful.


[Macro]
with-bezier (&optional segments) declaration* statement* => result


Draw a bezier curve of color *DEFAULT-COLOR* to the surface *DEFAULT-SURFACE*. The shape of the Bezier curve is defined by control points. A control point is a vertex containing an X and Y coordinate pair.

Local Methods

A vertex may be added using:

ADD-VERTEX and ADD-VERTEX-* are valid only within the scop of WITH-BEZIER.

Parameters
Example
(SDL:WITH-COLOR (COL (SDL:COLOR))
   (WITH-BEZIER (30)
     (ADD-VERTEX-* 60  40)
     (ADD-VERTEX-* 160 10)
     (ADD-VERTEX-* 170 150)
     (ADD-VERTEX-* 60  150)))


[Macro]
with-curve (shape-type &optional segments) declaration* statement* => result


Draw a Cattmul-Rom spline of color *DEFAULT-COLOR* to the surface *DEFAULT-SURFACE*. The shape of the curve is defined by waypoints. A waypoint is a vertex containing an X and Y coordinate pair.

Local Methods

A vertex may be added using:

ADD-VERTEX and ADD-VERTEX-* are valid only within the scope of WITH-CURVE.

Parameters
Example
(SDL:WITH-COLOR (COL (SDL:COLOR))
   (WITH-CURVE (:LINE-STRIP 30)
     (ADD-VERTEX-* 60  40)
     (ADD-VERTEX-* 160 10)
     (ADD-VERTEX-* 170 150)
     (ADD-VERTEX-* 60  150)))


[Macro]
with-shape (shape-type) declaration* statement* => result


Draw a polygon of color *DEFAULT-COLOR* to the surface *DEFAULT-SURFACE*.

Local Methods

A vertex may be added using:

ADD-VERTEX and ADD-VERTEX-* are valid only within the scop of WITH-SHAPE.

Parameters
Example
(SDL:WITH-COLOR (COL (SDL:COLOR))
   (WITH-SHAPE (:POINTS)
     (ADD-VERTEX-* 60  40)
     (ADD-VERTEX-* 160 10)
     (ADD-VERTEX-* 170 150)
     (ADD-VERTEX-* 60  150)))


[Function]
zoom-surface zoomx zoomy smooth &key surface => result



[Function]
zoom-surface-size width height zoomx zoomy => result



 

Acknowledgements

BACK