diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2014-12-23 23:38:16 -0800 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2014-12-23 23:52:37 -0800 |
commit | ef55a4146609051c0a4cb1ca46693f620bd12118 (patch) | |
tree | 8d3ff0314afe2f5f227669afbfedd0b7c56fad27 /graphics.mu | |
parent | 4630b4aee88e312f2682eb17b98d0144e48fd7d5 (diff) | |
download | mu-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 'graphics.mu')
-rw-r--r-- | graphics.mu | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/graphics.mu b/graphics.mu new file mode 100644 index 00000000..c4520c8f --- /dev/null +++ b/graphics.mu @@ -0,0 +1,20 @@ +; open a viewport, print coordinates of mouse clicks +; currently need to ctrl-c to exit after closing the viewport +(function main [ + (graphics-on) + { begin + (pos:integer-integer-pair click?:boolean <- mouse-position) + { begin + (break-if click?:boolean) + (loop 2:blocks) + } + (x:integer <- get pos:integer-integer-pair 0:offset) + (y:integer <- get pos:integer-integer-pair 1:offset) + (print-primitive x:integer) + (print-primitive ((", " literal))) + (print-primitive y:integer) + (print-primitive (("\n" literal))) + (loop) + } + (graphics-off) +]) |