Page 1 of 1

figures for all

Posted: Wed Dec 13, 2006 11:44 am
by newdep
Just for the fun I created a program that prints itself as a triangle..
(http://www.nodep.nl/downloads/newlisp/triangle.lsp)

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

Regards, Norman.

Posted: Wed Dec 13, 2006 12:58 pm
by cormullion
I like it!

Posted: Wed Dec 13, 2006 4:52 pm
by cormullion
This diagram is a bit lossy, so you might not be able to reconstruct the source from it...

(and choose a small font)

Code: Select all

(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)

Posted: Wed Dec 13, 2006 5:11 pm
by newdep
aaah a spiral ! nice work! ;-)

Posted: Wed Dec 13, 2006 8:31 pm
by Sleeper
great, i like it!

Code: Select all

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

(set 'cc (find-all "[^\t\n\r]" (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

Posted: Fri Dec 15, 2006 7:51 am
by newdep
nice nice a Circle .. the figures get complete ;-)