ui.images: load 1x or 2x graphics.
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.3 KiB |
After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.1 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.3 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.8 KiB |
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 2.5 KiB |
|
@ -1,16 +1,25 @@
|
||||||
! Copyright (C) 2009 Slava Pestov.
|
! Copyright (C) 2009 Slava Pestov.
|
||||||
! See http://factorcode.org/license.txt for BSD license.
|
! See http://factorcode.org/license.txt for BSD license.
|
||||||
USING: accessors assocs cache combinators images.loader kernel
|
USING: accessors assocs cache combinators images.loader kernel
|
||||||
math memoize namespaces opengl.textures sequences system
|
math memoize namespaces opengl opengl.textures sequences
|
||||||
ui.gadgets.worlds vocabs ;
|
splitting system ui.gadgets.worlds vocabs ;
|
||||||
IN: ui.images
|
IN: ui.images
|
||||||
|
|
||||||
TUPLE: image-name path ;
|
TUPLE: image-name path ;
|
||||||
|
|
||||||
C: <image-name> image-name
|
C: <image-name> image-name
|
||||||
|
|
||||||
MEMO: cached-image ( image-name -- image )
|
<PRIVATE
|
||||||
path>> load-image t >>2x? ;
|
|
||||||
|
MEMO: cached-image-path ( path -- image )
|
||||||
|
[ load-image ] [ "@2x" swap subseq? >>2x? ] bi ;
|
||||||
|
|
||||||
|
PRIVATE>
|
||||||
|
|
||||||
|
: cached-image ( image-name -- image )
|
||||||
|
path>> gl-scale-factor get-global 1.0 > [
|
||||||
|
"." split1-last "@2x." glue
|
||||||
|
] when cached-image-path ;
|
||||||
|
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
|
@ -30,7 +39,7 @@ PRIVATE>
|
||||||
rendered-image draw-scaled-texture ;
|
rendered-image draw-scaled-texture ;
|
||||||
|
|
||||||
: image-dim ( image-name -- dim )
|
: image-dim ( image-name -- dim )
|
||||||
cached-image dim>> [ 2 / ] map ;
|
cached-image [ dim>> ] [ 2x?>> [ [ 2 / ] map ] when ] bi ;
|
||||||
|
|
||||||
{
|
{
|
||||||
{ [ os macosx? ] [ "images.loader.cocoa" require ] }
|
{ [ os macosx? ] [ "images.loader.cocoa" require ] }
|
||||||
|
|