Menu

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

Download this file

30 lines (24 with data), 1.1 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
29
;;;;; Converted from the "Functions" Processing example at:
;;;;; "http://www.processing.org/learning/examples/functions.html"
;;;;; (C)2006 Luke J Crook
(in-package #:sdl-gfx-examples)
(defun draw-target (xloc yloc size num)
(let ((grayvalues (sdl:cast-to-int (/ 255 num)))
(steps (sdl:cast-to-int (/ size num))))
(dotimes (i num)
(sdl:with-color (col (sdl:color :r (* i grayvalues) :g (* i grayvalues) :b (* i grayvalues)))
(sdl-gfx:draw-filled-ellipse-* xloc yloc (- size (* i steps)) (- size (* i steps))
:surface sdl:*default-display*)))))
(defun functions ()
(let ((width 200) (height 200))
(sdl:with-init ()
(sdl:window width height :title-caption "Functions, from Processing.org")
(setf (sdl:frame-rate) 5)
(sdl:clear-display (sdl:color :r 51 :g 51 :b 51))
(draw-target 68 34 100 10)
(draw-target 152 16 50 3)
(draw-target 100 144 40 5)
(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.