2017-04-06 12:08:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
|
|
|
|
This file contains compressed versions of the following files:
|
|
|
|
|
|
|
|
https://draemm.li/various/place-atlas/_js/atlas.js
|
|
|
|
https://draemm.li/various/place-atlas/_js/main.js
|
|
|
|
https://draemm.li/various/place-atlas/_js/view.js
|
|
|
|
https://draemm.li/various/place-atlas/_js/draw.js
|
|
|
|
|
|
|
|
These files are released under the AGPL v3 license (see below)
|
|
|
|
|
|
|
|
This file also contains the function pointIsInPolygon,
|
|
|
|
which was released under the MIT license by James Halliday.
|
|
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
The MIT License (MIT)
|
|
|
|
|
|
|
|
pointIsInPolygon function
|
|
|
|
|
|
|
|
Copyright (c) 2016 James Halliday
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in all
|
|
|
|
copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function pointIsInPolygon (point, polygon) {
|
|
|
|
// ray-casting algorithm based on
|
|
|
|
// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
|
|
|
|
|
|
|
|
var x = point[0], y = point[1];
|
|
|
|
|
|
|
|
var inside = false;
|
|
|
|
for (var i = 0, j = polygon.length - 1; i < polygon.length; j = i++) {
|
|
|
|
var xi = polygon[i][0], yi = polygon[i][1];
|
|
|
|
var xj = polygon[j][0], yj = polygon[j][1];
|
|
|
|
|
|
|
|
var intersect = ((yi > y) != (yj > y))
|
|
|
|
&& (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
|
|
|
|
if (intersect) inside = !inside;
|
|
|
|
}
|
|
|
|
|
|
|
|
return inside;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
========================================================================
|
|
|
|
The /r/place Atlas
|
|
|
|
|
|
|
|
An Atlas of Reddit's /r/place, with information to each
|
|
|
|
artwork of the canvas provided by the community.
|
|
|
|
|
|
|
|
Copyright (C) 2017 Roland Rytz <roland@draemm.li>
|
|
|
|
Licensed under the GNU Affero General Public License Version 3
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
For more information, see:
|
|
|
|
https://draemm.li/various/place-atlas/license.txt
|
|
|
|
|
|
|
|
========================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2017-04-06 12:26:49 +02:00
|
|
|
|
2017-04-09 22:59:26 +02:00
|
|
|
|
2017-04-10 12:25:04 +02:00
|
|
|
function updateLines(){linesCanvas.width=linesCanvas.clientWidth,linesCanvas.height=linesCanvas.clientHeight,linesContext.lineCap="round",linesContext.lineWidth=Math.max(Math.min(1.5*zoom,24),6),linesContext.strokeStyle="#000000";for(var a=0;a<hovered.length;a++){var b=hovered[a].element;0!=b.getBoundingClientRect().left&&(linesContext.beginPath(),linesContext.moveTo(b.getBoundingClientRect().left+document.documentElement.scrollLeft+b.clientWidth/2,b.getBoundingClientRect().top+document.documentElement.scrollTop+20),linesContext.lineTo(~~(hovered[a].center[0]*zoom)+innerContainer.offsetLeft,~~(hovered[a].center[1]*zoom)+innerContainer.offsetTop),linesContext.stroke())}linesContext.lineWidth=Math.max(Math.min(zoom,16),4),linesContext.strokeStyle="#FFFFFF";for(var a=0;a<hovered.length;a++){var b=hovered[a].element;0!=b.getBoundingClientRect().left&&(linesContext.beginPath(),linesContext.moveTo(b.getBoundingClientRect().left+document.documentElement.scrollLeft+b.clientWidth/2,b.getBoundingClientRect().top+document.documentElement.scrollTop+20),linesContext.lineTo(~~(hovered[a].center[0]*zoom)+innerContainer.offsetLeft,~~(hovered[a].center[1]*zoom)+innerContainer.offsetTop),linesContext.stroke())}}function initView(){function t(){for(var a=j.length-1;a>0;a--){var b=Math.floor(Math.random()*(a+1)),c=j[a];j[a]=j[b],j[b]=c}}function u(a){var b=document.createElement("div");b.className="object";var c='<h2><a href="?id='+a.id+'">'+a.name+"</a></h2>";if(a.description&&(c+="<p>"+a.description+"</p>"),a.website&&(c+='<a target="_blank" href='+a.website+">Website</a>"),a.subreddit){var d=a.subreddit.split(",");for(var e in d){var f=d[e].trim();"r/"==f.substring(0,2)?f="/"+f:"/"!=f.substring(0,1)&&(f="/r/"+f),c+='<a target="_blank" href=https://reddit.com'+f+">"+f+"</a>"}}return b.innerHTML+=c,b}function v(){var a=document.getElementById("objectsList"),b=0,d=window.location.search;d&&(b=d.split("id=")[1])&&(b=parseInt(b.split("&")[0]));var e=atlas.filter(function(a){return a.id===b});if(1===e.length){e=e[0];var f=u(e);a.innerHTML="",a.appendChild(f),zoom=4,applyView(),zoomOrigin=[innerContainer.clientWidth/2-e.center[0]*zoom,innerContainer.clientHeight/2-e.center[1]*zoom],scaleZoomOrigin=[500-e.center[0],500-e.center[1]],applyView(),hovered=[e],z(),hovered[0].element=f,c.className="",updateLines(),r=!0}}function w(a,d){if(!dragging&&(!r||d)){var e=[(a.clientX-(container.clientWidth/2-innerContainer.clientWidth/2+zoomOrigin[0]+container.offsetLeft))/zoom,(a.clientY-(container.clientHeight/2-innerContainer.clientHeight/2+zoomOrigin[1]+container.offsetTop))/zoom];if(e[0]<=1100&&e[0]>=-100&&e[0]<=1100&&e[0]>=-100){for(var f=[],g=0;g<atlas.length;g++)pointIsInPolygon(e,atlas[g].path)&&f.push(atlas[g]);var h=!1;if(hovered.length==f.length){for(var g=0;g<hovered.length;g++)if(hovered[g].id!=f[g].id){h=!0;break}}else h=!0;if(h){hovered=f,b.innerHTML="";for(var g in hovered){var i=u(hovered[g]);b.appendChild(i),hovered[g].element=i}hovered.length>0?c.className="":c.className="hidden",z()}}}}function x(a){e.clearRect(0,0,canvas.width,canvas.height),e.fillStyle="rgba(0, 0, 0, 0.6)",e.fillRect(0,0,canvas.width,canvas.height);for(var b=0;b<a.length;b++){var c=a[b].path;e.beginPath(),c[0]&&e.moveTo(c[0][0],c[0][1]);for(var d=1;d<c.length;d++)e.lineTo(c[d][0],c[d][1]);e.closePath(),e.strokeStyle="rgba(255, 255, 255, 0.8)",e.stroke()}}function y(c,d){g.contains(m)&&g.removeChild(m),j||(j=atlas.concat(),document.getElementById("atlasSize").innerHTML="The Atlas contains "+j.length+" entries."),c?(j=atlas.filter(function(a){return-1!==a.name.toLowerCase().indexOf(c)||-1!==a.description.toLowerCase().indexOf(c)}),document.getElementById("atlasSize").innerHTML="Found "+j.length+" entries."):document.getElementById("atlasSize").innerHTML="The Atlas contains "+j.length+" entries.",null===d&&(d=n),x(j),z(),document.getElementById("sort").value=d;var e;switch(d){case"shuffle":e=null,0==l&&t();break;case"alphaAsc":e=function(a,b){return a.name.toLowerCase().localeCompare(b.name.toLowerCase())};break;case"alphaDesc":e=function(a,b){return b.name.toLowerCase().
|
2017-04-09 22:22:06 +02:00
|
|
|
|
2017-04-06 12:08:53 +02:00
|
|
|
|
|
|
|
|