]> gitweb.factorcode.org Git - factor.git/blob - extra/graphics/viewer/viewer.factor
Initial import
[factor.git] / extra / graphics / viewer / viewer.factor
1 ! Copyright (C) 2007 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3
4 USING: arrays kernel math math.functions namespaces opengl
5 ui.gadgets ui.render ;
6 IN: graphics.viewer
7
8 TUPLE: graphics-gadget image ;
9
10 GENERIC: draw-image ( image -- )
11 GENERIC: width ( image -- w )
12 GENERIC: height ( image -- h )
13
14 M: graphics-gadget pref-dim*
15     graphics-gadget-image
16     [ width ] keep height abs 2array ;
17
18 M: graphics-gadget draw-gadget* ( gadget -- )
19     origin get [
20         graphics-gadget-image draw-image
21     ] with-translation ;
22
23 : <graphics-gadget> ( bitmap -- gadget )
24     \ graphics-gadget construct-gadget
25     [ set-graphics-gadget-image ] keep ;
26