File: circle.l

package info (click to toggle)
euslisp 9.27%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye
  • size: 55,344 kB
  • sloc: ansic: 41,162; lisp: 3,339; makefile: 256; sh: 208; asm: 138; python: 53
file content (23 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(defun points-on-circle (&optional (dia 200.0) (segments 64) )
  (let ((points) (anginc (/ 2pi segments)) (ang 0.0) x y)
    (dotimes (s segments)
	(setq x (* dia (cos ang))
	      y (* dia (sin ang)))
	(push (integer-vector (round x) (round y)) points)
	(incf ang anginc))
    (coerce (nreverse points) vector)))

(defun draw-lines (points &optional (skip 30) 
		(color 5)
		(count (length points))
		(offset #i(210 210)))
  (let ((point1 (elt points 0)) (point2) (index 0) (size (length points)))
     (send *viewsurface* :foreground 
		(aref image::*x-rainbow32-lut* color) ) ; (mod index 32)
     (dotimes (i count)
	(setq index (mod (incf index skip) size))
	(setq point2 (elt points index))
	(send *viewsurface* :draw-line (v+ offset point1) (v+ offset point2))
	(setq point1 point2)))
   (xflush)
  )