I have a SVG with more than a 1000 polygons each 3 look like a cube. at the moment I'm changing the colour by class name. but I would like that each polygon is visited randomly without any repeating, unit all of polygons visited.
我有一个超过1000个多边形的SVG,每个3看起来像一个立方体。目前我正按类名改变颜色。但我希望每个多边形都是随机访问的,没有任何重复,单位访问所有多边形。
https://jsfiddle.net/MSTq/rbgmjqwd/2/
for better view please visit jsfiddle
为了更好的观点,请访问jsfiddle
/*
Created on : 11/03/2017, 7:01:53 PM
Author : MSTq
*/
$(document).ready(function(){
var polygons = $("#Layer_1").find("polygon");
/*var paths = $("#svg-layer-1 ").find("path");
var pathslength = paths.length;*/
var polygonslength = polygons.length;
var colorSeter = $("#curent-color-set").find(".color-set");
var byclass = [];
for(var f = 0 ; f < 9; f++){
byclass.push($("#Layer_1").find(".st" + f));
}
setInterval(function (){
var clor = rColorSet([rColor(),rColor()])[randomise(2,0)];
var rar = randomise(8,0);
var colrSeter = colorSeter[rar];
byclass[rar].css({"fill":clor,"stroke":clor});
$(colrSeter).css({"background-color":clor});
$("#" + $(colrSeter).attr("id") + " p").text(clor);
},500);
});
function isPositive (){
return arguments[0] > 0;
}
function vlidPositive (){
return isPositive(arguments[0]) ? arguments[0] : 0;
}
function comparer (){
return arguments[0] > arguments[1];
}
function reservation (r,t){
r = vlidPositive(arguments[0]), t = vlidPositive(arguments[1]);
return (r * t) / 100;
}
function randomise (max,min){
max = vlidPositive(arguments[0]),min = vlidPositive(arguments[1]);
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function rColor (){
var hex = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"],
hexLength = hex.length -1,
limits = [[11,4],
[12,6],
[hexLength,8]],
color = "",
final = "#",
temp = "";
for (var j =0 ; j < 3; j++){
for (var i = 0 ; i < 2; i++){
temp += hex[randomise(limits[j][0] , limits[j][1])];
}
color += temp;
temp = "";
}
final += color;
return final;
}
function rColorSet(){
var colorset = [];
for (var i = 0; i < arguments.length; i++)
{
if (Array.isArray(arguments[i])){
colorset = arguments[i];
break;
}
}
return colorset;
}
/*
Created on : 11/03/2017, 7:01:53 PM
Author : MSTq
*/
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,body{
width: 100%;
height:100px;
}
svg {
width:100%;
height:auto;
display: block;
margin: auto;
background-size:auto;
margin-top: 10px;
}
#mydiv{
width:200px;
height:200px;
background-color: #FFF0F0;
}
#curent-color-set{
width: 100%;
height:40%;
margin-bottom: 10px;
}
.color-set{
position: relative;
height: 100%;
width: 7%;
margin-left: 1%;
margin-top: 5px;
background-color: #000000;
display: inline-block;
}
.color-code{
font-size: .75em;
line-height: 34px;
}
.st0{fill:#EF4136;}
.st1{fill:#F7941E;}
.st2{fill:#00A79D;}
.st3{fill:#662D91;}
.st4{fill:#EC008C;}
.st5{fill:#F9ED32;}
.st6{fill:#8B5E3C;}
.st7{fill:#C2B59B;}
.st8{fill:#009444;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!--
/*
Created on : 11/03/2017, 7:01:53 PM
Author : MSTq
*/
-->
<div id="curent-color-set">
<div id="color-0" class="color-set"><p class="color-code">#</p></div>
<div id="color-1" class="color-set"><p class="color-code">#</p></div>
<div id="color-2" class="color-set"><p class="color-code">#</p></div>
<div id="color-3" class="color-set"><p class="color-code">#</p></div>
<div id="color-4" class="color-set"><p class="color-code">#</p></div>
<div id="color-5" class="color-set"><p class="color-code">#</p></div>
<div id="color-6" class="color-set"><p class="color-code">#</p></div>
<div id="color-7" class="color-set"><p class="color-code">#</p></div>
<div id="color-8" class="color-set"><p class="color-code">#</p></div>
</div>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 1920 1080" style="enable-background:new 0 0 1920 1080;" xml:space="preserve">
<g id="XMLID_32_">
<polygon id="XMLID_41_" class="st0" points="43.3,75 0,100 0,149.5 43.3,124.8 "/>
<polygon id="XMLID_40_" class="st1" points="43.3,124.8 0,149.5 0,150 43.3,175 86.6,150 43.3,125 "/>
<polygon id="XMLID_39_" class="st2" points="43.3,75 43.3,124.8 45.4,123.6 43.3,124.8 43.3,125 86.6,150 86.6,100 "/>
<polygon id="XMLID_38_" class="st3" points="129.9,75 129.9,25 86.6,0 86.6,50 "/>
<polygon id="XMLID_37_" class="st4" points="86.6,0 43.3,25 43.3,75 86.6,50 "/>
<polygon id="XMLID_36_" class="st5" points="129.9,75 86.6,50 86.6,51.8 86.6,50 43.3,75 86.6,100 "/>
<polygon id="XMLID_35_" class="st6" points="173.2,150 173.2,100 129.9,75 129.9,124.9 "/>
<polygon id="XMLID_34_" class="st7" points="129.9,124.9 129.9,125 86.6,150 129.9,175 173.2,150 173.2,150 "/>
<polygon id="XMLID_33_" class="st8" points="129.9,124.9 128.8,124.3 129.9,124.9 129.9,75 86.6,100 86.6,150 129.9,125 "/>
</g>
<g id="XMLID_122_">
<polygon id="XMLID_131_" class="st0" points="43.3,-75 0,-50 0,-0.5 43.3,-25.3 "/>
<polygon id="XMLID_130_" class="st1" points="43.3,-25.3 0,-0.5 0,0 43.3,25 86.6,0 43.3,-25 "/>
<polygon id="XMLID_129_" class="st2" points="43.3,-75 43.3,-25.3 45.4,-26.5 43.3,-25.3 43.3,-25 86.6,0 86.6,-50 "/>
<polygon id="XMLID_128_" class="st3" points="129.9,-75 129.9,-125 86.6,-150 86.6,-100 "/>
<polygon id="XMLID_127_" class="st4" points="86.6,-150 43.3,-125 43.3,-75 86.6,-100 "/>
<polygon id="XMLID_126_" class="st5" points="129.9,-75 86.6,-100 86.6,-98.2 86.6,-100 43.3,-75 86.6,-50 "/>
<polygon id="XMLID_125_" class="st6" points="173.2,-0.1 173.2,-50 129.9,-75 129.9,-25.1 "/>
<polygon id="XMLID_124_" class="st7" points="129.9,-25.1 129.9,-25 86.6,0 129.9,25 173.2,0 173.2,-0.1 "/>
<polygon id="XMLID_123_" class="st8" points="129.9,-25.1 128.8,-25.7 129.9,-25.1 129.9,-75 86.6,-50 86.6,0 129.9,-25 "/>
</g>
<g id="XMLID_2_">
<polygon id="XMLID_11_" class="st0" points="173.2,0 129.9,25 129.9,74.5 173.2,49.7 "/>
<polygon id="XMLID_10_" class="st1" points="173.2,49.7 129.9,74.5 129.9,75 173.2,100 216.5,75 173.2,50 "/>
<polygon id="XMLID_9_" class="st2" points="173.2,0 173.2,49.7 175.3,48.5 173.2,49.7 173.2,50 216.5,75 216.5,25 "/>
<polygon id="XMLID_8_" class="st3" points="259.8,0 259.8,-50 216.5,-75 216.5,-25 "/>
<polygon id="XMLID_7_" class="st4" points="216.5,-75 173.2,-50 173.2,0 216.5,-25 "/>
<polygon id="XMLID_6_" class="st5" points="259.8,0 216.5,-25 216.5,-23.2 216.5,-25 173.2,0 216.5,25 "/>
<polygon id="XMLID_5_" class="st6" points="303.1,74.9 303.1,25 259.8,0 259.8,49.9 "/>
<polygon id="XMLID_4_" class="st7" points="259.8,49.9 259.8,50 216.5,75 259.8,100 303.1,75 303.1,74.9 "/>
<polygon id="XMLID_3_" class="st8" points="259.8,49.9 258.7,49.3 259.8,49.9 259.8,0 216.5,25 216.5,75 259.8,50 "/>
</g>
<g id="XMLID_12_">
<polygon id="XMLID_21_" class="st0" points="43.3,224.5 0,249.5 0,299 43.3,274.3 "/>
<polygon id="XMLID_20_" class="st1" points="43.3,274.3 0,299 0,299.5 43.3,324.5 86.6,299.5 43.3,274.5 "/>
<polygon id="XMLID_19_" class="st2" points="43.3,224.5 43.3,274.3 45.4,273.1 43.3,274.3 43.3,274.5 86.6,299.5 86.6,249.5 "/>
<polygon id="XMLID_18_" class="st3" points="129.9,224.5 129.9,174.5 86.6,149.5 86.6,199.5 "/>
<polygon id="XMLID_17_" class="st4" points="86.6,149.5 43.3,174.5 43.3,224.5 86.6,199.5 "/>
<polygon id="XMLID_16_" class="st5" points="129.9,224.5 86.6,199.5 86.6,201.3 86.6,199.5 43.3,224.5 86.6,249.5 "/>
<polygon id="XMLID_15_" class="st6" points="173.2,299.5 173.2,249.5 129.9,224.5 129.9,274.4 "/>
<polygon id="XMLID_14_" class="st7" points="129.9,274.4 129.9,274.5 86.6,299.5 129.9,324.5 173.2,299.5 173.2,299.5 "/>
<polygon id="XMLID_13_" class="st8" points="129.9,274.4 128.8,273.8 129.9,274.4 129.9,224.5 86.6,249.5 86.6,299.5 129.9,274.5
"/>
</g>
<g id="XMLID_22_">
<polygon id="XMLID_31_" class="st0" points="-86.6,149.5 -129.9,174.5 -129.9,224 -86.6,199.3 "/>
<polygon id="XMLID_30_" class="st1" points="-86.6,199.3 -129.9,224 -129.9,224.5 -86.6,249.5 -43.3,224.5 -86.6,199.5 "/>
<polygon id="XMLID_29_" class="st2" points="-86.6,149.5 -86.6,199.3 -84.5,198.1 -86.6,199.3 -86.6,199.5 -43.3,224.5
-43.3,174.5 "/>
<polygon id="XMLID_28_" class="st3" points="0,149.5 0,99.5 -43.3,74.5 -43.3,124.5 "/>
<polygon id="XMLID_27_" class="st4" points="-43.3,74.5 -86.6,99.5 -86.6,149.5 -43.3,124.5 "/>
<polygon id="XMLID_26_" class="st5" points="0,149.5 -43.3,124.5 -43.3,126.3 -43.3,124.5 -86.6,149.5 -43.3,174.5 "/>
<polygon id="XMLID_25_" class="st6" points="43.3,224.5 43.3,174.5 0,149.5 0,199.4 "/>
<polygon id="XMLID_24_" class="st7" points="0,199.4 0,199.5 -43.3,224.5 0,249.5 43.3,224.5 43.3,224.5 "/>
<polygon id="XMLID_23_" class="st8" points="0,199.4 -1.1,198.8 0,199.4 0,149.5 -43.3,174.5 -43.3,224.5 0,199.5 "/>
</g>
<g id="XMLID_282_">
<polygon id="XMLID_291_" class="st0" points="-86.6,0 -129.9,25 -129.9,74.5 -86.6,49.8 "/>
<polygon id="XMLID_290_" class="st1" points="-86.6,49.8 -129.9,74.5 -129.9,75 -86.6,100 -43.3,75 -86.6,50 "/>
<polygon id="XMLID_289_" class="st2" points="-86.6,0 -86.6,49.8 -84.5,48.6 -86.6,49.8 -86.6,50 -43.3,75 -43.3,25 "/>
<polygon id="XMLID_288_" class="st3" points="0,0 0,-50 -43.3,-75 -43.3,-25 "/>
<polygon id="XMLID_287_" class="st4" points="-43.3,-75 -86.6,-50 -86.6,0 -43.3,-25 "/>
<polygon id="XMLID_286_" class="st5" points="0,0 -43.3,-25 -43.3,-23.2 -43.3,-25 -86.6,0 -43.3,25 "/>
<polygon id="XMLID_285_" class="st6" points="43.3,75 43.3,25 0,0 0,49.9 "/>
<polygon id="XMLID_284_" class="st7" points="0,49.9 0,50 -43.3,75 0,100 43.3,75 43.3,75 "/>
<polygon id="XMLID_283_" class="st8" points="0,49.9 -1.1,49.3 0,49.9 0,0 -43.3,25 -43.3,75 0,50 "/>
</g>
<g id="XMLID_272_">
<polygon id="XMLID_281_" class="st0" points="173.2,149.5 129.9,174.5 129.9,224 173.2,199.3 "/>
<polygon id="XMLID_280_" class="st1" points="173.2,199.3 129.9,224 129.9,224.5 173.2,249.5 216.5,224.5 173.2,199.5 "/>
<polygon id="XMLID_279_" class="st2" points="173.2,149.5 173.2,199.3 175.3,198.1 173.2,199.3 173.2,199.5 216.5,224.5
216.5,174.5 "/>
<polygon id="XMLID_278_" class="st3" points="259.8,149.5 259.8,99.5 216.5,74.5 216.5,124.5 "/>
<polygon id="XMLID_277_" class="st4" points="216.5,74.5 173.2,99.5 173.2,149.5 216.5,124.5 "/>
<polygon id="XMLID_276_" class="st5" points="259.8,149.5 216.5,124.5 216.5,126.3 216.5,124.5 173.2,149.5 216.5,174.5 "/>
<polygon id="XMLID_275_" class="st6" points="303.1,224.5 303.1,174.5 259.8,149.5 259.8,199.4 "/>
<polygon id="XMLID_274_" class="st7" points="259.8,199.4 259.8,199.5 216.5,224.5 259.8,249.5 303.1,224.5 303.1,224.5 "/>
<polygon id="XMLID_273_" class="st8" points="259.8,199.4 258.7,198.8 259.8,199.4 259.8,149.5 216.5,174.5 216.5,224.5
259.8,199.5 "/>
</g>
<g id="XMLID_102_">
<polygon id="XMLID_111_" class="st0" points="433,0 389.7,25 389.7,74.5 433,49.8 "/>
<polygon id="XMLID_110_" class="st1" points="433,49.8 389.7,74.5 389.7,75 433,100 476.3,75 433,50 "/>
<polygon id="XMLID_109_" class="st2" points="433,0 433,49.8 435.1,48.6 433,49.8 433,50 476.3,75 476.3,25 "/>
<polygon id="XMLID_108_" class="st3" points="519.6,0 519.6,-50 476.3,-75 476.3,-25 "/>
<polygon id="XMLID_107_" class="st4" points="476.3,-75 433,-50 433,0 476.3,-25 "/>
<polygon id="XMLID_106_" class="st5" points="519.6,0 476.3,-25 476.3,-23.2 476.3,-25 433,0 476.3,25 "/>
<polygon id="XMLID_105_" class="st6" points="562.9,75 562.9,25 519.6,0 519.6,49.9 "/>
<polygon id="XMLID_104_" class="st7" points="519.6,49.9 519.6,50 476.3,75 519.6,100 562.9,75 562.9,75 "/>
<polygon id="XMLID_103_" class="st8" points="519.6,49.9 518.5,49.3 519.6,49.9 519.6,0 476.3,25 476.3,75 519.6,50 "/>
</g>
<g id="XMLID_82_">
<polygon id="XMLID_91_" class="st0" points="562.9,-75 519.6,-50 519.6,-0.5 562.9,-25.3 "/>
<polygon id="XMLID_90_" class="st1" points="562.9,-25.3 519.6,-0.5 519.6,0 562.9,25 606.2,0 562.9,-25 "/>
<polygon id="XMLID_89_" class="st2" points="562.9,-75 562.9,-25.3 565,-26.5 562.9,-25.3 562.9,-25 606.2,0 606.2,-50 "/>
<polygon id="XMLID_88_" class="st3" points="649.5,-75 649.5,-125 606.2,-150 606.2,-100 "/>
<polygon id="XMLID_87_" class="st4" points="606.2,-150 562.9,-125 562.9,-75 606.2,-100 "/>
<polygon id="XMLID_86_" class="st5" points="649.5,-75 606.2,-100 606.2,-98.2 606.2,-100 562.9,-75 606.2,-50 "/>
<polygon id="XMLID_85_" class="st6" points="692.8,-0.1 692.8,-50 649.5,-75 649.5,-25.1 "/>
<polygon id="XMLID_84_" class="st7" points="649.5,-25.1 649.5,-25 606.2,0 649.5,25 692.8,0 692.8,-0.1 "/>
<polygon id="XMLID_83_" class="st8" points="649.5,-25.1 648.4,-25.7 649.5,-25.1 649.5,-75 606.2,-50 606.2,0 649.5,-25 "/>
</g>
<g id="XMLID_72_">
<polygon id="XMLID_81_" class="st0" points="433,149.5 389.7,174.5 389.7,224 433,199.3 "/>
<polygon id="XMLID_80_" class="st1" points="433,199.3 389.7,224 389.7,224.5 433,249.5 476.3,224.5 433,199.5 "/>
<polygon id="XMLID_79_" class="st2" points="433,149.5 433,199.3 435.1,198.1 433,199.3 433,199.5 476.3,224.5 476.3,174.5 "/>
<polygon id="XMLID_78_" class="st3" points="519.6,149.5 519.6,99.5 476.3,74.5 476.3,124.5 "/>
<polygon id="XMLID_77_" class="st4" points="476.3,74.5 433,99.5 433,149.5 476.3,124.5 "/>
<polygon id="XMLID_76_" class="st5" points="519.6,149.5 476.3,124.5 476.3,126.3 476.3,124.5 433,149.5 476.3,174.5 "/>
<polygon id="XMLID_75_" class="st6" points="562.9,224.5 562.9,174.5 519.6,149.5 519.6,199.4 "/>
<polygon id="XMLID_74_" class="st7" points="519.6,199.4 519.6,199.5 476.3,224.5 519.6,249.5 562.9,224.5 562.9,224.5 "/>
<polygon id="XMLID_73_" class="st8" points="519.6,199.4 518.5,198.8 519.6,199.4 519.6,149.5 476.3,174.5 476.3,224.5
519.6,199.5 "/>
</g>
<g id="XMLID_62_">
<polygon id="XMLID_71_" class="st0" points="303.1,74.5 259.8,99.5 259.8,149 303.1,124.3 "/>
<polygon id="XMLID_70_" class="st1" points="303.1,124.3 259.8,149 259.8,149.5 303.1,174.5 346.4,149.5 303.1,124.5 "/>
<polygon id="XMLID_69_" class="st2" points="303.1,74.5 303.1,124.3 305.2,123.1 303.1,124.3 303.1,124.5 346.4,149.5 346.4,99.5
"/>
<polygon id="XMLID_68_" class="st3" points="389.7,74.5 389.7,24.5 346.4,-0.5 346.4,49.5 "/>
<polygon id="XMLID_67_" class="st4" points="346.4,-0.5 303.1,24.5 303.1,74.5 346.4,49.5 "/>
<polygon id="XMLID_66_" class="st5" points="389.7,74.5 346.4,49.5 346.4,51.3 346.4,49.5 303.1,74.5 346.4,99.5 "/>
<polygon id="XMLID_65_" class="st6" points="433,149.5 433,99.5 389.7,74.5 389.7,124.4 "/>
<polygon id="XMLID_64_" class="st7" points="389.7,124.4 389.7,124.5 346.4,149.5 389.7,174.5 433,149.5 433,149.5 "/>
<polygon id="XMLID_63_" class="st8" points="389.7,124.4 388.6,123.8 389.7,124.4 389.7,74.5 346.4,99.5 346.4,149.5 389.7,124.5
"/>
</g>
<g id="XMLID_52_">
<polygon id="XMLID_61_" class="st0" points="303.1,-75 259.8,-50 259.8,-0.5 303.1,-25.2 "/>
<polygon id="XMLID_60_" class="st1" points="303.1,-25.2 259.8,-0.5 259.8,0 303.1,25 346.4,0 303.1,-25 "/>
<polygon id="XMLID_59_" class="st2" points="303.1,-75 303.1,-25.2 305.2,-26.4 303.1,-25.2 303.1,-25 346.4,0 346.4,-50 "/>
<polygon id="XMLID_58_" class="st3" points="389.7,-75 389.7,-125 346.4,-150 346.4,-100 "/>
<polygon id="XMLID_57_" class="st4" points="346.4,-150 303.1,-125 303.1,-75 346.4,-100 "/>
<polygon id="XMLID_56_" class="st5" points="389.7,-75 346.4,-100 346.4,-98.2 346.4,-100 303.1,-75 346.4,-50 "/>
<polygon id="XMLID_55_" class="st6" points="433,0 433,-50 389.7,-75 389.7,-25.1 "/>
<polygon id="XMLID_54_" class="st7" points="389.7,-25.1 389.7,-25 346.4,0 389.7,25 433,0 433,0 "/>
<polygon id="XMLID_53_" class="st8" points="389.7,-25.1 388.6,-25.7 389.7,-25.1 389.7,-75 346.4,-50 346.4,0 389.7,-25 "/>
</g>
<g id="XMLID_42_">
<polygon id="XMLID_51_" class="st0" points="562.9,74.5 519.6,99.5 519.6,149 562.9,124.3 "/>
<polygon id="XMLID_50_" class="st1" points="562.9,124.3 519.6,149 519.6,149.5 562.9,174.5 606.2,149.5 562.9,124.5 "/>
<polygon id="XMLID_49_" class="st2" points="562.9,74.5 562.9,124.3 565,123.1 562.9,124.3 562.9,124.5 606.2,149.5 606.2,99.5
"/>
<polygon id="XMLID_48_" class="st3" points="649.5,74.5 649.5,24.5 606.2,-0.5 606.2,49.5 "/>
<polygon id="XMLID_47_" class="st4" points="606.2,-0.5 562.9,24.5 562.9,74.5 606.2,49.5 "/>
<polygon id="XMLID_46_" class="st5" points="649.5,74.5 606.2,49.5 606.2,51.3 606.2,49.5 562.9,74.5 606.2,99.5 "/>
<polygon id="XMLID_45_" class="st6" points="692.8,149.5 692.8,99.5 649.5,74.5 649.5,124.4 "/>
<polygon id="XMLID_44_" class="st7" points="649.5,124.4 649.5,124.5 606.2,149.5 649.5,174.5 692.8,149.5 692.8,149.5 "/>
<polygon id="XMLID_43_" class="st8" points="649.5,124.4 648.4,123.8 649.5,124.4 649.5,74.5 606.2,99.5 606.2,149.5 649.5,124.5
"/>
</g>
<g id="XMLID_182_">
<polygon id="XMLID_191_" class="st0" points="303.1,375 259.8,400 259.8,449.6 303.1,424.8 "/>
<polygon id="XMLID_190_" class="st1" points="303.1,424.8 259.8,449.6 259.8,450 303.1,475 346.4,450 303.1,425 "/>
<polygon id="XMLID_189_" class="st2" points="303.1,375 303.1,424.8 305.2,423.6 303.1,424.8 303.1,425 346.4,450 346.4,400 "/>
<polygon id="XMLID_188_" class="st3" points="389.7,375 389.7,325 346.4,300 346.4,350 "/>
<polygon id="XMLID_187_" class="st4" points="346.4,300 303.1,325 303.1,375 346.4,350 "/>
<polygon id="XMLID_186_" class="st5" points="389.7,375 346.4,350 346.4,351.8 346.4,350 303.1,375 346.4,400 "/>
<polygon id="XMLID_185_" class="st6" points="433,450 433,400 389.7,375 389.7,425 "/>
<polygon id="XMLID_184_" class="st7" points="389.7,425 389.7,425 346.4,450 389.7,475 433,450 433,450 "/>
<polygon id="XMLID_183_" class="st8" points="389.7,425 388.6,424.3 389.7,425 389.7,375 346.4,400 346.4,450 389.7,425 "/>
</g>
<g id="XMLID_172_">
<polygon id="XMLID_181_" class="st0" points="303.1,225 259.8,250 259.8,299.5 303.1,274.8 "/>
<polygon id="XMLID_180_" class="st1" points="303.1,274.8 259.8,299.5 259.8,300 303.1,325 346.4,300 303.1,275 "/>
<polygon id="XMLID_179_" class="st2" points="303.1,225 303.1,274.8 305.2,273.6 303.1,274.8 303.1,275 346.4,300 346.4,250 "/>
<polygon id="XMLID_178_" class="st3" points="389.7,225 389.7,175 346.4,150 346.4,200 "/>
<polygon id="XMLID_177_" class="st4" points="346.4,150 303.1,175 303.1,225 346.4,200 "/>
<polygon id="XMLID_176_" class="st5" points="389.7,225 346.4,200 346.4,201.8 346.4,200 303.1,225 346.4,250 "/>
<polygon id="XMLID_175_" class="st6" points="433,300 433,250 389.7,225 389.7,274.9 "/>
<polygon id="XMLID_174_" class="st7" points="389.7,274.9 389.7,275 346.4,300 389.7,325 433,300 433,300 "/>
<polygon id="XMLID_173_" class="st8" points="389.7,274.9 388.6,274.3 389.7,274.9 389.7,225 346.4,250 346.4,300 389.7,275 "/>
</g>
<g id="XMLID_162_">
<polygon id="XMLID_171_" class="st0" points="433,300 389.7,325 389.7,374.5 433,349.8 "/>
<polygon id="XMLID_170_" class="st1" points="433,349.8 389.7,374.5 389.7,375 433,400 476.3,375 433,350 "/>
<polygon id="XMLID_169_" class="st2" points="433,300 433,349.8 435.1,348.6 433,349.8 433,350 476.3,375 476.3,325 "/>
<polygon id="XMLID_168_" class="st3" points="519.6,300 519.6,250 476.3,225 476.3,275 "/>
<polygon id="XMLID_167_" class="st4" points="476.3,225 433,250 433,300 476.3,275 "/>
<polygon id="XMLID_166_" class="st5" points="519.6,300 476.3,275 476.3,276.8 476.3,275 433,300 476.3,325 "/>
<polygon id="XMLID_165_" class="st6" points="562.9,375 562.9,325 519.6,300 519.6,349.9 "/>
<polygon id="XMLID_164_" class="st7" points="519.6,349.9 519.6,350 476.3,375 519.6,400 562.9,375 562.9,375 "/>
<polygon id="XMLID_163_" class="st8" points="519.6,349.9 518.5,349.3 519.6,349.9 519.6,300 476.3,325 476.3,375 519.6,350 "/>
</g>
<g id="XMLID_152_">
<polygon id="XMLID_161_" class="st0" points="303.1,524.5 259.8,549.5 259.8,599.1 303.1,574.3 "/>
<polygon id="XMLID_160_" class="st1" points="303.1,574.3 259.8,599.1 259.8,599.5 303.1,624.5 346.4,599.5 303.1,574.5 "/>
<polygon id="XMLID_159_" class="st2" points="303.1,524.5 303.1,574.3 305.2,573.1 303.1,574.3 303.1,574.5 346.4,599.5
346.4,549.5 "/>
<polygon id="XMLID_158_" class="st3" points="389.7,524.5 389.7,474.5 346.4,449.5 346.4,499.5 "/>
<polygon id="XMLID_157_" class="st4" points="346.4,449.5 303.1,474.5 303.1,524.5 346.4,499.5 "/>
<polygon id="XMLID_156_" class="st5" points="389.7,524.5 346.4,499.5 346.4,501.3 346.4,499.5 303.1,524.5 346.4,549.5 "/>
<polygon id="XMLID_155_" class="st6" points="433,599.5 433,549.5 389.7,524.5 389.7,574.5 "/>
<polygon id="XMLID_154_" class="st7" points="389.7,574.5 389.7,574.5 346.4,599.5 389.7,624.5 433,599.5 433,599.5 "/>
<polygon id="XMLID_153_" class="st8" points="389.7,574.5 388.6,573.8 389.7,574.5 389.7,524.5 346.4,549.5 346.4,599.5
389.7,574.5 "/>
</g>
<g id="XMLID_142_">
<polygon id="XMLID_151_" class="st0" points="173.2,449.5 129.9,474.5 129.9,524.1 173.2,499.3 "/>
<polygon id="XMLID_150_" class="st1" points="173.2,499.3 129.9,524.1 129.9,524.5 173.2,549.5 216.5,524.5 173.2,499.5 "/>
<polygon id="XMLID_149_" class="st2" points="173.2,449.5 173.2,499.3 175.3,498.1 173.2,499.3 173.2,499.5 216.5,524.5
216.5,474.5 "/>
<polygon id="XMLID_148_" class="st3" points="259.8,449.5 259.8,399.5 216.5,374.5 216.5,424.5 "/>
<polygon id="XMLID_147_" class="st4" points="216.5,374.5 173.2,399.5 173.2,449.5 216.5,424.5 "/>
<polygon id="XMLID_146_" class="st5" points="259.8,449.5 216.5,424.5 216.5,426.3 216.5,424.5 173.2,449.5 216.5,474.5 "/>
<polygon id="XMLID_145_" class="st6" points="303.1,524.5 303.1,474.5 259.8,449.5 259.8,499.5 "/>
<polygon id="XMLID_144_" class="st7" points="259.8,499.5 259.8,499.5 216.5,524.5 259.8,549.5 303.1,524.5 303.1,524.5 "/>
<polygon id="XMLID_143_" class="st8" points="259.8,499.5 258.7,498.8 259.8,499.5 259.8,449.5 216.5,474.5 216.5,524.5
259.8,499.5 "/>
</g>
<g id="XMLID_132_">
<polygon id="XMLID_141_" class="st0" points="173.2,300 129.9,325 129.9,374.6 173.2,349.8 "/>
<polygon id="XMLID_140_" class="st1" points="173.2,349.8 129.9,374.6 129.9,375 173.2,400 216.5,375 173.2,350 "/>
<polygon id="XMLID_139_" class="st2" points="173.2,300 173.2,349.8 175.3,348.6 173.2,349.8 173.2,350 216.5,375 216.5,325 "/>
<polygon id="XMLID_138_" class="st3" points="259.8,300 259.8,250 216.5,225 216.5,275 "/>
<polygon id="XMLID_137_" class="st4" points="216.5,225 173.2,250 173.2,300 216.5,275 "/>
<polygon id="XMLID_136_" class="st5" points="259.8,300 216.5,275 216.5,276.8 216.5,275 173.2,300 216.5,325 "/>
<polygon id="XMLID_135_" class="st6" points="303.1,375 303.1,325 259.8,300 259.8,350 "/>
<polygon id="XMLID_134_" class="st7" points="259.8,350 259.8,350 216.5,375 259.8,400 303.1,375 303.1,375 "/>
<polygon id="XMLID_133_" class="st8" points="259.8,350 258.7,349.3 259.8,350 259.8,300 216.5,325 216.5,375 259.8,350 "/>
</g>
<g id="XMLID_112_">
<polygon id="XMLID_121_" class="st0" points="433,449.5 389.7,474.5 389.7,524.1 433,499.3 "/>
<polygon id="XMLID_120_" class="st1" points="433,499.3 389.7,524.1 389.7,524.5 433,549.5 476.3,524.5 433,499.5 "/>
<polygon id="XMLID_119_" class="st2" points="433,449.5 433,499.3 435.1,498.1 433,499.3 433,499.5 476.3,524.5 476.3,474.5 "/>
<polygon id="XMLID_118_" class="st3" points="519.6,449.5 519.6,399.5 476.3,374.5 476.3,424.5 "/>
<polygon id="XMLID_117_" class="st4" points="476.3,374.5 433,399.5 433,449.5 476.3,424.5 "/>
<polygon id="XMLID_116_" class="st5" points="519.6,449.5 476.3,424.5 476.3,426.3 476.3,424.5 433,449.5 476.3,474.5 "/>
<polygon id="XMLID_115_" class="st6" points="562.9,524.5 562.9,474.5 519.6,449.5 519.6,499.5 "/>
<polygon id="XMLID_114_" class="st7" points="519.6,499.5 519.6,499.5 476.3,524.5 519.6,549.5 562.9,524.5 562.9,524.5 "/>
<polygon id="XMLID_113_" class="st8" points="519.6,499.5 518.5,498.8 519.6,499.5 519.6,449.5 476.3,474.5 476.3,524.5
519.6,499.5 "/>
</g>
<g id="XMLID_252_">
<polygon id="XMLID_261_" class="st0" points="-86.6,449.5 -129.9,474.5 -129.9,524.1 -86.6,499.3 "/>
<polygon id="XMLID_260_" class="st1" points="-86.6,499.3 -129.9,524.1 -129.9,524.5 -86.6,549.5 -43.3,524.5 -86.6,499.5 "/>
<polygon id="XMLID_259_" class="st2" points="-86.6,449.5 -86.6,499.3 -84.5,498.1 -86.6,499.3 -86.6,499.5 -43.3,524.5
-43.3,474.5 "/>
<polygon id="XMLID_258_" class="st3" points="0,449.5 0,399.5 -43.3,374.5 -43.3,424.5 "/>
<polygon id="XMLID_257_" class="st4" points="-43.3,374.5 -86.6,399.5 -86.6,449.5 -43.3,424.5 "/>
<polygon id="XMLID_256_" class="st5" points="0,449.5 -43.3,424.5 -43.3,426.3 -43.3,424.5 -86.6,449.5 -43.3,474.5 "/>
<polygon id="XMLID_255_" class="st6" points="43.3,524.5 43.3,474.5 0,449.5 0,499.5 "/>
<polygon id="XMLID_254_" class="st7" points="0,499.5 0,499.5 -43.3,524.5 0,549.5 43.3,524.5 43.3,524.5 "/>
<polygon id="XMLID_253_" class="st8" points="0,499.5 -1.1,498.8 0,499.5 0,449.5 -43.3,474.5 -43.3,524.5 0,499.5 "/>
</g>
</svg>
1 个解决方案
#1
2
It looks like the polygons have unique ids? For example: XMLID_121_
看起来多边形有独特的ID?例如:XMLID_121_
If so, maybe you could do something like this: 1) Put all of the polygon ids in an array 2) randomly visit a location in the array 3) do something with the element in that array location ("visit the polygon with that id", etc.) 4) extract the visited array element from the array 5) keep doing this until there are no elements left in the id array.
如果是这样,也许你可以做这样的事情:1)将所有的多边形id放在一个数组中2)随机访问数组中的一个位置3)用该数组位置中的元素做一些事情(“访问带有该id的多边形“等等)4)从数组中提取被访问数组元素5)继续这样做直到id数组中没有剩余元素。
Here is a simple JavaScript program to that effect:
这是一个简单的JavaScript程序:
var polygonIds = [1, 2, 3, 4, 5]; //the order doesn't matter
while (polygonIds.length > 0) { //repeat until no more elements left
var position = Math.floor(Math.random() * polygonIds.length); //choose random location
var extracted = polygonIds[position]; //get that element
alert(extracted); //do whatever you want to do with the extracted element
polygonIds.splice(position, 1); //remove the element from array
}
Maybe there is a better way to do this. But it seems reasonable, and it looks like you are using JavaScript. So something like this might work for you.
也许有更好的方法来做到这一点。但它看似合理,看起来你正在使用JavaScript。所以这样的事情可能适合你。
#1
2
It looks like the polygons have unique ids? For example: XMLID_121_
看起来多边形有独特的ID?例如:XMLID_121_
If so, maybe you could do something like this: 1) Put all of the polygon ids in an array 2) randomly visit a location in the array 3) do something with the element in that array location ("visit the polygon with that id", etc.) 4) extract the visited array element from the array 5) keep doing this until there are no elements left in the id array.
如果是这样,也许你可以做这样的事情:1)将所有的多边形id放在一个数组中2)随机访问数组中的一个位置3)用该数组位置中的元素做一些事情(“访问带有该id的多边形“等等)4)从数组中提取被访问数组元素5)继续这样做直到id数组中没有剩余元素。
Here is a simple JavaScript program to that effect:
这是一个简单的JavaScript程序:
var polygonIds = [1, 2, 3, 4, 5]; //the order doesn't matter
while (polygonIds.length > 0) { //repeat until no more elements left
var position = Math.floor(Math.random() * polygonIds.length); //choose random location
var extracted = polygonIds[position]; //get that element
alert(extracted); //do whatever you want to do with the extracted element
polygonIds.splice(position, 1); //remove the element from array
}
Maybe there is a better way to do this. But it seems reasonable, and it looks like you are using JavaScript. So something like this might work for you.
也许有更好的方法来做到这一点。但它看似合理,看起来你正在使用JavaScript。所以这样的事情可能适合你。