1 ! Copyright (C) 2006, 2007 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel accessors math namespaces opengl opengl.gl sequences
4 math.vectors ui.gadgets ui.gadgets.grids ui.render math.geometry.rect ;
5 IN: ui.gadgets.grid-lines
7 TUPLE: grid-lines color ;
9 C: <grid-lines> grid-lines
13 : half-gap grid get gap>> [ 2/ ] map ; inline
15 : grid-line-from/to ( orientation point -- from to )
17 [ half-gap spin set-axis ] 2keep
18 grid-dim get spin set-axis ;
20 : draw-grid-lines ( gaps orientation -- )
21 grid get rot grid-positions grid get rect-dim suffix [
22 grid-line-from/to gl-line
25 M: grid-lines draw-boundary
27 -0.5 -0.5 0.0 glTranslated
30 dup rect-dim half-gap v- grid-dim set
32 { 0 1 } draw-grid-lines
33 { 1 0 } draw-grid-lines