2009-02-12 04:58:42 -05:00
|
|
|
! Copyright (C) 2009 Slava Pestov.
|
|
|
|
! See http://factorcode.org/license.txt for BSD license.
|
|
|
|
USING: ;
|
|
|
|
IN: ui.pens.polygon
|
|
|
|
|
|
|
|
! Polygon pen
|
|
|
|
TUPLE: polygon color
|
|
|
|
interior-vertices
|
|
|
|
interior-count
|
|
|
|
boundary-vertices
|
|
|
|
boundary-count ;
|
|
|
|
|
2009-02-15 07:09:04 -05:00
|
|
|
: close-path ( points -- points' )
|
|
|
|
dup first suffix ;
|
|
|
|
|
2009-02-12 04:58:42 -05:00
|
|
|
: <polygon> ( color points -- polygon )
|
|
|
|
dup close-path [ [ concat >float-array ] [ length ] bi ] bi@
|
|
|
|
polygon boa ;
|
|
|
|
|
|
|
|
M: polygon draw-boundary
|
|
|
|
nip
|
|
|
|
[ color>> gl-color ]
|
|
|
|
[ boundary-vertices>> gl-vertex-pointer ]
|
|
|
|
[ [ GL_LINE_STRIP 0 ] dip boundary-count>> glDrawArrays ]
|
|
|
|
tri ;
|
|
|
|
|
|
|
|
M: polygon draw-interior
|
|
|
|
nip
|
|
|
|
[ color>> gl-color ]
|
|
|
|
[ interior-vertices>> gl-vertex-pointer ]
|
|
|
|
[ [ GL_POLYGON 0 ] dip interior-count>> glDrawArrays ]
|
|
|
|
tri ;
|