3 ;; strokes-demo.lsp - demonstrate strokes with round endings in different lines and outlines
7 (load (append (env "NEWLISPDIR") "/guiserver.lsp"))
9 ;; subroutines for random shapes
12 (define (random-draw-line)
13 (gs:draw-line
'L
(rand 640) (rand 640) (rand 640) (rand 640) (list (random) (random) (random))))
15 (define (random-draw-rect)
16 (gs:draw-rect
'R
(rand 640) (rand 640) (rand 100) (rand 100) (list (random) (random) (random))))
18 (define (random-draw-round-rect)
19 (gs:draw-round-rect
'R
(rand 640) (rand 640) (rand 100) (rand 100)
20 (rand 40) (rand 40) (list (random) (random) (random))))
22 (define (random-draw-circle)
23 (gs:draw-circle
'C
(rand 640) (rand 640) (rand 100) (list (random) (random) (random))))
25 (define (random-draw-ellipse)
26 (gs:draw-ellipse
'E
(rand 640) (rand 640) (rand 100) (rand 100) (list (random) (random) (random))))
28 (define (random-draw-arc)
29 (gs:draw-arc
'A
(rand 640) (rand 640) (rand 100) (rand 100) (rand 360) (rand 360) (list (random) (random) (random))))
35 (gs:frame
'StrokesDemo
100 100 640 640 "Random lines, rectangles, circles, ellipses and arcs Demo")
36 (gs:set-border-layout
'StrokesDemo
)
37 (gs:canvas
'MyCanvas
'StrokesDemo
)
39 (gs:label
'HelpText
"show or hide shapes:")
40 (gs:check-box
'LineSelect
'select-action
"lines")
41 (gs:check-box
'RectangleSelect
'select-action
"rectangles")
42 (gs:check-box
'CircleSelect
'select-action
"circles")
43 (gs:check-box
'EllipseSelect
'select-action
"ellipse")
44 (gs:check-box
'ArcSelect
'select-action
"arcs")
45 (gs:set-selected
'LineSelect true
'RectangleSelect true
'CircleSelect true
'EllipseSelect true
'ArcSelect true
)
46 (gs:add-to
'Selection
'HelpText
'LineSelect
'RectangleSelect
'CircleSelect
'EllipseSelect
'ArcSelect
)
47 (gs:add-to
'StrokesDemo
'MyCanvas
"center" 'Selection
"south")
48 (gs:set-background
'MyCanvas gs
:white
)
50 ; default color if not specified in shape or text
51 (gs:set-paint gs
:darkGray
)
53 ;(gs:set-translation 100 100) ;only for test, will shift everything
54 ;(gs:set-scale 0.5 0.5) ; only for testing scrinks or zooms
56 (println (time-of-day))
58 (gs:set-stroke
(rand 16) "round")
61 (random-draw-round-rect)
66 (println (time-of-day))
68 (gs:set-font
'MyCanvas
"Lucida Sans Regular" 40 "italic")
69 (gs:draw-text
'T
"Random" 60 100)
70 (gs:set-font
'MyCanvas
"Monospaced" 40 "plain")
71 (gs:draw-text
'T
"Outlines and strokes" 60 160 gs
:green -
15)
72 ;(gs:draw-text 'T "Third text line" 60 220) ; only for testing
74 (gs:set-visible
'StrokesDemo true
)
78 (define (select-action id flag
)
80 ("MAIN:LineSelect" 'L
)
81 ("MAIN:RectangleSelect" 'R
)
82 ("MAIN:CircleSelect" 'C
)
83 ("MAIN:EllipseSelect" 'E
)
84 ("MAIN:ArcSelect" 'A
))
92 (gs:add-to
'Selection
'HelpText
'LineSelect
'RectangleSelect
'CircleSelect
'EllipseSelect
'ArcSelect
)
93 ;;;; listen for incoming action requests and dispatch
95 ;(gs:export "shapes.png") ; just for testing