First, we need to create URLs of the formUSING: images.http kernel sequences urls urls.encoding ;
http://robohash.org/YOUR_TEXT, as instructed:
Next, we would like to support the different "image sets" that Robohash supports.: robohash-url ( str -- url ) url-encode "http://robohash.org/" prepend >url ;
Using this, we can create image loaders for each set (currently three sets: "set1", "set2", and "set3"):: (robohash) ( str type -- image ) [ robohash-url ] [ "set" set-query-param ] bi* load-http-image ;
You can try it out and see that it works:: robohash1 ( str -- image ) "set1" (robohash) ; : robohash2 ( str -- image ) "set2" (robohash) ; : robohash3 ( str -- image ) "set3" (robohash) ;
Robohash also supports custom backgrounds, changing image sizes, and varying image formats (e.g., JPG or BMP). Adding support for that is an exercise to the reader.
The code for this is on my Github.