Looks very cool, I especially like how the code for a simple application has shrunk.
Justin On 6/23/06, Luke J Crook <[EMAIL PROTECTED]> wrote: > Ok, > > I've finished most of what I wanted to do with the lispbuilder-sdl API's. > Everything is now committed to SVN. > > There are now two ways of doing things. I'll describe the new way first, and > then give the same example using the 'old' way: > > 1) The 'new' very Lispy way: > I took a look at Edi Weitz's CL-GD and came up with a similar API for > lispbuilder-sdl. > > There are now tree global variables in the lispbuilder-sdl package: > *default-surface*, *default-display* and *default-color*. > > All functions (except BLIT-SURFACE) that take a surface and/or a color will > default to using these variables unless another is provided. > > This means that is is possible to just write: > - (UPDATE-SURFACE), as UPDATE-SURFACE takes an &optional (surface > *default-surface*) > - (DRAW-RECT (sdl:random-rect width height)), as DRAW-RECT takes &key > (surface *default-surface*) (color *default-color*) > > The macroes that modify *default-surface*, *default-display* and > *default-color* are; > - WITH-SURFACE, > - WITH-DISPLAY > - WITH-DEFAULT-COLOR > > WITH-DISPLAY sets up *default-surface*, *default-display*. > > WITH-SURFACE and WITH-DEFAULT-COLOR use lexical scope to 'push'/'pop' > surfaces and colors on *default-surface* and *default-color* > > So, to draw random rects to the screen: > > (defun random-rects1 () > (let ((width 320) (height 240)) > (sdl:with-init () > (sdl:with-display (width height) > (sdl:with-events > (:quit t) > (:idle > (sdl:with-default-color ((sdl:random-color)) > (sdl:draw-rect (sdl:random-rect width height) :update-p t)))))))) > > 2) The 'other' API. > All these functions still take a surface and color either as &optional or a > &key'word' arguments. > > So the previous example could still be written as: > > (defun random-rects1 () > (let ((width 320) (height 240)) > (sdl:with-init () > (sdl:with-display (width height) > (sdl:with-events > (:quit t) > (:idle > (sdl:draw-rect (sdl:random-rect width height) :update-p t > :surface sdl:*default-surface* > :color (sdl:random-color)))))))) > > > > I have also updates lispbuilder-sdl-gfx to have the same API's. For example: > > (defun draw-pixel (point &key (surface sdl:*default-surface*) (color > sdl:*default-color*)) > > (defun draw-box (rect &key (surface sdl:*default-surface*) (color > sdl:*default-color*)) > > The changes to lispbuilder-sdl-gfx are also in SVN. > > - Luke > _______________________________________________ > application-builder mailing list > [email protected] > http://www.lispniks.com/mailman/listinfo/application-builder > _______________________________________________ application-builder mailing list [email protected] http://www.lispniks.com/mailman/listinfo/application-builder
