1 ! Copyright (C) 2009 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: accessors combinators.short-circuit http.client
4 images.loader images.loader.private images.viewer io.pathnames
5 kernel namespaces opengl present sequences strings urls ;
10 : content-type ( response -- type/f )
11 content-type>> dup "image/" head?
12 [ 6 tail ] [ drop f ] if ;
16 : load-http-image ( path -- image )
17 [ http-get swap content-type ]
18 [ present file-extension ] bi or
19 (image-class) load-image*
20 gl-scale-factor get-global [ 2.0 = >>2x? ] when* ;
23 dup { [ "http://" head? ] [ "https://" head? ] } 1||
24 [ load-http-image ] [ load-image ] if >>image ;
27 protocol>> load-http-image >>image ;
29 : http-image. ( path -- )
30 load-http-image image. ;