factor/extra/images/viewer/viewer.factor

38 lines
1.0 KiB
Factor
Raw Normal View History

! Copyright (C) 2007 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: accessors images images.loader io.pathnames kernel namespaces
opengl opengl.gl opengl.textures sequences strings ui ui.gadgets
2009-02-10 19:42:21 -05:00
ui.gadgets.panes ui.render ;
IN: images.viewer
TUPLE: image-gadget < gadget { image image } ;
M: image-gadget pref-dim*
2009-02-10 19:42:21 -05:00
image>> dim>> ;
2009-03-02 20:38:28 -05:00
: draw-image ( image -- )
2009-02-10 19:42:21 -05:00
0 0 glRasterPos2i 1.0 -1.0 glPixelZoom
[ dim>> first2 ] [ component-order>> component-order>format ] [ bitmap>> ] tri
glDrawPixels ;
M: image-gadget draw-gadget* ( gadget -- )
2009-02-27 02:01:51 -05:00
image>> draw-image ;
: <image-gadget> ( image -- gadget )
2009-03-07 02:22:21 -05:00
\ image-gadget new
swap >>image ;
: image-window ( path -- gadget )
[ load-image <image-gadget> dup ] [ open-window ] bi ;
2009-02-10 19:52:28 -05:00
GENERIC: image. ( object -- )
2009-02-10 19:52:28 -05:00
: default-image. ( path -- )
<image-gadget> gadget. ;
M: string image. ( image -- ) load-image default-image. ;
M: pathname image. ( image -- ) load-image default-image. ;
2009-02-10 19:52:28 -05:00
M: image image. ( image -- ) default-image. ;