figures for all

Started by newdep, December 13, 2006, 03:44:58 AM

Previous topic - Next topic

newdep

Just for the fun I created a program that prints itself as a triangle..

(http://www.nodep.nl/downloads/newlisp/triangle.lsp">http://www.nodep.nl/downloads/newlisp/triangle.lsp)



But would be nice to see some other figures around here ;-)



Regards, Norman.
-- (define? (Cornflakes))

cormullion

#1
I like it!

cormullion

#2
This diagram is a bit lossy, so you might not be able to reconstruct the source from it...



(and choose a small font)




(set 'display-size '(250 250))

(setq B (clean (lambda (x) (find x '( "n" "r" "t" )))
(explode (read-file (main-args 1)))))

(set 'screen (array (first display-size) (last display-size) '(" ")))

(define (draw-screen)
(dotimes (r (first display-size))
(dotimes (c (last display-size))
(print (screen r c)))
(println)))

(define (squeeze-in n low high)
(and
(max n low)
(min n high)))

(define (draw-point x y (c "X"))
(nth-set
(squeeze-in x 0 (- (first display-size) 1))
(squeeze-in y 0 (- (last display-size) 1)) screen c))

(set 'PI 3.1415 'r 100 'c 0 'step 0.15)

(for (i 0.5 (mul 200 PI) step (> c (length B)))
(set 'r (mul 1.1 i))
(dec 'step 0.05)
(draw-point
(int (add (/ (first display-size) 2) (mul r (cos i))))
(int (add (/ (last display-size) 2) (mul r (sin i))))
(nth (inc 'c) B )))

(draw-screen)
(exit)

newdep

#3
aaah a spiral ! nice work! ;-)
-- (define? (Cornflakes))

Sleeper

#4
great, i like it!



; circle.lsp --
;    prints itself in a circle

(set 'cc (find-all "[^tnr]" (read-file (main-args 1))))
(set 'w (int (sqrt (div (length cc) 1.7 0.25))))
(set 'h (int (div w 1.5)))
(set 'g (dup (dup " " w true) h true))
(set 'r (div w 2.2))

(for (i 1 h) (for (j 1 w)
    (if (> (length cc) 0) (begin
       (set 'y (mul (sub (div h 2) i) 1.5))
       (set 'x (sub (div w 2) j))
       (if (< (sqrt (add (* x x) (* y y))) r)
       (nth-set (g i j) (pop cc)
   ))))))
       
(dolist (x g) (println (join x)))

(exit)


a quite ugly circle :p

newdep

#5
nice nice a Circle .. the figures get complete ;-)
-- (define? (Cornflakes))