about summary refs log tree commit diff stats
path: root/mu.arc
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-12-23 23:38:16 -0800
committerKartik K. Agaram <vc@akkartik.com>2014-12-23 23:52:37 -0800
commitef55a4146609051c0a4cb1ca46693f620bd12118 (patch)
tree8d3ff0314afe2f5f227669afbfedd0b7c56fad27 /mu.arc
parent4630b4aee88e312f2682eb17b98d0144e48fd7d5 (diff)
downloadmu-ef55a4146609051c0a4cb1ca46693f620bd12118.tar.gz
443 - simple graphics primitives
http://docs.racket-lang.org/graphics/Mouse_Operations.html

Like with the text mode primitives, we still don't have a story for
writing white-box tests for code using these.
Diffstat (limited to 'mu.arc')
-rw-r--r--mu.arc17
1 files changed, 17 insertions, 0 deletions
diff --git a/mu.arc b/mu.arc
index c3527369..79f5586b 100644
--- a/mu.arc
+++ b/mu.arc
@@ -323,6 +323,8 @@
       typeinfo.operand!address))
 
 ($:require "charterm/main.rkt")
+($:require graphics/graphics)
+(= Viewport nil)
 
 ; run instructions from 'routine*' for 'time-slice'
 (def run-for-time-slice (time-slice)
@@ -518,6 +520,21 @@
                 console-off
                   (do1 nil (if ($.current-charterm) ($.close-charterm)))
 
+                ; graphics
+                graphics-on
+                  (do1 nil
+                    ($.open-graphics)
+                    (= Viewport ($.open-viewport "practice" 300 300)))
+                graphics-off
+                  (do1 nil
+                    ($.close-graphics)
+                    (= Viewport nil))
+                mouse-position
+                  (aif ($.ready-mouse-click Viewport)
+                    (let posn ($.mouse-click-posn it)
+                      (list (annotate 'record (list ($.posn-x posn) ($.posn-y posn))) t))
+                    (list nil nil))
+
                 ; user-defined functions
                 next-input
                   (let idx caller-arg-idx.routine*