3 ;; rotationn-demo.lsp - demonstrate gs:rotate-tag, gs:translate-tag and gs:scale-tag
4 ;; and the mouse-wheel rotating an object
8 (load (append (env "NEWLISPDIR") "/guiserver.lsp"))
14 (gs:frame
'RotationDemo
100 100 600 600 "Image demo")
15 (gs:set-border-layout
'RotationDemo
)
16 ;(gs:set-resizable 'RotationDemo nil)
18 (gs:set-background
'MyCanvas gs
:white
)
20 (gs:radio-button
'ZoomButton
'zoom-action
"zoom")
21 (gs:radio-button
'TurnButton
'turn-action
"turn")
22 (gs:set-selected
'TurnButton true
)
24 (gs:add-to
'Select
'ZoomButton
'TurnButton
)
25 (gs:add-to
'RotationDemo
'MyCanvas
"center" 'Select
"south")
26 (gs:mouse-wheel
'MyCanvas
'mouse-wheel-action
)
28 ;(gs:set-scale 0.5 0.5) ; only for testing
30 (gs:set-font
'MyCanvas
"Lucida Sans Oblique" 14 "plain")
31 (gs:draw-text
'T
"turn mouse wheel to turn or zoom image" 20 50 gs
:darkGray
)
32 (gs:fill-circle
'C
0 0 50 gs
:red
)
33 (gs:fill-circle
'C -
40 -
40 30 gs
:black
)
34 (gs:fill-circle
'C
40 -
40 30 gs
:black
)
35 (gs:fill-circle
'C
0 10 8 gs
:yellow
)
36 (gs:translate-tag
'C
300 300)
38 (gs:set-visible
'RotationDemo true
)
42 (define (zoom-action id flag
)
43 (gs:set-selected
'TurnButton
(not flag
))
44 (set 'turn-flag
(not flag
))
47 (define (turn-action id flag
)
48 (gs:set-selected
'ZoomButton
(not flag
))
52 (define (mouse-wheel-action x y wheel
)
54 (gs:rotate-tag
'C wheel
0 0)
56 (gs:scale-tag
'C
0.9 0.9)
57 (gs:scale-tag
'C
1.1 1.1)