2019-10-18 09:05:06 -04:00
|
|
|
! 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
|
|
|
|
|
|
2019-10-18 09:05:08 -04:00
|
|
|
: 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 -- )
|
2019-10-18 09:05:08 -04:00
|
|
|
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
|
|
|
|
2006-08-15 03:01:24 -04:00
|
|
|
M: grid-lines draw-boundary
|
2006-10-11 16:39:53 -04:00
|
|
|
origin get [
|
2019-10-18 09:05:06 -04:00
|
|
|
-0.5 -0.5 0.0 glTranslated
|
2006-06-26 01:53:05 -04:00
|
|
|
grid-lines-color gl-color [
|
2019-10-18 09:05:08 -04:00
|
|
|
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
|
2019-10-18 09:05:08 -04:00
|
|
|
] with-scope
|
2006-10-11 16:39:53 -04:00
|
|
|
] with-translation ;
|