2017-04-06 23:20:08 +02:00
|
|
|
/*
|
|
|
|
========================================================================
|
2022-04-09 04:45:47 +02:00
|
|
|
The 2022 /r/place Atlas
|
2017-04-06 23:20:08 +02:00
|
|
|
|
2022-04-09 04:45:47 +02:00
|
|
|
An Atlas of Reddit's 2022 /r/place, with information to each
|
2017-04-06 23:20:08 +02:00
|
|
|
artwork of the canvas provided by the community.
|
|
|
|
|
2022-04-09 04:45:47 +02:00
|
|
|
Copyright (c) 2017 Roland Rytz <roland@draemm.li>
|
|
|
|
Copyright (c) 2022 r/placeAtlas2 contributors
|
|
|
|
|
2017-04-06 23:20:08 +02:00
|
|
|
Licensed under the GNU Affero General Public License Version 3
|
2022-04-09 03:23:55 +02:00
|
|
|
https://place-atlas.stefanocoding.me/license.txt
|
2017-04-06 23:20:08 +02:00
|
|
|
========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
function initOverlap(){
|
|
|
|
|
2022-04-09 11:27:14 +02:00
|
|
|
window.renderBackground = renderBackground
|
2017-04-06 23:20:08 +02:00
|
|
|
|
|
|
|
var hovered = [];
|
|
|
|
|
2022-04-09 11:27:14 +02:00
|
|
|
buildObjectsList(null, null);
|
|
|
|
renderBackground(atlas);
|
2017-04-06 23:20:08 +02:00
|
|
|
render();
|
|
|
|
|
|
|
|
applyView();
|
|
|
|
render();
|
|
|
|
updateLines();
|
|
|
|
|
2022-04-11 04:54:00 +02:00
|
|
|
if(window.location.hash){
|
|
|
|
highlightEntryFromUrl();
|
2017-04-06 23:20:08 +02:00
|
|
|
}
|
|
|
|
|
2022-04-09 11:27:14 +02:00
|
|
|
function renderBackground(atlas) {
|
2017-04-06 23:20:08 +02:00
|
|
|
|
|
|
|
backgroundContext.clearRect(0, 0, canvas.width, canvas.height);
|
|
|
|
|
|
|
|
backgroundContext.fillStyle = "rgba(255, 255, 255, 1)";
|
|
|
|
backgroundContext.fillRect(0, 0, canvas.width, canvas.height);
|
|
|
|
|
|
|
|
for(var i = 0; i < atlas.length; i++){
|
|
|
|
|
|
|
|
var path = atlas[i].path;
|
|
|
|
|
|
|
|
backgroundContext.beginPath();
|
|
|
|
|
|
|
|
if(path[0]){
|
|
|
|
backgroundContext.moveTo(path[0][0], path[0][1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(var p = 1; p < path.length; p++){
|
|
|
|
backgroundContext.lineTo(path[p][0], path[p][1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
backgroundContext.closePath();
|
|
|
|
|
|
|
|
backgroundContext.fillStyle = "rgba(0, 0, 255, 0.2)";
|
|
|
|
backgroundContext.fill();
|
|
|
|
}
|
2017-04-12 17:17:00 +02:00
|
|
|
|
|
|
|
var pixels = backgroundContext.getImageData(0, 0, backgroundCanvas.width, backgroundCanvas.height).data;
|
|
|
|
var blank = 0;
|
|
|
|
|
|
|
|
for(var i = 0; i < pixels.length; i+=4){
|
|
|
|
if(pixels[i] == 255){
|
|
|
|
blank++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(blank+" blank pixels, which are "+Math.round(blank/100)/100+"% of the canvas ("+(100-Math.round(blank/100)/100)+"% mapped)");
|
2017-04-06 23:20:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|