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-06 19:57:16 +02:00
|
|
|
function initView(){function q(a){var b=document.createElement("div");b.className="object";var c='<h2><a href="?id='+a.id+'">'+a.name+"</a></h2>";return a.description&&(c+="<p>"+a.description+"</p>"),a.website&&(c+='<a target="_blank" href='+a.website+">Website</a>"),a.subreddit&&("r/"==a.subreddit.substring(0,2)?a.subreddit="/"+a.subreddit:"/"!=a.subreddit.substring(0,1)&&(a.subreddit="/r/"+a.subreddit),c+='<a target="_blank" href=https://reddit.com'+a.subreddit+">"+a.subreddit+"</a>"),b.innerHTML+=c,b}function r(){var a=document.getElementById("objectsList"),b=0,c=window.location.search;c&&(b=c.split("id=")[1])&&(b=parseInt(b.split("&")[0]));var d=atlas.filter(function(a){return a.id===b});if(1===d.length){d=d[0];var e=q(d);a.innerHTML="",a.appendChild(e),zoom=4,applyView(),zoomOrigin=[innerContainer.clientWidth/2-d.center[0]*zoom,innerContainer.clientHeight/2-d.center[1]*zoom],applyView(),m=[d],v(),m[0].element=e,x(),o=!0}}function s(b){if(!dragging&&!o){var c=[(b.clientX-(container.clientWidth/2-innerContainer.clientWidth/2+zoomOrigin[0]+container.offsetLeft))/zoom,(b.clientY-(container.clientHeight/2-innerContainer.clientHeight/2+zoomOrigin[1]+container.offsetTop))/zoom];if(c[0]<=1100&&c[0]>=-100&&c[0]<=1100&&c[0]>=-100){for(var d=[],e=0;e<atlas.length;e++)pointIsInPolygon(c,atlas[e].path)&&d.push(atlas[e]);var f=!1;if(m.length==d.length){for(var e=0;e<m.length;e++)if(m[e].id!=d[e].id){f=!0;break}}else f=!0;if(f){m=d,a.innerHTML="";for(var e in m){var g=q(m[e]);a.appendChild(g),m[e].element=g}v()}}}}function t(){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 a=0;a<atlas.length;a++){var b=atlas[a].path;e.beginPath(),b[0]&&e.moveTo(b[0][0],b[0][1]);for(var c=1;c<b.length;c++)e.lineTo(b[c][0],b[c][1]);e.closePath(),e.strokeStyle="rgba(255, 255, 255, 0.8)",e.stroke()}}function u(b){g.contains(l)&&g.removeChild(l);var c;b?(c=atlas.filter(function(a){return-1!==a.name.toLowerCase().indexOf(b)}),document.getElementById("atlasSize").innerHTML="Found "+c.length+" entries."):(c=atlas.concat(),document.getElementById("atlasSize").innerHTML="The Atlas contains "+c.length+" entries.");var e,d=document.getElementById("sort").value;switch(d){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().localeCompare(a.name.toLowerCase())};break;case"newest":e=function(a,b){return a.id>b.id?-1:a.id<b.id?1:0};break;case"oldest":e=function(a,b){return a.id<b.id?-1:a.id>b.id?1:0}}c.sort(e);for(var f=k;f<k+j&&!(f>=c.length);f++){var h=q(c[f]);h.entry=c[f],h.addEventListener("mouseenter",function(b){o||dragging||(a.innerHTML="",zoomOrigin=[innerContainer.clientWidth/2-this.entry.center[0]*zoom,innerContainer.clientHeight/2-this.entry.center[1]*zoom],applyView(),m=[this.entry],v(),m[0].element=this,x())}),h.addEventListener("mouseleave",function(a){o||dragging||(m=[],x(),v())}),g.appendChild(h)}k+=j,c.length>k&&(l.innerHTML="Show "+Math.min(j,c.length-k)+" more",g.appendChild(l))}function v(){context.globalCompositeOperation="source-over",context.clearRect(0,0,canvas.width,canvas.height),m.length>0?container.style.cursor="pointer":container.style.cursor="default";for(var a=0;a<m.length;a++){var b=m[a].path;context.beginPath(),b[0]&&context.moveTo(b[0][0],b[0][1]);for(var c=1;c<b.length;c++)context.lineTo(b[c][0],b[c][1]);context.closePath(),context.globalCompositeOperation="source-over",context.fillStyle="rgba(0, 0, 0, 1)",context.fill()}context.globalCompositeOperation="source-out",context.drawImage(d,0,0);for(var a=0;a<m.length;a++){var b=m[a].path;context.beginPath(),b[0]&&context.moveTo(b[0][0],b[0][1]);for(var c=1;c<b.length;c++)context.lineTo(b[c][0],b[c][1]);context.closePath(),context.globalCompositeOperation="source-over",context.strokeStyle="rgba(0, 0, 0, 1)",context.stroke()}}function w(a){if(!o&&0==m.length)return 0;(o=!o)||(s(a),v())}function x(){b.width=b.clientWidth,b.height=b.clientHeight,c.lineCap="round",c.lineWidth=Math.max(Math.min(1.5*zoo
|
2017-04-06 13:06:12 +02:00
|
|
|
|
2017-04-06 12:26:49 +02:00
|
|
|
|
|
|
|
|
2017-04-06 12:08:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|