<!doctype html>
<html>
<head>
<title>Rectangle Analyze - RJM Programming - March, 2020</title>
<style>
td { opacity: 0,9; }
span { opacity: 0.9; }
div {
transform: rotate(0deg); /* Equal to rotateZ(45deg) */
transform-origin: left top;
}
</style>
<script type="text/javascript">
var EquityTolerance = 0.000000001;
var divs=[];
var pofinterest=',5;6,4;6,2;6,';
var areatemplate='<area shape="rect" coords="20,86,78,160" title="Rectangle 1" href="#" target="_blank" onclick="if (1 == 3) { alert(99); }" />';
var maphtml='<map id="mijigsaw" name="mijigsaw"><area nohref alt="" shape="default" /></map>';
var origmap=maphtml;
var onenp=[], onepoly=[], onell=[], twoll=[];
var atitle='';
var isstart=true;
var poly='poly';
var rest='';
var relevant=true;
var dglowc='';
if (document.URL.indexOf('glow=') != -1) { dglowc=' checked'; }
var maxw=-1, maxh=-1;
var orignumsides=location.search.split('numsides=')[1] ? decodeURIComponent(location.search.split('numsides=')[1].split('&')[0]) : '';
var orignumcols=location.search.split('numcols=')[1] ? decodeURIComponent(location.search.split('numcols=')[1].split('&')[0]) : '';
var rdone=false;
var dbih='';
var dglow='';
var within=false;
var allwithin=false, someadjacent=false;
var popupWindow = null;
var popupIsShown = false;
var pword="";
var wo=null;
var bks=' ';
var argnumcols=location.search.split('numcols=')[1] ? decodeURIComponent(location.search.split('numcols=')[1].split('&')[0]) : '11';
// Thanks to https://htmlcolorcodes.com/color-names/ below
var allcols=['lime','black','blue','purple','navy','teal','fuchsia','olive','maroon','gray','green',
'IndianRed','LightCoral','Salmon','DarkSalmon','LightSalmon','Crimson','Red','FireBrick','DarkRed',
'Pink','LightPink','HotPink','DeepPink','MediumVioletRed','PaleVioletRed','Coral',
'Tomato','OrangeRed','DarkOrange','Orange','Gold','Yellow','LightYellow',
'LemonChiffon','LightGoldenrodYellow','PapayaWhip','Moccasin','PeachPuff',
'PaleGoldenrod','Khaki','DarkKhaki','Lavender','Thistle',
'Plum','Violet','Orchid','Fuchsia','Magenta',
'MediumOrchid','MediumPurple','RebeccaPurple',
'BlueViolet','DarkViolet','DarkOrchid','DarkMagenta',
'Indigo','SlateBlue','DarkSlateBlue','MediumSlateBlue',
'GreenYellow','Chartreuse','LawnGreen','LimeGreen',
'PaleGreen','LightGreen','MediumSpringGreen','SpringGreen',
'MediumSeaGreen','SeaGreen','ForestGreen','DarkGreen',
'YellowGreen','OliveDrab','DarkOliveGreen','MediumAquamarine','DarkSeaGreen',
'LightSeaGreen','DarkCyan','Aqua','Cyan','LightCyan','PaleTurquoise',
'Aquamarine','Turquoise','MediumTurquoise','DarkTurquoise',
'CadetBlue','SteelBlue','LightSteelBlue','PowderBlue',
'LightBlue','SkyBlue','LightSkyBlue','DeepSkyBlue','DodgerBlue','CornflowerBlue',
'MediumSlateBlue','RoyalBlue','MediumBlue','DarkBlue','Navy',
'MidnightBlue','Cornsilk','BlanchedAlmond','Bisque','NavajoWhite','Wheat',
'BurlyWood','Tan','RosyBrown','SandyBrown','Goldenrod',
'DarkGoldenrod','Peru','Chocolate','SaddleBrown','Sienna','Brown','Snow',
'HoneyDew','MintCream','Azure','AliceBlue','GhostWhite','WhiteSmoke','SeaShell',
'Beige','OldLace','FloralWhite','Ivory','AntiqueWhite','Linen',
'LavenderBlush','MistyRose','Gainsboro','LightGray','Silver','DarkGray','DimGray',
'LightSlateGray','SlateGray','DarkSlateGray'];
var cols=['lime','black','blue','purple','navy','teal','fuchsia','olive','maroon','gray','green'];
var xs=[0,0,0,0,0,0,0,0,0,0,0];
var ys=[0,0,0,0,0,0,0,0,0,0,0];
var ls=[0,0,0,0,0,0,0,0,0,0,0];
var ts=[0,0,0,0,0,0,0,0,0,0,0];
var ws=[0,0,0,0,0,0,0,0,0,0,0];
var hs=[0,0,0,0,0,0,0,0,0,0,0];
var pw=[null,null,null,null,null,null,null,null,null,null,null];
var ps=[null,null,null,null,null,null,null,null,null,null,null];
if (eval('' + argnumcols) != 11) {
if (eval('' + argnumcols) >= 40) { bks=' '; }
cols=[];
xs=[];
ys=[];
ls=[];
ts=[];
ws=[];
hs=[];
pw=[];
ps=[];
for (var ijk=0; ijk<argnumcols; ijk++) {
cols.push(allcols[ijk]);
xs.push(0);
ys.push(0);
ls.push(0);
ts.push(0);
ws.push(0);
hs.push(0);
pw.push(null);
ps.push(null);
}
}
var cmds=[];
var lastevent=null;
var rects=[];
var orects=[];
var dpdone=false;
var gone=0, gtwo=1;
var extentx=0, extenty=0;
var score=0;
var goes=0;
var ok=false;
var doneonce=false;
var ci=null;
var prevx=0, prevy=0, lastx=0, lasty=0, myx=0, myy=0;
var prevscore=0, qt=0, sin=0;
var prehtmltablerteport=('<h1 style="text-align:center;width:100%;">Rectangle Analyze <input onblur="relevant=false; setTimeout(obchange,3000);" onchange="relevant=false; setTimeout(obchange,3000);" onclick="relevant=false;" type=number id=selensidenum min=2 max=' + allcols.length + ' value=' + ('~' + orignumcols + '~').replace('~~','11').replace('~','').replace('~','') + '></input></h1><h4 style="text-align:center;width:100%;">RJM Programming - March, 2020</h4><select id=raselect onclick="relevant=false; event.stopPropagation();" onchange="relevant=false; sidelimit(this.value);" style="margin-left:150px;"><option value="">Convex 3/4/5/6/7/8 Sided Polygon Mix</option><option value="3">Convex 3 Sided Polygons Only</option><option value="4">Convex 4 Sided Polygons Only</option><option value="5">Convex 5 Sided Polygons Only</option><option value="6">Convex 6 Sided Polygons Only</option><option value="7">Convex 7 Sided Polygons Only</option><option value="8">Convex 8 Sided Polygons Only</option></select><br><br><span style="margin-left:150px;">Glow <input type="checkbox" onclick="relevant=false;" onchange="relevant=false; glowit(this);" id="cbglow"' + dglowc + '></input></span><br><br><table onclick="relevant=false; woit(this);" title="Show in new window" id=mytable border=1 id=trep style=width:30%;align:right;z-index:67;margin-right:10px;><tr><th>Colour</th><th>Intersects?</th><th>Is within?</th><th>Adjacent to?</th><th>Separate to?<input id=iootw type=text style=position:absolute;top:-200px;left:-200px; value=""></input></th></tr></table><span id=thright></span>').replace(' value="' + orignumsides + '"', ' value="' + orignumsides + '" selected');
for (var li=0; li<ts.length; li++) {
prehtmltablerteport=prehtmltablerteport.replace('</table>', '<tr style=height:30px; id=row' + li + '><td id=col' + li + '></td><td id=intersects' + li + '></td><td id=within' + li + '></td><td id=adjacent' + li + '></td><td id=separate' + li + '></td></tr></table>');
}
var htmltablerteport=prehtmltablerteport;
function glowit(cbo) {
if (cbo.checked) {
document.getElementById('thright').innerHTML+="<style> div { -webkit-animation: glow 1s ease-in-out infinite alternate; -moz-animation: glow 1s ease-in-out infinite alternate; animation: glow 1s ease-in-out infinite alternate; } @-webkit-keyframes glow { from { box-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #e60073, 0 0 9px #e60073, 0 0 11px #e60073, 0 0 13px #e60073, 0 0 15px #e60073; } to { box-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #ff4da6, 0 0 10px #ff4da6, 0 0 12px #ff4da6, 0 0 14px #ff4da6, 0 0 16px #ff4da6; } } </style> ";
htmltablerteport=htmltablerteport.replace('></span>','>' + document.getElementById('thright').innerHTML + '</span>').replace(' id="cbglow"',' id="cbglow" style=display:none;');
prehtmltablerteport=prehtmltablerteport.replace('></span>','>' + document.getElementById('thright').innerHTML + '</span>').replace(' id="cbglow"',' id="cbglow" style=display:none;');
dglow='&glow=y';
} else {
document.getElementById('thright').innerHTML=document.getElementById('thright').innerHTML.split('<style')[0];
dglow='';
}
cbo.style.visibility='hidden';
}
function IsEqual(d1, d2) {
return Math.abs(d1-d2) <= EquityTolerance;
}
function sidelimit(tvis) {
if (tvis == '') {
location.href=(document.URL.split('#')[0].replace('numsides=','nXumsides=').replace('glow=','gXlow=') + dglow).replace('.htm&','.htm?').replace('.html&','.html?');
} else {
location.href=(document.URL.split('#')[0].replace('numsides=','nXumsides=').replace('glow=','gXlow=') + '&numsides=' + tvis + dglow).replace('.htm&','.htm?').replace('.html&','.html?');
}
}
function obchange() {
var synopsis=document.getElementById('selensidenum').value;
location.href=(document.URL.split('#')[0].replace('numcols=','nXumcols=').replace('glow=','gXlow=') + '&numcols=' + synopsis + dglow).replace('.htm&','.htm?').replace('.html&','.html?');
}
//math logic from http://www.wyrmtale.com/blog/2013/115/2d-line-intersection-in-c
function GetIntersectionPoint(l1p1, l1p2, l2p1, l2p2) {
var l1p1_X=eval('' + l1p1.split(',')[0]);
var l1p1_Y=eval('' + l1p1.split(',')[1]);
var l1p2_X=eval('' + l1p2.split(',')[0]);
var l1p2_Y=eval('' + l1p2.split(',')[1]);
var l2p1_X=eval('' + l2p1.split(',')[0]);
var l2p1_Y=eval('' + l2p1.split(',')[1]);
var l2p2_X=eval('' + l2p2.split(',')[0]);
var l2p2_Y=eval('' + l2p2.split(',')[1]);
var A1 = l1p2_Y - l1p1_Y;
var B1 = l1p1_X - l1p2_X;
var C1 = A1 * l1p1_X + B1 * l1p1_Y;
var A2 = l2p2_Y - l2p1_Y;
var B2 = l2p1_X - l2p2_X;
var C2 = A2 * l2p1_X + B2 * l2p1_Y;
//lines are parallel
var det = A1 * B2 - A2 * B1;
if (IsEqual(det, 0)) {
//alert(56);
return null; //parallel lines
} else {
var x = (B2 * C1 - B1 * C2) / det;
var y = (A1 * C2 - A2 * C1) / det;
var online1 = ((Math.min(l1p1_X, l1p2_X) < x || IsEqual(Math.min(l1p1_X, l1p2_X), x))
&& (Math.max(l1p1_X, l1p2_X) > x || IsEqual(Math.max(l1p1_X, l1p2_X), x))
&& (Math.min(l1p1_Y, l1p2_Y) < y || IsEqual(Math.min(l1p1_Y, l1p2_Y), y))
&& (Math.max(l1p1_Y, l1p2_Y) > y || IsEqual(Math.max(l1p1_Y, l1p2_Y), y))
);
var online2 = ((Math.min(l2p1_X, l2p2_X) < x || IsEqual(Math.min(l2p1_X, l2p2_X), x))
&& (Math.max(l2p1_X, l2p2_X) > x || IsEqual(Math.max(l2p1_X, l2p2_X), x))
&& (Math.min(l2p1_Y, l2p2_Y) < y || IsEqual(Math.min(l2p1_Y, l2p2_Y), y))
&& (Math.max(l2p1_Y, l2p2_Y) > y || IsEqual(Math.max(l2p1_Y, l2p2_Y), y))
);
if (online1 && online2) {
console.log('there ' + x + ',' + y);
if (twoll.indexOf(new_Point2D(x, y)) == -1) { twoll.push(new_Point2D(x, y)); onell.push(new_LinkedList2D(new_Point2D(x, y), isstart)); isstart=false; }
return new_Point2D(x, y);
} else {
console.log('not there ' + online1 + online2 + x + ',' + y);
//onell.push(new_LinkedList2D(new_Point2D(x, y), isstart)); isstart=false;
return false; //return new_Point2D(x, y);
}
}
return null; //intersection is at out of at least one segment.
}
// taken from https://wrf.ecse.rpi.edu//Research/Short_Notes/pnpoly.html
function IsPointInsidePoly(test, poly) {
var i;
var j;
var result = false;
//alert(poly.Corners.length);
for (i = 0, j = poly.Corners.length - 1; i < poly.Corners.length; j = i++) {
//alert('i=' + i + ' and j=' + j);
console.log("here at " + i);
console.log(poly.CornersX(i));
if ((poly.Corners[i].toString().split(',')[1] > test.toString().split(',')[1]) != (poly.Corners[j].Y > test.Y) &&
(test.X < (poly.Corners[j].X - poly.Corners[i].X) * (test.Y - poly.Corners[i].Y) / (poly.Corners[j].Y - poly.Corners[i].Y) + poly.Corners[i].X)) {
result = !result;
}
}
return result;
}
function new_IsPointInsidePoly(testx, testy, poly) {
var i;
var j;
var result = false;
//alert(poly.CornersX.length);
for (i = 0, j = poly.CornersX.length - 1; i < poly.CornersX.length; j = i++) {
//alert('i=' + i + ' and j=' + j);
//console.log("Here at " + i);
//console.log(poly.CornersX[i]);
//console.log("here at " + testx + ',' + testy + '?' + (testx < (poly.CornersX[j] - poly.CornersX[i]) * (testy - poly.CornersY[i]) / (poly.CornersY[j] - poly.CornersY[i]) + poly.CornersX[i]));
if ((poly.CornersY[i] > testy) != (poly.CornersY[j] > testy) &&
(testx < (poly.CornersX[j] - poly.CornersX[i]) * (testy - poly.CornersY[i]) / (poly.CornersY[j] - poly.CornersY[i]) + poly.CornersX[i])) {
result = !result;
}
}
return result;
}
function GetIntersectionPoints(l1p1, l1p2, poly) {
var l1p1_X=eval('' + l1p1.split(',')[0]);
var l1p1_Y=eval('' + l1p1.split(',')[1]);
var l1p2_X=eval('' + l1p2.split(',')[0]);
var l1p2_Y=eval('' + l1p2.split(',')[1]);
var ip=null, ipx=null;
var next, i;
//List<Point2D> intersectionPoints = new List<Point2D>();
intersectionPoints = null;
for (i = 0; i < poly.CornersX.length; i++) {
next = (i + 1 == poly.CornersX.length) ? 0 : i + 1;
ip = GetIntersectionPoint('' + l1p1_X + ',' + l1p1_Y, '' + l1p2_X + ',' + l1p2_Y, '' + poly.CornersX[i] + ',' + poly.CornersY[i], '' + poly.CornersX[next] + ',' + poly.CornersY[next]);
if (ip != null) { ipx=ip; if (twoll.indexOf(ip) == -1) { twoll.push(ip); onell.push(ip, istart); isstart=false; } }
}
return ipx; //intersectionPoints.ToArray();
}
function GetIntersectionOfPolygons(poly1, poly2) { // thanks to https://www.swtestacademy.com/intersection-convex-polygons-algorithm/
var clippedCorners = new Array();
var totar=0.0;
var firstpt=null; //new_Point2D
var lastpt=null; //new_Point2D
var isin=false;
isstart=true;
var newp=null;
var i, j, next, sofar='';
onell=[];
twoll=[];
//Add the corners of poly1 which are inside poly2
//alert(' poly1.CornersX.length=' + poly1.CornersX.length);
for (i = 0; i < poly1.CornersX.length; i++) {
if (new_IsPointInsidePoly(poly1.CornersX[i], poly1.CornersY[i], poly2)) {
isin=true;
//if (!within) { alert(54); }
within=true;
//clippedCorners.AddPoints(new Point2D(poly1.Corners[i] ));
if (twoll.indexOf('' + poly1.CornersX[i] + ',' + poly1.CornersY[i]) == -1) { twoll.push('' + poly1.CornersX[i] + ',' + poly1.CornersY[i]); onell.push(new_LinkedList2D('' + poly1.CornersX[i] + ',' + poly1.CornersY[i], isstart)); }
isstart=false;
} else {
allwithin=false;
}
}
//Add the corners of poly2 which are inside poly1
for (i = 0; i < poly2.CornersX.length; i++) {
if (new_IsPointInsidePoly(poly2.CornersX[i], poly2.CornersY[i], poly1)) {
isin=true;
within=true;
//alert(154);
//clippedCorners.AddPoints(new Point2D(poly2.Corners[i]));
if (twoll.indexOf('' + poly2.CornersX[i] + ',' + poly2.CornersY[i]) == -1) { twoll.push('' + poly2.CornersX[i] + ',' + poly2.CornersY[i]); onell.push(new_LinkedList2D('' + poly2.CornersX[i] + ',' + poly2.CornersY[i], isstart)); }
isstart=false;
}
}
//Add the intersection points
// Area via (x1 y2 − y1 x2) + ( x 2 y 3 − y 2 x 3 ) ..... + ( x n y 1 − y n x 1 ) / 2
for (i = 0; i < eval(0 + poly1.CornersX.length); i++) {
for (j = 0; j < eval(0 + poly2.CornersX.length); j++) {
//alert('i=' + i + ' and j=' + j + ' ... ' + poly1.CornersX.length + ',' + poly2.CornersX.length);
newp=GetIntersectionPoint('' + poly1.CornersX[i] + ',' + poly1.CornersY[i], '' + poly1.CornersX[eval((i + 1) % poly1.CornersX.length)] + ',' + poly1.CornersY[eval((i + 1) % poly1.CornersX.length)], '' + poly2.CornersX[j] + ',' + poly2.CornersY[j], '' + poly2.CornersX[eval((j + 1) % poly2.CornersX.length)] + ',' + poly2.CornersY[eval((j + 1) % poly2.CornersX.length)]);
if (newp) { if (!firstpt) { firstpt=newp; lastpt=newp; } else { totar+=eval(eval(newp.y) * eval(lastpt.x)) - eval(eval(newp.x) * eval(lastpt.y)); lastpt=newp; } isin=true; }
}
}
if (1 == 7) {
for (i = 0, next = 1; i < poly1.CornersX.length; i++, next = (i + 1 == poly1.CornersX.length) ? 0 : i + 1) {
//alert('i=' + i + ' and next=' + next + ' ... ' + poly1.CornersX[i] + ',' + poly1.CornersY[i] + ';' + poly1.CornersX[next] + ',' + poly1.CornersY[next]);
//clippedCorners.AddPoints(GetIntersectionPoints(poly1.Corners[i], poly1.Corners[next], poly2));
newp=GetIntersectionPoints('' + poly1.CornersX[i] + ',' + poly1.CornersY[i], '' + poly1.CornersX[next] + ',' + poly1.CornersY[next], poly2);
if (newp) { if (!firstpt) { firstpt=newp; lastpt=newp; } else { totar+=eval(eval(newp.y) * eval(lastpt.x)) - eval(eval(newp.x) * eval(lastpt.y)); lastpt=newp; } isin=true; }
}
}
if (isin) { if (firstpt) { totar+=eval(eval(firstpt.y) * eval(lastpt.x)) - eval(eval(firstpt.x) * eval(lastpt.y)); } if (Math.abs(totar) > 0.001) { someadjacent=true; } poly='poly'; mapareait(); return true; }
return null;
//if (clippedCorners.length == 0) { return null; }
//return new ConvexPolygon2D(OrderClockwise(clippedCorners.slice()));
}
function vsw(inws) {
if (maxw < 0) { maxw=screen.width; }
return inws;
return '' + Math.round(eval(inws.replace('px','') * 100.0 / maxw)) + '%';
}
function vsh(inhs) {
if (maxh < 0) { maxh=screen.height; }
return inhs;
return '' + Math.round(eval(inhs.replace('px','') * 100.0 / maxh)) + '%';
}
function badltom(allfour) {
var retval='' + Math.min(eval(allfour.split(',')[0]), eval(allfour.split(',')[2]));
rest+='<div class="dglow" style="position:absolute;left:' + vsw('' + retval + 'px') + ';top:' + vsh('' + Math.min(eval(allfour.split(',')[1]), eval(allfour.split(',')[3])) + 'px') + ';width:';
retval+=',' + Math.min(eval(allfour.split(',')[1]), eval(allfour.split(',')[3]));
rest+='' + vsw('' + (Math.max(eval(allfour.split(',')[0]), eval(allfour.split(',')[2])) - Math.min(eval(allfour.split(',')[0]), eval(allfour.split(',')[2]))) + 'px') + ';height:';
retval+=',' + Math.max(eval(allfour.split(',')[0]), eval(allfour.split(',')[2]));
retval+=',' + Math.max(eval(allfour.split(',')[1]), eval(allfour.split(',')[3]));
rest+='' + vsh('' + (Math.max(eval(allfour.split(',')[1]), eval(allfour.split(',')[3])) - Math.min(eval(allfour.split(',')[1]), eval(allfour.split(',')[3]))) + 'px') + ';z-index:12;background-color:yellow;opacity:0.6;text-align:center;"><br><br>Intersection of ' + atitle + '</div>';
return retval;
}
function ltom(allfour) {
var retval='' + Math.min(eval(allfour.split(',')[0]), eval(allfour.split(',')[2]));
rest+='<div class="dglow" style="position:absolute;left:' + retval + 'px;top:' + Math.min(eval(allfour.split(',')[1]), eval(allfour.split(',')[3])) + 'px;width:';
retval+=',' + Math.min(eval(allfour.split(',')[1]), eval(allfour.split(',')[3]));
rest+='' + eval(Math.max(eval(allfour.split(',')[0]), eval(allfour.split(',')[2])) - Math.min(eval(allfour.split(',')[0]), eval(allfour.split(',')[2]))) + 'px;height:';
retval+=',' + Math.max(eval(allfour.split(',')[0]), eval(allfour.split(',')[2]));
retval+=',' + Math.max(eval(allfour.split(',')[1]), eval(allfour.split(',')[3]));
rest+='' + eval(Math.max(eval(allfour.split(',')[1]), eval(allfour.split(',')[3])) - Math.min(eval(allfour.split(',')[1]), eval(allfour.split(',')[3]))) + 'px;z-index:12;background-color:yellow;opacity:0.6;text-align:center;"><br><br>Intersection of ' + atitle + '</div>';
//alert(rest + ' ... ' + allfour + ' ... ' + eval(Math.max(eval(allfour.split(',')[1]), eval(allfour.split(',')[3])) - Math.min(eval(allfour.split(',')[1]), eval(allfour.split(',')[3]))));
return retval;
}
function mapareait() {
// var areatemplate='<area shape="rect" coords="20,86,78,160" title="Rectangle 1" href="#" target="_blank" onclick="if (1 == 3) { alert(99); }" />';
var picked=false, coords='', delim='', lastx='', lasty='', finalcoords=',', prelastx='', prelasty='';
if (onell.length > 0) {
//if (within) { alert('onell.length=' + onell.length); }
for (var i=0; i < onell.length; i++) {
picked=false;
//alert('i=' + i);
for (var j=0; j < onell.length; j++) {
if (picked) {
picked=picked;
} else if (i >= 1 && finalcoords == '' && poly == 'rect') {
picked=picked;
onell[j].tagged=true;
} else if (!onell[j].tagged && coords == '') {
coords+=delim + onell[j].X[0] + ',' + onell[j].Y[0];
finalcoords+=coords;
lastx='' + onell[j].X[0];
lasty='' + onell[j].Y[0];
prelastx=lastx;
prelasty=lasty;
delim=',';
picked=true;
onell[j].tagged=true;
} else if (onell.length == 4 && i == 1 && !onell[j].tagged &&
((Math.round(('' + onell[j].X[0])) != Math.round(prelastx) && Math.round(('' + onell[j].Y[0])) != Math.round(prelasty)) ||
(Math.round(('' + onell[j].X[0])) != Math.round(prelastx) && Math.round(('' + onell[j].Y[0])) != Math.round(prelasty)))
) {
coords=finalcoords.substring(1);
if (eval(onell[j].X[0]) > eval(coords.split(',')[0])) {
coords=onell[j].X[0] + ',' + onell[j].Y[0] + delim + finalcoords.substring(1);
//if (within) { alert('finalcoords=' + finalcoords + ' Coords=' + coords + ' and after=' + ltom(coords)); }
} else {
coords+=delim + onell[j].X[0] + ',' + onell[j].Y[0];
//if (within) { alert('finalcoords=' + finalcoords + ' coords=' + coords + ' and after=' + ltom(coords)); }
}
coords=ltom(coords);
lastx='' + onell[j].X[0];
lasty='' + onell[j].Y[0];
delim=',';
picked=true;
onell[j].tagged=true;
//alert('Yes');
poly='rect';
finalcoords='';
} else if (poly == 'poly' && !onell[j].tagged &&
((Math.round(('' + onell[j].X[0])) == Math.round(lastx) && Math.round(('' + onell[j].Y[0])) != Math.round(lasty)) ||
(Math.round(('' + onell[j].X[0])) != Math.round(lastx) && Math.round(('' + onell[j].Y[0])) == Math.round(lasty)))
) {
coords+=delim + onell[j].X[0] + ',' + onell[j].Y[0];
lastx='' + onell[j].X[0];
lasty='' + onell[j].Y[0];
delim=',';
if (i == 1 && onell.length == 4) { picked=picked; } else { picked=true; }
onell[j].tagged=true;
//alert('yes');
}
}
}
maphtml=maphtml.replace('>', '><area shape="' + poly + '" coords="' + coords + finalcoords + '" title="' + atitle +'" href="#" target="_blank" onclick="if (1 == 1) { alert(99); }" />');
//if (within) { alert(maphtml + rest); }
}
}
function new_Point2D(isx, isy) {
return '' + isx + ',' + isy;
}
function new_LinkedList2D(isxy, isfirst) {
//console.log(isxy);
var previs;
if (isfirst) {
return {
X: [eval(isxy.split(',')[0])],
Y: [eval(isxy.split(',')[1])],
tagged: false,
next: null,
prev: null
};
} else if (isxy != '') {
previs=null; //onell[eval(-1 + onell.length)];
//alert(isxy);
//new_LinkedList2D('', false);
return {
X: [eval(isxy.split(',')[0])],
Y: [eval(isxy.split(',')[1])],
tagged: false,
next: null,
prev: previs
};
} else {
previs=onell[eval(-2 + onell.length)];
previs.next=onell[eval(-1 + onell.length)];
return null;
}
}
function new_ConvexPolygon2D_via_title(isxy, numsd) {
console.log(isxy);
var inu=eval('' + numsd);
return {
CornersX: [eval(isxy.split(',')[0])],
CornersY: [eval(isxy.split(',')[1])],
CornersCurr: 1,
CornersLength: inu
};
}
function new_ConvexPolygon2D(isxy) {
console.log(isxy);
return {
CornersX: [eval(isxy.split(',')[0])],
CornersY: [eval(isxy.split(',')[1])],
CornersCurr: 1,
CornersLength: 4
};
}
function new_ZAddPoints(pool, newpoints) {
var found = false;
//if (pool.CornersCurr >= 4) { found=true; }
//if (!found) { pool.CornersX[pool.CornersCurr]=eval(newpoints.split(',')[0]); pool.CornersY[pool.CornersCurr]=eval(newpoints.split(',')[1]); pool.CornersCurr++; }
if (!found) { onepoly[eval(-1 + onepoly.length)].CornersX.push(eval(newpoints.split(',')[0])); onepoly[eval(-1 + onepoly.length)].CornersY.push(eval(newpoints.split(',')[1])); onepoly[eval(-1 + onepoly.length)].CornersCurr++; }
}
function divpolys() {
var vertsare=[];
var iverts=0;
var ddrot=0.0;
var divsii;
var xdiff=0.0, ydiff=0.0;
var divsiileft=0.0, divsiitop=0.0, divsiiwidth=0.0, divsiiheight=0.0;
divs=document.getElementsByTagName('div');
console.log(divs[eval(-1 + eval('' + divs.length))].outerHTML);
for (var ii=0; ii<divs.length; ii++) {
//alert(ii);
ddrot=0.0;
xdiff=0.0;
ydiff=0.0;
divsii=divs[ii].getBoundingClientRect();
if (('' + divs[ii].title).indexOf(',') != -1 && ('' + divs[ii].title).indexOf(' ') != -1) {
vertsare=('' + divs[ii].title).split(' ');
for (iverts=0; iverts<vertsare.length; iverts++) {
if (iverts == 0) {
onenp.push(new_Point2D(eval(vertsare[iverts].split(',')[0]), eval(vertsare[iverts].split(',')[1])));
onepoly.push(new_ConvexPolygon2D_via_title(onenp[eval(-1 + onenp.length)], vertsare.length));
} else {
onenp.push(new_Point2D(eval(vertsare[iverts].split(',')[0]), eval(vertsare[iverts].split(',')[1])));
}
new_ZAddPoints(onepoly[eval(-1 + onepoly.length)],onenp[eval(-1 + onenp.length)]);
//onenp.push(new_Point2D(eval(vertsare[0].split(',')[0]), eval(vertsare[0].split(',')[1])));
//new_ZAddPoints(onepoly[eval(-1 + onepoly.length)],onenp[eval(-1 + onenp.length)]);
}
} else {
if (divs[ii].style.transform.indexOf('deg)') != -1) {
ddrot=eval('' + divs[ii].style.transform.split('(')[1].split('deg)')[0]);
//alert(divs[ii].outerHTML);
}
divsiileft=eval('' + divs[ii].style.left.replace('px',''));
divsiitop=eval('' + divs[ii].style.top.replace('px',''));
if (eval('' + divsii.width) > maxw) { maxw=eval('' + divsiiwidth); }
if (eval('' + divsii.height) > maxh) { maxh=eval('' + divsiiheight); }
if (eval('' + divsii.width) <= eval('' + divsii.height)) {
divsiiwidth=eval('' + divs[ii].style.width.replace('px',''));
divsiiheight=eval('' + divs[ii].style.height.replace('px',''));
} else {
divsiiheight=eval('' + divs[ii].style.width.replace('px',''));
divsiiwidth=eval('' + divs[ii].style.height.replace('px',''));
}
divs[ii].title='Polygon ' + eval(1 + ii);
onenp.push(new_Point2D(divsiileft, divsiitop));
//alert(12);
onepoly.push(new_ConvexPolygon2D(onenp[eval(-1 + onenp.length)]));
//alert(13);
xdiff+=Math.cos(ddrot * Math.PI / 180.0) * divsiiwidth;
ydiff+=Math.sin(ddrot * Math.PI / 180.0) * divsiiwidth;
//alert(divs[ii].style.transform + ' ddrot=' + ddrot + ' width=' + divsii.width + ' height=' + divsii.height + ' xdiff=' + xdiff + ' ydiff=' + ydiff);
onenp.push(new_Point2D(eval(divsiileft + xdiff), eval(divsiitop + ydiff)));
//alert(14);
new_ZAddPoints(onepoly[eval(-1 + onepoly.length)],onenp[eval(-1 + onenp.length)]);
//alert(15);
xdiff-=Math.sin(ddrot * Math.PI / 180.0) * divsiiheight;
ydiff+=Math.cos(ddrot * Math.PI / 180.0) * divsiiheight;
onenp.push(new_Point2D(eval(divsiileft + xdiff), eval(divsiitop + ydiff)));
//alert(16);
new_ZAddPoints(onepoly[eval(-1 + onepoly.length)],onenp[eval(-1 + onenp.length)]);
//alert(17);
xdiff-=Math.cos(ddrot * Math.PI / 180.0) * divsiiwidth;
ydiff-=Math.sin(ddrot * Math.PI / 180.0) * divsiiwidth;
onenp.push(new_Point2D(eval(divsiileft + xdiff), eval(divsiitop + ydiff)));
//alert(18);
new_ZAddPoints(onepoly[eval(-1 + onepoly.length)],onenp[eval(-1 + onenp.length)]);
//alert(19);
onenp.push(new_Point2D(divsiileft, divsiitop));
//alert(20);
new_ZAddPoints(onepoly[eval(-1 + onepoly.length)],onenp[eval(-1 + onenp.length)]);
//alert(1);
//onenp.push(new_Point2D(divsiileft, divsiitop));
}
}
console.log('xxx');
console.log(onepoly[eval(-1 + onepoly.length)]);
var sofar='';
for (var jj=0; jj<onepoly.length; jj++) {
for (var kk=0; kk<onepoly.length; kk++) {
if (jj != kk && sofar.indexOf(',' + eval(1 + jj) + ';' + eval(1 + kk) + ',') == -1 && pofinterest.indexOf(',' + eval(1 + jj) + ';' + eval(1 + kk) + ',') != -1) {
sofar+=',' + eval(1 + kk) + ';' + eval(1 + jj) + ',';
atitle='Polygon ' + eval(1 + jj) + ' and Polygon ' + eval(1 + kk);
//GetIntersectionOfPolygons(onepoly[jj], onepoly[kk]);
//if (GetIntersectionOfPolygons(onepoly[jj], onepoly[kk])) {
// alert(atitle + ' intersect');
//} else {
// alert(atitle + ' do not intersect');
//}
}
}
}
if (1 == 11 && maphtml.replace('area shape','poly').replace('rect','poly').indexOf('oly') != -1) {
//alert(rest);
//document.body.innerHTML=dbih + maphtml.replace('<map ','<map style="z-index:7;width:100%;height:100%;" ') + rest;
//document.body.innerHTML+=maphtml.replace('<map ','<map style="z-index:7;width:100%;height:100%;" ') + rest;
//alert(rest);
document.body.innerHTML=dbih + rest;
//alert(document.body.innerHTML);
dbih=document.body.innerHTML;
maphtml=origmap;
within=false;
}
dbih=document.body.innerHTML;
maphtml=origmap;
within=false;
}
function intersectRect(r1, r2) { // thanks to https://stackoverflow.com/questions/2752349/fast-rectangle-to-rectangle-intersection
//if (!dpdone) { dpdone=true; dbih=document.body.innerHTML; divpolys(); }
//return GetIntersectionOfPolygons(onepoly[gone], onepoly[gtwo]);
if (('' + orects[gone].title).indexOf(',') != -1 || ('' + orects[gtwo].title).indexOf(',') != -1) {
if (!dpdone) { dpdone=true; dbih=document.body.innerHTML; divpolys(); }
within=false;
allwithin=true;
someadjacent=false;
return GetIntersectionOfPolygons(onepoly[gone], onepoly[gtwo]);
} else if (eval('' + r1.width) != eval('' + ('' + orects[gone].style.width).replace('px','')) || eval('' + r2.width) != eval('' + ('' + orects[gtwo].style.width).replace('px',''))) {
if (!(r2.left > r1.right ||
r2.right < r1.left ||
r2.top > r1.bottom ||
r2.bottom < r1.top)) {
if (!dpdone) { dpdone=true; dbih=document.body.innerHTML; divpolys(); }
within=false;
allwithin=true;
someadjacent=false;
return GetIntersectionOfPolygons(onepoly[gone], onepoly[gtwo]);
} else {
return false;
}
}
if (dpdone) {
within=false;
allwithin=true;
someadjacent=false;
return GetIntersectionOfPolygons(onepoly[gone], onepoly[gtwo]);
}
return !(r2.left > r1.right ||
r2.right < r1.left ||
r2.top > r1.bottom ||
r2.bottom < r1.top);
}
function adjacentTo(r1, r2) { // thanks to https://stackoverflow.com/questions/2752349/fast-rectangle-to-rectangle-intersection
if (intersectRect(r1, r2)) {
return (r2.left == r1.right ||
r2.right == r1.left ||
r2.top == r1.bottom ||
r2.bottom == r1.top);
} else {
return false;
}
}
function contains(r1, r2) { // thanks to https://stackoverflow.com/questions/27768039/find-out-if-a-rectangle-is-inside-another-rectangle-c
if ( (r2.right) < (r1.right)
&& (r2.left) > (r1.left)
&& (r2.top) > (r1.top)
&& (r2.bottom) < (r1.bottom) ) {
return true;
} else {
return false;
}
}
function woit(tois) {
if (wo != null) {
wo.close();
wo=null;
}
wo=window.open('','_blank','top=20,left=20,width=900,height=900');
wo.document.write('<html><body>' + tois.outerHTML + '</body></html>');
}
function enoughmovement() {
var avx=0.0, avy=0.0, xok=true, yok=true;
var i, jx=0, jy=0;
prevx=0;
prevy=0;
lastx=-1;
lasty=-1;
if (ok) {
for (i=0; i<ts.length; i++) {
if (ok) {
if (xs[i] != 0) {
if (jx == 0) {
prevx=xs[i];
lastx=xs[i];
} else if (lastx == xs[i]) {
if (xok == true) {
prevx=lastx;
lastx=xs[i];
xok=false;
} else {
ok=false;
sin=11;
}
} else {
prevx=lastx;
lastx=xs[i];
xok=true;
}
jx++;
avx=eval(avx * eval(-1 + jx) + xs[i]) / eval(jx);
}
if (ys[i] != 0) {
if (jy == 0) {
prevy=ys[i];
lasty=ys[i];
} else if (lasty == ys[i]) {
if (xok == true) {
prevy=lasty;
lasty=ys[i];
yok=false;
} else {
ok=false;
sin=12;
}
} else {
prevy=lasty;
lasty=ys[i];
yok=true;
}
jy++;
avy=eval(avy * eval(-1 + jy) + ys[i]) / eval(jy);
}
}
}
return ok;
} else {
return false;
}
}
function onesec() {
var i;
if (ok) {
score++;
if (myx != 0 && myy != 0) {
xs[eval(score % ts.length)] = myx;
ys[eval(score % ts.length)] = myy;
if (score > eval(prevscore + 5)) ok=enoughmovement();
} else if (qt == 15) {
ok=false;
sin=5;
qt=0;
} else {
qt++;
}
myx=0;
myy=0;
} else if (ci != null && relevant) {
clearInterval(ci);
ci=null;
var synopsis=prompt('You have scored ' + score + ' from ' + goes + ' goes. You can answer with number of colours (currently ' + ts.length + ') to use up to ' + allcols.length + ' (and optionally abscissa-ize with .3 to .8 number of polygon sides to enforce)', '');
if (synopsis != null) {
if ((synopsis + ' ').toUpperCase().substring(0,1) == "Y") {
alert(("" + sin).replace('12','Y co-ordinate lazy').replace('11','X co-ordinate lazy').replace('7','You stepped on a tile.').replace('5','Too passive.').replace('1','X co-ordinate still').replace('2','X co-ordinate still'));
} else if ((synopsis + ' ').substring(0,1) >= '1' && (synopsis + ' ').substring(0,1) <= '9' && (synopsis + ' ').indexOf('.') != -1) {
location.href=(document.URL.split('#')[0].replace('numcols=','nXumcols=').replace('numsides=','nXumsides=').replace('glow=','gXlow=') + '&numcols=' + synopsis.replace('.','&numsides=') + dglow).replace('.htm&','.htm?').replace('.html&','.html?');
} else if ((synopsis + ' ').substring(0,1) >= '1' && (synopsis + ' ').substring(0,1) <= '9') {
location.href=(document.URL.split('#')[0].replace('numcols=','nXumcols=').replace('glow=','gXlow=') + '&numcols=' + synopsis.replace('.','&numsides=') + dglow).replace('.htm&','.htm?').replace('.html&','.html?');
}
}
document.body.innerHTML='<table style=width:100%;><tr><td id=left style=width:70%;><input id=crb type="button" value="Create Rectangles ' + eval(goes + 1) + '! Score:' + score + '" onclick="MakePopups(event);" style="background-color: lightgreen;position:absolute;left:0px;top:0px;"/></td><td id=right style=vertical-align:top; style=width:30%;background-color:#f0f0f0;>' + htmltablerteport + '</td></tr></table>';
//document.title='Create Rectangles ... Score:' + score + ' Goes:' + goes;
pword="";
extentx=0;
extenty=0;
ok=false;
prevx=0;
prevy=0;
lastx=0;
lasty=0;
myx=0;
myy=0;
for (i=0; i<ts.length; i++) xs[i]=0;
for (i=0; i<ts.length; i++) ys[i]=0;
prevscore=score;
qt=0;
sin=0;
//kup();
MakePopups(lastevent);
}
relevant=true;
}
function MakePopups(event) {
var i, j=1;
lastevent=event;
doneonce=false;
if (ci != null) {
clearInterval(ci);
ci=null;
}
document.body.innerHTML='<table style=width:100%;><tr><td id=left style=width:70%;><input id=crb type="button" value="Create Rectangles ' + eval(goes + 1) + '! Score:' + score + '" onclick="MakePopups(event);" style="background-color: lightgreen;position:absolute;left:0px;top:0px;"/></td><td id=right style=vertical-align:top; style=width:30%;background-color:#f0f0f0;>' + htmltablerteport + '</td></tr></table>';
//document.title='Create Rectangles ... Score:' + score + ' Goes:' + goes;
pword="";
extentx=0;
extenty=0;
ok=false;
prevx=0;
prevy=0;
lastx=0;
lasty=0;
myx=0;
myy=0;
for (i=0; i<ts.length; i++) xs[i]=0;
for (i=0; i<ts.length; i++) ys[i]=0;
prevscore=score;
qt=0;
sin=0;
goes++;
j--;
for (i=0; i<(ts.length - 1); i++) {
j++;
ls[i]=Math.floor(Math.random() * (600 - 35) + 35);
ts[i]=Math.floor(Math.random() * (600 - 35) + 35);
ws[i]=Math.floor(Math.random() * (200 - 35) + 35);
hs[i]=Math.floor(Math.random() * (200 - 35) + 35);
MakePopup(event, pw[i], ps[i], cols[i], ls[i], ts[i], ws[i], hs[i], i);
if (eval(ls[i] + ws[i]) > extentx) extentx=eval(ls[i] + ws[i]);
if (eval(ts[i] + hs[i]) > extenty) extenty=eval(ts[i] + hs[i]);
}
ls[j]=eval(5 + extentx);
ts[j]=0;
ws[j]=10;
hs[j]=1200;
MakePopup(event, pw[j], ps[j], cols[j], ls[j], ts[j], ws[j], hs[j], j);
ok=true;
ci=setInterval(onesec,9000);
}
function andlater() {
if (!doneonce) {
for (var ji=0; ji<cmds.length; ji++) {
eval(cmds[ji]);
}
for (var kji=0; kji<rects.length; kji++) {
var seprt=false;
document.getElementById('intersects' + kji).innerHTML='';
document.getElementById('within' + kji).innerHTML='';
document.getElementById('adjacent' + kji).innerHTML='';
document.getElementById('separate' + kji).innerHTML='';
for (var mji=0; mji<rects.length; mji++) {
if (mji != kji) {
gone=kji;
gtwo=mji;
seprt=true;
if (mji > kji || 1 == 1) {
if (intersectRect(rects[kji], rects[mji])) {
seprt=false;
if (document.getElementById('intersects' + kji).innerHTML.indexOf(cmds[mji].split("='")[1].split("'")[0]) == -1) {
document.getElementById('intersects' + kji).innerHTML+='<span style=background-color:' + cmds[mji].split("='")[1].split("'")[0] + ';>' + bks + '</span>';
}
}
if (someadjacent) {
seprt=false;
if (document.getElementById('adjacent' + kji).innerHTML.indexOf(cmds[mji].split("='")[1].split("'")[0]) == -1) {
document.getElementById('adjacent' + kji).innerHTML+='<span style=background-color:' + cmds[mji].split("='")[1].split("'")[0] + ';>' + bks + '</span>';
}
} else if (!dpdone) {
if (adjacentTo(rects[kji], rects[mji])) {
seprt=false;
if (document.getElementById('adjacent' + kji).innerHTML.indexOf(cmds[mji].split("='")[1].split("'")[0]) == -1) {
document.getElementById('adjacent' + kji).innerHTML+='<span style=background-color:' + cmds[mji].split("='")[1].split("'")[0] + ';>' + bks + '</span>';
}
}
}
}
if (allwithin) {
seprt=false;
if (document.getElementById('within' + kji).innerHTML.indexOf(cmds[mji].split("='")[1].split("'")[0]) == -1) {
document.getElementById('within' + kji).innerHTML+='<span style=background-color:' + cmds[mji].split("='")[1].split("'")[0] + ';>' + bks + '</span>';
}
} else if (!dpdone) {
if (contains(rects[mji], rects[kji])) {
seprt=false;
if (document.getElementById('within' + kji).innerHTML.indexOf(cmds[mji].split("='")[1].split("'")[0]) == -1) {
document.getElementById('within' + kji).innerHTML+='<span style=background-color:' + cmds[mji].split("='")[1].split("'")[0] + ';>' + bks + '</span>';
}
}
}
if (seprt) {
if (document.getElementById('separate' + kji).innerHTML.indexOf(cmds[mji].split("='")[1].split("'")[0]) == -1) {
document.getElementById('separate' + kji).innerHTML+='<span style=background-color:' + cmds[mji].split("='")[1].split("'")[0] + ';>' + bks + '</span>';
}
}
}
}
}
doneonce=true;
}
cmds=[];
rects=[];
orects=[];
onenp=[];
onepoly=[];
onell=[];
twoll=[];
dpdone=false;
pofinterest=',5;6,4;6,2;6,';
areatemplate='<area shape="rect" coords="20,86,78,160" title="Rectangle 1" href="#" target="_blank" onclick="if (1 == 3) { alert(99); }" />';
maphtml='<map id="mijigsaw" name="mijigsaw"><area nohref alt="" shape="default" /></map>';
origmap=maphtml;
atitle='';
isstart=true;
poly='poly';
rest='';
maxw=-1;
maxh=-1;
within=false;
allwithin=false;
someadjacent=false;
}
function MakePopup(event, popupWindow, popupIsShown, colis, lis, tis, wis, his, indx) {
var drot=0;
var svgpl='', svgplm='';
var numsides=4;
var foldover=0;
if (1 == 56 && window.createPopup) { //Internet Explorer
if (!popupWindow) {
popupWindow = window.createPopup();
var popupBody = popupWindow.document.body;
popupBody.style.backgroundColor = colis; //"lightblue";
popupBody.style.opacity = "0.9"; //"lightblue";
drot=Math.floor(Math.random() * 45);
popupBody.style.transform='rotate(' + drot + 'deg)';
popupBody.style.transformOrigin="left top";
cmds.push("document.getElementById('col" + indx + "').style.backgroundColor='" + colis + "'");
if (indx == 0) { setTimeout(andlater,200); }
popupBody.style.border = "solid black 1px";
//popupBody.mousedown="function(event) { alert('IE'); }";
//popupBody.mouseover="function(event) { alert('IEblur'); }";
if (1 == 2) popupBody.innerHTML = "Click outside to close.";
}
popupWindow.show (lis, tis, wis, his, document.body); //100, 100, 150, 25, document.body);
//document.title='Create Rectangle ... Score:' + score + ' Goes:' + goes;
pword="client";
}
else {
if (!popupIsShown) {
if (!popupWindow) {
popupWindow = document.createElement("div");
//popupWindow.style.backgroundColor = colis; //"lightblue";
cmds.push("document.getElementById('col" + indx + "').style.backgroundColor='" + colis + "'");
if (indx == 0) { setTimeout(andlater,200); }
popupWindow.style.position = "absolute";
popupWindow.style.width = wis + "px"; //150
popupWindow.style.height = his + "px"; //25
popupWindow.style.top = tis + "px"; //"100px";
popupWindow.style.left = lis + "px"; //"100px";
popupWindow.style.opacity = "0.9"; //"100px";
// '<svg height="100%" width="100%"><polygon points="' + svgpl + '" style="fill:' + fcol + ';stroke:purple;stroke-width:1" /></svg>'
drot=0;
svgpl='';
svgplm='';
numsides=eval(Math.floor(Math.random() * 7) + 2);
foldover=eval(Math.floor(Math.random() * 4) + 0);
//numsides=2;
if (document.URL.indexOf('numsides=') != -1) {
numsides=location.search.split('numsides=')[1] ? decodeURIComponent(location.search.split('numsides=')[1].split('&')[0]) : numsides;
}
if (numsides == 4 || eval('' + indx) == eval(-1 + ts.length)) {
popupWindow.title='';
popupWindow.style.border = "solid black 1px";
popupWindow.style.backgroundColor = colis; //"lightblue";
drot=Math.floor(Math.random() * 45);
popupWindow.style.transform='rotate(' + drot + 'deg)';
popupWindow.style.transformOrigin="" + lis + " " + tis + "";
} else if (numsides == 3) {
svgpl='' + eval(lis - 0) + ',' + eval(tis - 0);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his);
svgplm='' + eval(lis - lis) + ',' + eval(tis - tis);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his);
popupWindow.title=svgpl;
popupWindow.innerHTML = '<svg height="100%" width="100%"><polygon points="' + svgplm + '" style="fill:' + colis + ';stroke:purple;stroke-width:1" /></svg>';
//alert(popupWindow.innerHTML);
} else if (numsides == 5) {
if (eval(foldover % 2) == 0) {
svgpl='' + eval(lis - 0) + ',' + eval(tis - 0);
svgplm='' + eval(lis - lis) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis + wis - 0 - wis/2) + ',' + eval(tis - 0);
svgplm+=' ' + eval(lis + wis - lis - wis/2) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his/2);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his/2);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis - 0) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis - lis) + ',' + eval(tis - tis + his);
} else {
svgpl='' + eval(lis - 0 + wis/2) + ',' + eval(tis - 0);
svgplm='' + eval(lis - lis + wis/2) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis - 0) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis - lis) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis - 0) + ',' + eval(tis - 0 + his/2);
svgplm+=' ' + eval(lis - lis) + ',' + eval(tis - tis + his/2);
}
popupWindow.title=svgpl;
popupWindow.innerHTML = '<svg height="100%" width="100%"><polygon points="' + svgplm + '" style="fill:' + colis + ';stroke:purple;stroke-width:1" /></svg>';
} else if (numsides >= 8) {
svgpl='' + eval(lis - 0 + wis/3) + ',' + eval(tis - 0);
svgplm='' + eval(lis - lis + wis/3) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis - 0 + wis/3 + wis/3) + ',' + eval(tis - 0);
svgplm+=' ' + eval(lis - lis + wis/3 + wis/3) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his/3);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his/3);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his/3 + his/3);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his/3 + his/3);
svgpl+=' ' + eval(lis + wis - 0 - wis/3) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis + wis - lis - wis/3) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis + wis - 0 - wis/3 - wis/3) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis + wis - lis - wis/3 - wis/3) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis - 0) + ',' + eval(tis - 0 + his/3 + his/3);
svgplm+=' ' + eval(lis - lis) + ',' + eval(tis - tis + his/3 + his/3);
svgpl+=' ' + eval(lis - 0) + ',' + eval(tis - 0 + his/3);
svgplm+=' ' + eval(lis - lis) + ',' + eval(tis - tis + his/3);
popupWindow.title=svgpl;
popupWindow.innerHTML = '<svg height="100%" width="100%"><polygon points="' + svgplm + '" style="fill:' + colis + ';stroke:purple;stroke-width:1" /></svg>';
//alert('1: ' + popupWindow.innerHTML);
} else if (numsides == 7) {
svgpl='' + eval(lis - 0 + wis/3) + ',' + eval(tis - 0);
svgplm='' + eval(lis - lis + wis/3) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis - 0 + wis/3 + wis/3) + ',' + eval(tis - 0);
svgplm+=' ' + eval(lis - lis + wis/3 + wis/3) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his/3);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his/3);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his/3 + his/3);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his/3 + his/3);
svgpl+=' ' + eval(lis + wis - 0 - wis/3) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis + wis - lis - wis/3) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis + wis - 0 - wis/3 - wis/3) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis + wis - lis - wis/3 - wis/3) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis - 0) + ',' + eval(tis - 0 + his/3);
svgplm+=' ' + eval(lis - lis) + ',' + eval(tis - tis + his/3);
popupWindow.title=svgpl;
popupWindow.innerHTML = '<svg height="100%" width="100%"><polygon points="' + svgplm + '" style="fill:' + colis + ';stroke:purple;stroke-width:1" /></svg>';
//alert('2: ' + popupWindow.innerHTML);
} else if (numsides == 6) {
svgpl='' + eval(lis - 0 + wis/3) + ',' + eval(tis - 0);
svgplm='' + eval(lis - lis + wis/3) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis - 0 + wis/3 + wis/3) + ',' + eval(tis - 0);
svgplm+=' ' + eval(lis - lis + wis/3 + wis/3) + ',' + eval(tis - tis);
svgpl+=' ' + eval(lis + wis - 0) + ',' + eval(tis - 0 + his/3 + his/3);
svgplm+=' ' + eval(lis + wis - lis) + ',' + eval(tis - tis + his/3 + his/3);
svgpl+=' ' + eval(lis + wis - 0 - wis/3) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis + wis - lis - wis/3) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis + wis - 0 - wis/3 - wis/3) + ',' + eval(tis - 0 + his);
svgplm+=' ' + eval(lis + wis - lis - wis/3 - wis/3) + ',' + eval(tis - tis + his);
svgpl+=' ' + eval(lis - 0) + ',' + eval(tis - 0 + his/3);
svgplm+=' ' + eval(lis - lis) + ',' + eval(tis - tis + his/3);
popupWindow.title=svgpl;
popupWindow.innerHTML = '<svg height="100%" width="100%"><polygon points="' + svgplm + '" style="fill:' + colis + ';stroke:purple;stroke-width:1" /></svg>';
} else if (numsides > 4) {
popupWindow.title='';
popupWindow.style.border = "solid black 1px";
popupWindow.style.backgroundColor = colis; //"lightblue";
} else {
popupWindow.title='';
popupWindow.style.border = "solid black 1px";
popupWindow.style.backgroundColor = colis; //"lightblue";
}
//popupWindow.onmouseover="function(event) { top.document.title='Mouse Over'; }";
//popupWindow.mouseout="function(event) { top.document.title='Mouse Out'; }";
if (1 == 2) popupWindow.innerHTML = "Click outside to close.";
}
document.body.appendChild(popupWindow);
orects.push(popupWindow);
rects.push(popupWindow.getBoundingClientRect());
//if (pword == "") window.addEventListener ('click', RemovePopup, true);
if (pword == "") window.addEventListener('mouseover', MouseOver, true);
//window.addEventListener ('mouseout', MouseOut, true);
//window.addEventListener ('mousedown', MouseIsDown, true);
popupIsShown = true;
//document.title='Create Rectangles ... Score:' + score + ' Goes:' + goes;
// to avoid that the current click event propagates up
if (pword == "") event.stopPropagation ();
}
pword="page";
}
}
function MouseIsDown(event) {
alert('non-IE');
}
function MouseOver(event) {
if (pword != "" && ok) {
qt=0;
myx=eval("event." + pword + "X");
myy=eval("event." + pword + "Y");
if (eval(myx - extentx) > 0) {
sin=1;
ok=false;
}
if (eval(myy - extenty) > 0) {
sin=2;
ok=false;
}
if (ok) {
xs[eval(score % ts.length)] = myx;
ys[eval(score % ts.length)] = myy;
ok=enoughmovement();
}
var i, found=false;
if (ok) {
for (i=0; i<ts.length; i++) {
if (!found) {
if (myx >= ls[i] && myy >= ts[i] && myx <= eval(ls[i] + ws[i]) && myy <= eval(ts[i] + hs[i])) {
found=true;
}
}
}
}
if (found) {
if (1 == 7) { top.document.title='Mouse Over ... Score:' + score + ' Goes:' + goes; }
sin=7;
ok=false;
} else {
if (1 == 7) { top.document.title='Mouse Out ... Score:' + score + ' Goes:' + goes; }
}
}
}
function MouseOut(event) {
if (1 == 7) { top.document.title='Mouse Out ... Score:' + score + ' Goes:' + goes; }
//alert(99);
}
function RemovePopup(event) {
if (popupIsShown) {
var relation = popupWindow.compareDocumentPosition (event.target);
var clickInPopup = (event.target == popupWindow) || (relation & Node.DOCUMENT_POSITION_CONTAINED_BY);
if (!clickInPopup) {
document.body.removeChild(popupWindow);
window.removeEventListener('click', RemovePopup, true);
popupIsShown = false;
//document.title='Create Rectangles ... Score:' + score + ' Goes:' + goes;
pword="";
extentx=0;
extenty=0;
ok=false;
prevx=0;
prevy=0;
lastx=0;
lasty=0;
}
}
}
function firstone() {
document.getElementById('right').innerHTML=htmltablerteport;
}
function kup() {
document.getElementById("raselect").value=orignumsides;
document.body.addEventListener("keyup", function(event) {
event.preventDefault();
if (event.which == 13 || event.keyCode == 13) {
if (ci != null) {
clearInterval(ci);
ci=null;
}
MakePopups(event); //document.getElementById("crb").click();
}
});
}
function cit() {
if ( document.getElementById('cbglow').checked) {
document.getElementById('thright').innerHTML+="<style> div { -webkit-animation: glow 1s ease-in-out infinite alternate; -moz-animation: glow 1s ease-in-out infinite alternate; animation: glow 1s ease-in-out infinite alternate; } @-webkit-keyframes glow { from { box-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #e60073, 0 0 9px #e60073, 0 0 11px #e60073, 0 0 13px #e60073, 0 0 15px #e60073; } to { box-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #ff4da6, 0 0 10px #ff4da6, 0 0 12px #ff4da6, 0 0 14px #ff4da6, 0 0 16px #ff4da6; } } </style> ";
htmltablerteport=htmltablerteport.replace('></span>','>' + document.getElementById('thright').innerHTML + '</span>').replace(' id="cbglow"',' id="cbglow" style=display:none;');
prehtmltablerteport=prehtmltablerteport.replace('></span>','>' + document.getElementById('thright').innerHTML + '</span>').replace(' id="cbglow"',' id="cbglow" style=display:none;');
dglow='&glow=y';
}
}
setTimeout(kup,1000);
if (document.URL.indexOf('glow=') != -1) { setTimeout(cit, 1200); }
</script>
</head>
<body data-onload="kup();" style="width: 100%;">
<h1>Rectangle Analyze</h1>
<h4>RJM Programming - March, 2020</h4>
<table id=mytable style=width:100%;><tr><td id=left style=width:70%;>
<input id=crb type="button" value="Create Rectangles" onclick="MakePopups(event);" style="background-color: yellow;position:absolute;left:0px;top:0px;"/>
</td><td id=right style=vertical-align:top;width:30%;align:right;background-color:#f0f0f0;><script type='text/javascript'> document.write(htmltablerteport); document.getElementById('crb').click(); </script></td><input id=iootw type=text style=position:absolute;top:-200px;left:-200px; value=""></input></tr></table>
</body>
</html>