1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors alien.c-types colors help.markup help.syntax
4 kernel opengl opengl.gl sequences math.vectors ui.gadgets
5 ui.pens specialized-arrays ;
6 SPECIALIZED-ARRAY: float
16 : close-path ( points -- points' )
19 : <polygon> ( color points -- polygon )
20 dup close-path [ [ concat >float-array ] [ length ] bi ] bi@
23 M: polygon draw-boundary
26 [ boundary-vertices>> gl-vertex-pointer ]
27 [ [ GL_LINE_STRIP 0 ] dip boundary-count>> glDrawArrays ]
30 M: polygon draw-interior
33 [ interior-vertices>> gl-vertex-pointer ]
34 [ [ GL_POLYGON 0 ] dip interior-count>> glDrawArrays ]
37 : <polygon-gadget> ( color points -- gadget )
38 [ <polygon> ] [ { 0 0 } [ vmax ] reduce ] bi
39 [ <gadget> ] 2dip [ >>interior ] [ >>dim ] bi* ;