1 ! Copyright (C) 2009 Slava Pestov.
2 ! See https://factorcode.org/license.txt for BSD license.
3 USING: accessors colors kernel math opengl ui.pens
7 TUPLE: solid < caching-pen color interior-vertices boundary-vertices ;
9 : <solid> ( color -- solid ) solid new swap >>color ;
11 M: solid recompute-pen
13 [ [ { 0 0 } ] dip (fill-rect-vertices) >>interior-vertices ]
14 [ [ { 0 0 } ] dip (rect-vertices) >>boundary-vertices ]
19 : (solid) ( gadget pen -- )
20 [ compute-pen ] [ color>> gl-color ] bi ;
24 M: solid draw-interior
25 [ (solid) ] [ interior-vertices>> gl-vertex-pointer ] bi
28 M: solid draw-boundary
29 [ (solid) ] [ boundary-vertices>> gl-vertex-pointer ] bi
32 M: solid pen-background
33 nip color>> dup alpha>> 1 number= [ drop transparent ] unless ;