]> gitweb.factorcode.org Git - factor.git/blob - basis/ui/pens/solid/solid.factor
core, basis, extra: Remove DOS line endings from files.
[factor.git] / basis / ui / pens / solid / solid.factor
1 ! Copyright (C) 2009 Slava Pestov.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel accessors opengl math colors ui.pens ui.pens.caching ;
4 IN: ui.pens.solid
5
6 TUPLE: solid < caching-pen color interior-vertices boundary-vertices ;
7
8 : <solid> ( color -- solid ) solid new swap >>color ;
9
10 M: solid recompute-pen
11     swap dim>>
12     [ [ { 0 0 } ] dip (fill-rect-vertices) >>interior-vertices ]
13     [ [ { 0 0 } ] dip (rect-vertices) >>boundary-vertices ]
14     bi drop ;
15
16 <PRIVATE
17
18 : (solid) ( gadget pen -- )
19     [ compute-pen ] [ color>> gl-color ] bi ;
20
21 PRIVATE>
22
23 M: solid draw-interior
24     [ (solid) ] [ interior-vertices>> gl-vertex-pointer ] bi
25     (gl-fill-rect) ;
26
27 M: solid draw-boundary
28     [ (solid) ] [ boundary-vertices>> gl-vertex-pointer ] bi
29     (gl-rect) ;
30
31 M: solid pen-background
32     nip color>> dup alpha>> 1 number= [ drop transparent ] unless ;