Random Bits of Open Code

Check-in [6915e3fe7e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Added big arrow polygon generator
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:6915e3fe7e87ceac37094156ebd13d20653132bc
User & Date: matt 2018-08-01 05:44:39
Context
2018-08-02
00:39
Dunno check-in: 237f2b7191 user: mrwellan tags: trunk
2018-08-01
05:44
Added big arrow polygon generator check-in: 6915e3fe7e user: matt tags: trunk
2018-07-31
05:58
Trying out vg for help graphics check-in: e00c2f28be user: matt tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to multiapp/src/learn-teach-help.scm.

17
18
19
20
21
22
23

























24
25
26
27
28
29
30

31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48












49
50

51
52
53
54
55
56
57
 ;;  ;; vg:draw-rect
 ;;  ;; vg:grow-rect
 ;;  vg:get-extents-for-objs
 ;;  vg:components-get-extents
 ;;  vg:instances-get-extents
 ;;  vg:get-extents-for-two-rects
 ;;  canvas-line!)


























(let* ((help-drawing (make-drawing))
       (hlib         (make-lib))
       ;; components
       (title        (make-comp))    ;; title block
       (subjects     (make-comp))    ;; subjects tree
       (active       (make-comp)))   ;; most active sessions

  (add-lib help-drawing "hlib" hlib) ;; add library hlib to drawing
  ;; build up the title
  (add-objs-to-comp title (rectangle 0 0 158 18 text: "Learn Something!" font: "Helvetica, -40"))
  (add-comp-to-lib hlib "title" title) ;; add component help-learn to library help-lib

  ;; add objects to subjects tree sketch
  (add-objs-to-comp
   subjects
   (rectangle 0 80 80 200)
   (line 10 190 20 190)
   (line 20 190 20 150)
   (line 20 180 30 180)
   (text 31 178 "unix" font: "Helvetica, -20")
   (line 40 178 40 170)
   (text 32 162 "11:00" font: "Helvetica, -20")
   )
  (add-comp-to-lib hlib "subj" subjects)
  












  (instantiate help-drawing "hlib" "title" "t1" 20 220)  ;; instantiate component title from library hlib in drawing help-drawing
  (instantiate help-drawing "hlib" "subj"  "s1" 20 10) ;; instantiate component subj  from library hlib in drawing help-drawing

  (drawing-scalex-set! help-drawing 1.5)
  (drawing-scaley-set! help-drawing 1.5)

  (drawing-update-proc-set!
   help-drawing
   (lambda (dwg c xadj yadj)
     (canvas-clear! c)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>






|
>












|
|




>
>
>
>
>
>
>
>
>
>
>
>


>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
 ;;  ;; vg:draw-rect
 ;;  ;; vg:grow-rect
 ;;  vg:get-extents-for-objs
 ;;  vg:components-get-extents
 ;;  vg:instances-get-extents
 ;;  vg:get-extents-for-two-rects
 ;;  canvas-line!)

;; make a big arrow outline (will add fill later
;;  l = length base to tip
;;  t = base thickness. tip is 1.5t long and 1.5t wide
;;  a = angle from vertical
;;  returns a list of points `( x0 y0 x1 y1 x2 y2 ... xn yn )
;;
(define (big-arrow l t angle)
  (let* ((t/2    (/ t 2))
	 (t/4    (/ t 4))
	 (hl     (* 1.5 t))       ;; arrow head length
	 (l-h    (- l hl))        ;; length of arrow body
	 (a      `(,(- t/2) 0))
	 (b      `(,(- t/2) ,l-h))
	 (c      `(,(- 0 t/2 t/4) ,l-h))
	 (d      `(0  ,l))
	 (e      `(,(+ t/2 t/4) ,l-h))
	 (f      `(,t/2 ,l-h))
	 (g      `(,t/2 0))
	 (all    (map (lambda (pt)
			(print "pt: " pt " (car pt): " (car pt) " (cadr pt): " (cadr pt))
			(geolib:rotate-pt angle (car pt)(cadr pt)))
		      (list a b c d e f g)))
	 (flat   (apply append all)))
    flat))

(let* ((help-drawing (make-drawing))
       (hlib         (make-lib))
       ;; components
       (title        (make-comp))    ;; title block
       (subjects     (make-comp))    ;; subjects tree
       (active       (make-comp))    ;; most active sessions
       (arrow        (make-comp)))
  (add-lib help-drawing "hlib" hlib) ;; add library hlib to drawing
  ;; build up the title
  (add-objs-to-comp title (rectangle 0 0 158 18 text: "Learn Something!" font: "Helvetica, -40"))
  (add-comp-to-lib hlib "title" title) ;; add component help-learn to library help-lib

  ;; add objects to subjects tree sketch
  (add-objs-to-comp
   subjects
   (rectangle 0 80 80 200)
   (line 10 190 20 190)
   (line 20 190 20 150)
   (line 20 180 30 180)
   (text 32 176 "unix" font: "Helvetica, -20")
   (line 40 175 40 170)
   (text 32 162 "11:00" font: "Helvetica, -20")
   )
  (add-comp-to-lib hlib "subj" subjects)
  
;;   (let ((l (vector 50 20 100 120)))
;;     (apply add-objs-to-comp subjects
;; 	   (map (lambda (angle)
;; 		  (let ((newl (geolib:rotate-line angle l 0 0)))
;; 		    (apply line (vector->list newl))))
  ;; 		'(0 22.5 45))))

  (add-objs-to-comp
   arrow
   (polygon (big-arrow 80 8 (deg->rad 45))))
  (add-comp-to-lib hlib "arrow1" arrow)
  
  (instantiate help-drawing "hlib" "title" "t1" 20 220)  ;; instantiate component title from library hlib in drawing help-drawing
  (instantiate help-drawing "hlib" "subj"  "s1" 20 10) ;; instantiate component subj  from library hlib in drawing help-drawing
  (instantiate help-drawing "hlib" "arrow1" "a1" 135 110)
  (drawing-scalex-set! help-drawing 1.5)
  (drawing-scaley-set! help-drawing 1.5)

  (drawing-update-proc-set!
   help-drawing
   (lambda (dwg c xadj yadj)
     (canvas-clear! c)