void(),
количество ножек "паучка" можно указать в строке 121
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
html, body{
height: 100%;
}
body{
position: relative;
background-color: #FFD700;
}
hr.connection{
position: absolute;
width: 0px;
height: 1px;
background-color: #00008B;
padding: 0;
margin: 0;
z-index: 2;
}
.one {
background-color: #A0522D;
position: absolute;
width: 5px;
height: 5px;
border-radius: 50%;
}
.two{
border-radius: 8px;
border: 6px solid #006400;
position: absolute;
top: 30%;
left: 50%;
background-color: #228B22;
z-index: 1;
width: 128px;
height: 128px;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script>
(function($) {
$.fn.connectionItem = function(options) {
var defaults = {
num: 5
};
var settings = $.extend({}, defaults, options);
var elems = $(this).get();
var num = Math.min(settings.num, elems.length);
var line = $.map(Array(num), function(indx, element) {
var hr = $("<hr/>", {
"class": "connection",
css: {
position: "absolute"
}
}).appendTo("body");
hr.css("transform-origin", 0);
hr.css("-moz-transform-origin", 0);
hr.css("-webkit-transform-origin", 0);
hr.css("-o-transform-origin", 0);
return hr
});
function extraction(event) {
var k = elems.map(function(el) {
var x0,
y0, x, y, x1, y1, r, w, pos;
pos = $(el).offset();
x0 = pos.left - 6;
y0 = pos.top - 6;
x1 = event.pageX - 8;
y1 = event.pageY - 8;
x = x1 - x0;
y = y1 - y0;
w = Math.sqrt(x * x + y * y);
r = 180 - 180 / Math.PI * Math.atan2(y, x);
return {
left: x1,
top: y1,
width: w,
transform: "rotate(-" + r + "deg)"
}
}).sort(function(a, b) {
return a.width - b.width
}).slice(0, num).forEach(function(css, i) {
line[i].css(css)
})
}
$(document).on({
mousemove: extraction
});
return this
}
})(jQuery);
$(function(){
function rand(a) {
return 5 + Math.floor(Math.random() * a)
}
$.each(Array(47),function(indx, element){
$('<div>',{css : {top : rand(80)+"%",left : rand(80)+"%"} , "class" : "one"})
.appendTo('body')
});
$(".one").connectionItem({num : 6});//
});
</script>
</head>
<body>
</body>
</html>