Barnsley fern: Difference between revisions

m
minor edits
(Add Common Lisp implementation)
m (minor edits)
Line 245:
 
(defun set-pixel (image x y)
(let ((%x (truncate (+ (* *factor* x) (floor/ *width* 2))))
(%y (truncate (- *height* (* *factor* y) *y-offset*))))
(setf (pixel image %y %x) (values 0 255 0))))
 
(defun fern (filespec &optional (iterations 10000000))
(loop withlet ((image = (make-8-bit-rgb-image *height* *width* :initial-element 0))
with (x = 0)
with (y = 0))
(dotimes (i iterations)
do (set-pixel image x y)
(set-pixel image repeatx iterationsy)
do (multiple-value-setq (x y) (funcall (choose-transform) x y)))
finally (write-png-file filespec image)))</lang>
 
=={{header|Delphi}}==
68

edits