factor/core/ui/gadgets/grid-lines.factor

33 lines
888 B
Factor
Raw Normal View History

! Copyright (C) 2006, 2007 Slava Pestov.
2006-06-26 01:53:05 -04:00
! See http://factorcode.org/license.txt for BSD license.
2006-10-22 18:46:02 -04:00
IN: gadgets
USING: kernel math namespaces opengl sequences ;
2006-06-26 01:53:05 -04:00
TUPLE: grid-lines color ;
SYMBOL: grid-dim
: half-gap grid get grid-gap [ 2/ ] map ; inline
2006-06-26 01:53:05 -04:00
: grid-line-from/to ( orientation point -- from to )
half-gap v-
[ half-gap swap rot set-axis ] 2keep
grid-dim get swap rot set-axis ;
: draw-grid-lines ( gaps orientation -- )
grid get rot grid-positions grid get rect-dim add [
grid-line-from/to gl-line
] each-with ;
2006-06-26 01:53:05 -04:00
M: grid-lines draw-boundary
2006-10-11 16:39:53 -04:00
origin get [
-0.5 -0.5 0.0 glTranslated
2006-06-26 01:53:05 -04:00
grid-lines-color gl-color [
dup grid set
dup rect-dim half-gap v- grid-dim set
compute-grid
2006-06-26 01:53:05 -04:00
{ 0 1 } draw-grid-lines
{ 1 0 } draw-grid-lines
] with-scope
2006-10-11 16:39:53 -04:00
] with-translation ;