-- <<<- global theWindowPage := object (WebPage) title: "ScriptX Window" base: theSXPrefix contents object (WebMacro) func: (self stream props -> local w := (allinstances Window)[1] if (w == empty) do ( return "Sorry, no window to look at!\r" ) w.clock.rate := 0 w.compositor.enabled := false local bms := new BitmapSurface bbox: w.bbox colormap: w.colormap webLog theWebServer "Drawing window ..." draw w bms bms local imageDir := theTempDir local gifPath := "g" + ((uniqueID()) as String) + ".gif" webLog theWebServer ("exporting to " + gifPath + " ...") if (isFile imageDir gifPath) do ( delete imageDir gifPath ) gifPath := createFile imageDir gifPath @binary local gifStream := getStream imageDir gifPath @writable exportGif bms gifStream plug gifStream webLog theWebServer "Done exporting!" w.clock.rate := 1 w.compositor.enabled := true object (WebImage) url: ("file:///" + (imageDir as String) + gifPath) end ) end end registerService theWebServer \ (new WebService \ name: "Window" \ about: "Grab a snapshot of a ScriptX window!" \ handler: (service request params -> HTML theWindowPage)) -- >>>