{"action":"created","comment":{"url":"https://api.github.com/repos/Mindwerks/worldengine/pulls/comments/43850531","id":43850531,"diff_hunk":"@@ -209,28 +393,95 @@ def draw_riversmap(world, target):\n \n \n def draw_grayscale_heightmap(world, target):\n-    e = world.elevation['data']\n-\n-    mask = numpy.ma.array(e, mask=world.ocean)  # only land\n-    min_elev_land = mask.min()\n-    max_elev_land = mask.max()\n-    elev_delta_land = max_elev_land - min_elev_land\n-\n-    mask = numpy.ma.array(e, mask=numpy.logical_not(world.ocean))  # only ocean\n-    min_elev_sea = mask.min()\n-    max_elev_sea = mask.max()\n-    elev_delta_sea = max_elev_sea - min_elev_sea\n-\n-    c = numpy.empty(e.shape, dtype=numpy.float)\n-    c[numpy.invert(world.ocean)] = (e[numpy.invert(world.ocean)] - min_elev_land) * 127 / elev_delta_land + 128\n-    c[world.ocean] = (e[world.ocean] - min_elev_sea) * 127 / elev_delta_sea\n-    c = numpy.rint(c).astype(dtype=numpy.int32)  # proper rounding\n+    c = get_normalized_elevation_mask(world)\n \n     for y in range(world.height):\n         for x in range(world.width):\n             target.set_pixel(x, y, (c[y, x], c[y, x], c[y, x], 255))\n \n \n+def draw_satellite(world, target):\n+    ''' This draws a \"satellit map\" - a view of the generated planet as it may look from space '''\n+\n+    # Get an elevation mask where heights are normalized between 0 and 255\n+    elevation_mask = get_normalized_elevation_mask(world)\n+\n+    ## The first loop sets each pixel's color based on colors defined in _biome_satellite_colors\n+    #  and additional \"business logic\" defined in get_biome_color_based_on_elevation\n+    for y in xrange(world.height):\n+        for x in xrange(world.width):\n+            # Get the normalized elevation at this pixel\n+            elev = elevation_mask[y, x]\n+            \n+            # Get a rgb noise value, with some logic to modify it based on the elevation of the tile\n+            r, g, b = get_biome_color_based_on_elevation(world, elev, x, y)\n+\n+            # Set pixel to this color. This initial color will be accessed and modified later when \n+            # the map is smoothed and shaded.\n+            target.set_pixel(x, y, (r, g, b, 255))\n+\n+\n+    # Loop through and average a pixel with its neighbors to smooth transitions between biomes\n+    for y in xrange(1, world.height-1):\n+        for x in xrange(1, world.width-1):\n+            ## Only smooth land tiles\n+            if world.is_land((x, y)):\n+                # Lists to hold the separated rgb values of the neighboring pixels\n+                all_r = []\n+                all_g = []\n+                all_b = []\n+\n+                # Loop through this pixel and all neighboring pixels\n+                for j in xrange(y-1, y+2):\n+                    for i in xrange(x-1, x+2):\n+                        # Don't include ocean in the smoothing, if this tile happens to border an ocean\n+                        if world.is_land((i, j)):\n+                            # Grab each rgb value and append to the list\n+                            r, g, b, a = target.pixels[i, j]\n+                            all_r.append(r)\n+                            all_g.append(g)\n+                            all_b.append(b)\n+\n+                # Making sure there is at least one valid tile to be smoothed before we attempt to average the values\n+                if all_r:\n+                    avg_r = int(sum(all_r) / len(all_r))\n+                    avg_g = int(sum(all_g) / len(all_g))\n+                    avg_b = int(sum(all_b) / len(all_b))\n+\n+                    ## Setting color of the pixel again - this will be once more modified by the shading algorithm\n+                    target.set_pixel(x, y, (avg_r, avg_g, avg_b, 255))\n+\n+    # \"Shade\" the map by sending beams of light west to east, and increasing or decreasing value of pixel based on elevation difference\n+    for y in xrange(SAT_SHADOW_SIZE-1, world.height-SAT_SHADOW_SIZE-1):","path":"worldengine/draw.py","position":291,"original_position":291,"commit_id":"90b1e439926006e3f03958e6784fa322b2e6c6b5","original_commit_id":"90b1e439926006e3f03958e6784fa322b2e6c6b5","user":{"login":"ftomassetti","id":439078,"avatar_url":"https://avatars.githubusercontent.com/u/439078?v=3","gravatar_id":"","url":"https://api.github.com/users/ftomassetti","html_url":"https://github.com/ftomassetti","followers_url":"https://api.github.com/users/ftomassetti/followers","following_url":"https://api.github.com/users/ftomassetti/following{/other_user}","gists_url":"https://api.github.com/users/ftomassetti/gists{/gist_id}","starred_url":"https://api.github.com/users/ftomassetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ftomassetti/subscriptions","organizations_url":"https://api.github.com/users/ftomassetti/orgs","repos_url":"https://api.github.com/users/ftomassetti/repos","events_url":"https://api.github.com/users/ftomassetti/events{/privacy}","received_events_url":"https://api.github.com/users/ftomassetti/received_events","type":"User","site_admin":false},"body":"We tend to use range instead of xrange because xrange is not available on Python 3","created_at":"2015-11-04T07:42:10Z","updated_at":"2015-11-04T07:42:10Z","html_url":"https://github.com/Mindwerks/worldengine/pull/181#discussion_r43850531","pull_request_url":"https://api.github.com/repos/Mindwerks/worldengine/pulls/181","_links":{"self":{"href":"https://api.github.com/repos/Mindwerks/worldengine/pulls/comments/43850531"},"html":{"href":"https://github.com/Mindwerks/worldengine/pull/181#discussion_r43850531"},"pull_request":{"href":"https://api.github.com/repos/Mindwerks/worldengine/pulls/181"}}},"pull_request":{"url":"https://api.github.com/repos/Mindwerks/worldengine/pulls/181","id":49650315,"html_url":"https://github.com/Mindwerks/worldengine/pull/181","diff_url":"https://github.com/Mindwerks/worldengine/pull/181.diff","patch_url":"https://github.com/Mindwerks/worldengine/pull/181.patch","issue_url":"https://api.github.com/repos/Mindwerks/worldengine/issues/181","number":181,"state":"open","locked":false,"title":"Satellite map (non-messed-up version)","user":{"login":"pangal","id":8039081,"avatar_url":"https://avatars.githubusercontent.com/u/8039081?v=3","gravatar_id":"","url":"https://api.github.com/users/pangal","html_url":"https://github.com/pangal","followers_url":"https://api.github.com/users/pangal/followers","following_url":"https://api.github.com/users/pangal/following{/other_user}","gists_url":"https://api.github.com/users/pangal/gists{/gist_id}","starred_url":"https://api.github.com/users/pangal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pangal/subscriptions","organizations_url":"https://api.github.com/users/pangal/orgs","repos_url":"https://api.github.com/users/pangal/repos","events_url":"https://api.github.com/users/pangal/events{/privacy}","received_events_url":"https://api.github.com/users/pangal/received_events","type":"User","site_admin":false},"body":"Here is a pull request with the proper issues sorted out.\r\n\r\nThis branch adds functionality for creating a \"Satellite map\" of the generated world. This is currently an option, default false, toggled on with the --sat command when running.\r\n\r\nAdditional work may need to be done in selecting more appropriate biome colors and tuning the algorithm to display elevation / shading, to get a more realistic result.\r\n\r\nSome sample outputs are attached here:\r\n![8e13c412-819c-11e5-938f-a05a3379e9de](https://cloud.githubusercontent.com/assets/8039081/10930437/f5a3a710-8272-11e5-8b64-a48658f48a42.png)\r\n![8e177a62-819c-11e5-8452-9a03a9fa8734](https://cloud.githubusercontent.com/assets/8039081/10930438/f5b50ad2-8272-11e5-8e90-5153600301a3.png)\r\n\r\n\r\n","created_at":"2015-11-04T05:36:50Z","updated_at":"2015-11-04T07:42:10Z","closed_at":null,"merged_at":null,"merge_commit_sha":"671ba4efaea192f254a7b2ad00694b065f1f2abb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Mindwerks/worldengine/pulls/181/commits","review_comments_url":"https://api.github.com/repos/Mindwerks/worldengine/pulls/181/comments","review_comment_url":"https://api.github.com/repos/Mindwerks/worldengine/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Mindwerks/worldengine/issues/181/comments","statuses_url":"https://api.github.com/repos/Mindwerks/worldengine/statuses/90b1e439926006e3f03958e6784fa322b2e6c6b5","head":{"label":"pangal:sat_v2","ref":"sat_v2","sha":"90b1e439926006e3f03958e6784fa322b2e6c6b5","user":{"login":"pangal","id":8039081,"avatar_url":"https://avatars.githubusercontent.com/u/8039081?v=3","gravatar_id":"","url":"https://api.github.com/users/pangal","html_url":"https://github.com/pangal","followers_url":"https://api.github.com/users/pangal/followers","following_url":"https://api.github.com/users/pangal/following{/other_user}","gists_url":"https://api.github.com/users/pangal/gists{/gist_id}","starred_url":"https://api.github.com/users/pangal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pangal/subscriptions","organizations_url":"https://api.github.com/users/pangal/orgs","repos_url":"https://api.github.com/users/pangal/repos","events_url":"https://api.github.com/users/pangal/events{/privacy}","received_events_url":"https://api.github.com/users/pangal/received_events","type":"User","site_admin":false},"repo":{"id":45439655,"name":"worldengine","full_name":"pangal/worldengine","owner":{"login":"pangal","id":8039081,"avatar_url":"https://avatars.githubusercontent.com/u/8039081?v=3","gravatar_id":"","url":"https://api.github.com/users/pangal","html_url":"https://github.com/pangal","followers_url":"https://api.github.com/users/pangal/followers","following_url":"https://api.github.com/users/pangal/following{/other_user}","gists_url":"https://api.github.com/users/pangal/gists{/gist_id}","starred_url":"https://api.github.com/users/pangal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pangal/subscriptions","organizations_url":"https://api.github.com/users/pangal/orgs","repos_url":"https://api.github.com/users/pangal/repos","events_url":"https://api.github.com/users/pangal/events{/privacy}","received_events_url":"https://api.github.com/users/pangal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pangal/worldengine","description":"World generator using simulation of plates, rain shadow, erosion, etc.","fork":true,"url":"https://api.github.com/repos/pangal/worldengine","forks_url":"https://api.github.com/repos/pangal/worldengine/forks","keys_url":"https://api.github.com/repos/pangal/worldengine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pangal/worldengine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pangal/worldengine/teams","hooks_url":"https://api.github.com/repos/pangal/worldengine/hooks","issue_events_url":"https://api.github.com/repos/pangal/worldengine/issues/events{/number}","events_url":"https://api.github.com/repos/pangal/worldengine/events","assignees_url":"https://api.github.com/repos/pangal/worldengine/assignees{/user}","branches_url":"https://api.github.com/repos/pangal/worldengine/branches{/branch}","tags_url":"https://api.github.com/repos/pangal/worldengine/tags","blobs_url":"https://api.github.com/repos/pangal/worldengine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pangal/worldengine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pangal/worldengine/git/refs{/sha}","trees_url":"https://api.github.com/repos/pangal/worldengine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pangal/worldengine/statuses/{sha}","languages_url":"https://api.github.com/repos/pangal/worldengine/languages","stargazers_url":"https://api.github.com/repos/pangal/worldengine/stargazers","contributors_url":"https://api.github.com/repos/pangal/worldengine/contributors","subscribers_url":"https://api.github.com/repos/pangal/worldengine/subscribers","subscription_url":"https://api.github.com/repos/pangal/worldengine/subscription","commits_url":"https://api.github.com/repos/pangal/worldengine/commits{/sha}","git_commits_url":"https://api.github.com/repos/pangal/worldengine/git/commits{/sha}","comments_url":"https://api.github.com/repos/pangal/worldengine/comments{/number}","issue_comment_url":"https://api.github.com/repos/pangal/worldengine/issues/comments{/number}","contents_url":"https://api.github.com/repos/pangal/worldengine/contents/{+path}","compare_url":"https://api.github.com/repos/pangal/worldengine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pangal/worldengine/merges","archive_url":"https://api.github.com/repos/pangal/worldengine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pangal/worldengine/downloads","issues_url":"https://api.github.com/repos/pangal/worldengine/issues{/number}","pulls_url":"https://api.github.com/repos/pangal/worldengine/pulls{/number}","milestones_url":"https://api.github.com/repos/pangal/worldengine/milestones{/number}","notifications_url":"https://api.github.com/repos/pangal/worldengine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pangal/worldengine/labels{/name}","releases_url":"https://api.github.com/repos/pangal/worldengine/releases{/id}","created_at":"2015-11-03T03:36:31Z","updated_at":"2015-11-03T03:36:32Z","pushed_at":"2015-11-04T05:33:25Z","git_url":"git://github.com/pangal/worldengine.git","ssh_url":"git@github.com:pangal/worldengine.git","clone_url":"https://github.com/pangal/worldengine.git","svn_url":"https://github.com/pangal/worldengine","homepage":"","size":86651,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"Mindwerks:master","ref":"master","sha":"e562f96484d29d8c00008c2eb18569b1abd32fe4","user":{"login":"Mindwerks","id":6725881,"avatar_url":"https://avatars.githubusercontent.com/u/6725881?v=3","gravatar_id":"","url":"https://api.github.com/users/Mindwerks","html_url":"https://github.com/Mindwerks","followers_url":"https://api.github.com/users/Mindwerks/followers","following_url":"https://api.github.com/users/Mindwerks/following{/other_user}","gists_url":"https://api.github.com/users/Mindwerks/gists{/gist_id}","starred_url":"https://api.github.com/users/Mindwerks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mindwerks/subscriptions","organizations_url":"https://api.github.com/users/Mindwerks/orgs","repos_url":"https://api.github.com/users/Mindwerks/repos","events_url":"https://api.github.com/users/Mindwerks/events{/privacy}","received_events_url":"https://api.github.com/users/Mindwerks/received_events","type":"Organization","site_admin":false},"repo":{"id":14665885,"name":"worldengine","full_name":"Mindwerks/worldengine","owner":{"login":"Mindwerks","id":6725881,"avatar_url":"https://avatars.githubusercontent.com/u/6725881?v=3","gravatar_id":"","url":"https://api.github.com/users/Mindwerks","html_url":"https://github.com/Mindwerks","followers_url":"https://api.github.com/users/Mindwerks/followers","following_url":"https://api.github.com/users/Mindwerks/following{/other_user}","gists_url":"https://api.github.com/users/Mindwerks/gists{/gist_id}","starred_url":"https://api.github.com/users/Mindwerks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Mindwerks/subscriptions","organizations_url":"https://api.github.com/users/Mindwerks/orgs","repos_url":"https://api.github.com/users/Mindwerks/repos","events_url":"https://api.github.com/users/Mindwerks/events{/privacy}","received_events_url":"https://api.github.com/users/Mindwerks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Mindwerks/worldengine","description":"World generator using simulation of plates, rain shadow, erosion, etc.","fork":false,"url":"https://api.github.com/repos/Mindwerks/worldengine","forks_url":"https://api.github.com/repos/Mindwerks/worldengine/forks","keys_url":"https://api.github.com/repos/Mindwerks/worldengine/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Mindwerks/worldengine/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Mindwerks/worldengine/teams","hooks_url":"https://api.github.com/repos/Mindwerks/worldengine/hooks","issue_events_url":"https://api.github.com/repos/Mindwerks/worldengine/issues/events{/number}","events_url":"https://api.github.com/repos/Mindwerks/worldengine/events","assignees_url":"https://api.github.com/repos/Mindwerks/worldengine/assignees{/user}","branches_url":"https://api.github.com/repos/Mindwerks/worldengine/branches{/branch}","tags_url":"https://api.github.com/repos/Mindwerks/worldengine/tags","blobs_url":"https://api.github.com/repos/Mindwerks/worldengine/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Mindwerks/worldengine/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Mindwerks/worldengine/git/refs{/sha}","trees_url":"https://api.github.com/repos/Mindwerks/worldengine/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Mindwerks/worldengine/statuses/{sha}","languages_url":"https://api.github.com/repos/Mindwerks/worldengine/languages","stargazers_url":"https://api.github.com/repos/Mindwerks/worldengine/stargazers","contributors_url":"https://api.github.com/repos/Mindwerks/worldengine/contributors","subscribers_url":"https://api.github.com/repos/Mindwerks/worldengine/subscribers","subscription_url":"https://api.github.com/repos/Mindwerks/worldengine/subscription","commits_url":"https://api.github.com/repos/Mindwerks/worldengine/commits{/sha}","git_commits_url":"https://api.github.com/repos/Mindwerks/worldengine/git/commits{/sha}","comments_url":"https://api.github.com/repos/Mindwerks/worldengine/comments{/number}","issue_comment_url":"https://api.github.com/repos/Mindwerks/worldengine/issues/comments{/number}","contents_url":"https://api.github.com/repos/Mindwerks/worldengine/contents/{+path}","compare_url":"https://api.github.com/repos/Mindwerks/worldengine/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Mindwerks/worldengine/merges","archive_url":"https://api.github.com/repos/Mindwerks/worldengine/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Mindwerks/worldengine/downloads","issues_url":"https://api.github.com/repos/Mindwerks/worldengine/issues{/number}","pulls_url":"https://api.github.com/repos/Mindwerks/worldengine/pulls{/number}","milestones_url":"https://api.github.com/repos/Mindwerks/worldengine/milestones{/number}","notifications_url":"https://api.github.com/repos/Mindwerks/worldengine/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Mindwerks/worldengine/labels{/name}","releases_url":"https://api.github.com/repos/Mindwerks/worldengine/releases{/id}","created_at":"2013-11-24T17:49:35Z","updated_at":"2015-11-04T06:25:02Z","pushed_at":"2015-11-04T05:36:50Z","git_url":"git://github.com/Mindwerks/worldengine.git","ssh_url":"git@github.com:Mindwerks/worldengine.git","clone_url":"https://github.com/Mindwerks/worldengine.git","svn_url":"https://github.com/Mindwerks/worldengine","homepage":"","size":86651,"stargazers_count":294,"watchers_count":294,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":22,"mirror_url":null,"open_issues_count":38,"forks":22,"open_issues":38,"watchers":294,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Mindwerks/worldengine/pulls/181"},"html":{"href":"https://github.com/Mindwerks/worldengine/pull/181"},"issue":{"href":"https://api.github.com/repos/Mindwerks/worldengine/issues/181"},"comments":{"href":"https://api.github.com/repos/Mindwerks/worldengine/issues/181/comments"},"review_comments":{"href":"https://api.github.com/repos/Mindwerks/worldengine/pulls/181/comments"},"review_comment":{"href":"https://api.github.com/repos/Mindwerks/worldengine/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Mindwerks/worldengine/pulls/181/commits"},"statuses":{"href":"https://api.github.com/repos/Mindwerks/worldengine/statuses/90b1e439926006e3f03958e6784fa322b2e6c6b5"}}}}