Print Page | Close Window

World Map Screenshot

Printed From: Illyriad
Category: Miscellaneous
Forum Name: Technology & data
Forum Description: Discussions on data dumps, downloads, and third party applications.
URL: http://forum.illyriad.co.uk/forum_posts.asp?TID=5263
Printed Date: 16 Apr 2022 at 21:12
Software Version: Web Wiz Forums 12.03 - http://www.webwizforums.com


Topic: World Map Screenshot
Posted By: ubluntu
Subject: World Map Screenshot
Date Posted: 28 Sep 2013 at 05:38
Here is some javascript to create a base64 encoded image of the World Map, courtesy of Illyriad Developer blog with a bit of modification for canvas id (2nd page also has code to post to server). Thanks again Illyriad dev team.
http://www.illyriad.co.uk/blog/index.php/2011/09/fix-memory-leaks-animating-html5-canvas/" rel="nofollow - http://www.illyriad.co.uk/blog/index.php/2011/09/fix-memory-leaks-animating-html5-canvas/
http://www.illyriad.co.uk/blog/index.php/2011/09/html5-canvas-creating-screenshots-from-javascript/" rel="nofollow - http://www.illyriad.co.uk/blog/index.php/2011/09/html5-canvas-creating-screenshots-from-javascript/  

You can paste the code below into the console (Chrome:CTRL+Shift+J), press enter, then entering  'TakeScreenshot()' into the console will return the World Map as an image. You can then click the link looking text and it will open the image in a new tab, where you can right-click and "Save Image as".

Enjoy!

var CachedCanvases = new Object(); // Canvas element cache
 
function CreateCanvasCached(name) {
    if (!CachedCanvases[name]) {
        var canvas = document.createElement('canvas');
        CachedCanvases[name] = canvas;
        return canvas;
    }
    return CachedCanvases[name];
};

function TakeScreenshot() {
    StopAnimating(); // Stop the animation loop
 
    var bufferScreenshot = CreateCanvasCached("Screenshot");
    bufferScreenshot.height = 500; bufferScreenshot.width = 500;
    var contextScreenshot = bufferScreenshot.getContext("2d");
    // Draw the layers in order
    contextScreenshot.drawImage(document.getElementById("mapTerrain"), 0, 0, 500, 500);
    contextScreenshot.drawImage(document.getElementById("mapSov"), 0, 0, 500, 500);
    contextScreenshot.drawImage(document.getElementById("mapCities"), 0, 0, 500, 500);
    contextScreenshot.drawImage(document.getElementById("mapAnims"), 0, 0, 500, 500);
 
    // Save to a data URL as a jpeg quality 9
    var imgUrl = bufferScreenshot.toDataURL("image/jpeg", .9);
 
    StartAnimating(); // Restart the animation loop
    return imgUrl;
}



Replies:
Posted By: ubluntu
Date Posted: 10 Oct 2013 at 00:48
It is worth noting that if you just want a single screenshot, the built-in "Share" feature is the way to go(these are public accessible via direct url)
The above code is intended to capture images without creating actions(Rules regarding third party tools  http://forum.illyriad.co.uk/rules-regarding-third-party-tools_topic756.html" rel="nofollow - http://forum.illyriad.co.uk/rules-regarding-third-party-tools_topic756.html ).



Which brings up


Ex BBcode:
  http://www.illyriad.co.uk/World/Map?filename=Illyriad_x-994_y-824_z9_2013-10-09T23-21-29fece0177-5bba-47b4-b99e-0e1193b04fa1.jpg" rel="nofollow">



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.03 - http://www.webwizforums.com
Copyright ©2001-2019 Web Wiz Ltd. - https://www.webwiz.net