]> gitweb.factorcode.org Git - factor.git/commitdiff
Add ui.gadgets.cartesian
authorEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Wed, 30 Jul 2008 00:37:24 +0000 (19:37 -0500)
committerEduardo Cavazos <dharmatech@finkelstein.stackeffects.info>
Wed, 30 Jul 2008 00:37:24 +0000 (19:37 -0500)
extra/ui/gadgets/cartesian/cartesian.factor [new file with mode: 0644]

diff --git a/extra/ui/gadgets/cartesian/cartesian.factor b/extra/ui/gadgets/cartesian/cartesian.factor
new file mode 100644 (file)
index 0000000..08e04e6
--- /dev/null
@@ -0,0 +1,50 @@
+
+USING: kernel combinators opengl.gl
+       ui.render ui.gadgets ui.gadgets.slate
+       accessors ;
+
+IN: ui.gadgets.cartesian
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+: init-slate ( slate -- slate )
+  init-gadget
+  [ ]         >>action
+  { 200 200 } >>pdim
+  [ ]         >>graft
+  [ ]         >>ungraft ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+TUPLE: cartesian < slate x-min x-max y-min y-max z-min z-max perspective ;
+
+: init-cartesian ( cartesian -- cartesian )
+  init-slate
+  -10 >>x-min
+   10 >>x-max
+  -10 >>y-min
+   10 >>y-max
+   -1 >>z-min
+    1 >>z-max ;
+
+: <cartesian> ( -- cartesian ) cartesian new init-cartesian ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+M: cartesian draw-gadget* ( cartesian -- )
+   GL_PROJECTION glMatrixMode
+   glLoadIdentity
+   dup
+       {
+         [ x-min>> ] [ x-max>> ]
+         [ y-min>> ] [ y-max>> ]
+         [ z-min>> ] [ z-max>> ]
+       }
+     cleave
+     glOrtho
+   GL_MODELVIEW glMatrixMode
+   glLoadIdentity
+   call-next-method ;
+
+! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+