Menu

[r760]: / trunk / lispbuilder-sdl-gfx / examples / recursion.lisp  Maximize  Restore  History

Download this file

29 lines (24 with data), 1.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;;;;; Converted from the "Recursion" Processing example at:
;;;;; "http://www.processing.org/learning/examples/recursion.html"
;;;;; (C)2006 Luke J Crook
(in-package #:sdl-gfx-examples)
(defun draw-circle (x radius level)
(let ((tt (* 126 (/ level 4.0))))
(sdl-gfx:draw-filled-ellipse (sdl:point :x x :y 100) (sdl:cast-to-int radius) (sdl:cast-to-int radius)
:color (sdl:color :r tt :g tt :b tt)
:surface sdl:*default-display*)
(when (> level 1)
(decf level 1)
(draw-circle (- x (/ radius 2)) (/ radius 2) level)
(draw-circle (+ x (/ radius 2)) (/ radius 2) level))))
(defun recursion ()
(let ((width 200) (height 200))
(sdl:with-init ()
(sdl:window width height :title-caption "Recursion, from Processing.org")
(setf (sdl:frame-rate) 5)
(sdl:clear-display (sdl:color :r 0 :g 0 :b 0))
(draw-circle 126 170 6)
(sdl:update-display)
(sdl:with-events ()
(:quit-event () t)
(:video-expose-event () (sdl:update-display))))))
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.