javascript - Draw several Numbers around a circle -
as per below fiddle, tried draw number circle , want circle start 0 @ top , how can achieve behaviour.
also want connect numbers inner circle border number dotted line, how can draw dotted line
http://jsfiddle.net/ineffablep/x03f61db/
function createfields() { $('.field').remove(); var container = $('#container'); for(var = 0; < +$('input:text').val()+1; i++) { $('<div/>', { 'class': 'field', 'text': }).appendto(container); } } function distributefields() { var fields = $('.field'), container = $('#container'), width = center.width()*2, height = center.height()*2, angle = 0, step = (2*math.pi) / fields.length; var radius = width/2; var containerlength=$('input:text').val(); angle=step* (containerlength-1); fields.each(function() { var x = math.round(width + radius * math.cos(angle)); var y = math.round(height + radius * math.sin(angle)); $(this).css({ right: x + 'px', top: y + 'px' }); angle -= step; }); } var center = $('#center'); $(window).resize(function(height) { $('#container').width($(window).height()*0.9) $('#container').height($(window).height()*0.9) var width = $('#container').width() * 0.4; console.log("width",$('#container').width()); console.log("height",$('#container').height()); var radius = width/2; width += 'px'; radius += 'px'; center.css({ width: width, height: width, '-moz-border-radius' : radius, '-webkit-border-radius' : radius, 'border-radius' : radius }); createfields(); distributefields(); // rest of code font-size setting etc.. }); $(window).resize(); $('input').change(function() { createfields(); distributefields(); });
your initial angle must changed.
angle = -90*math.pi/180; // (deg) * [math.pi/180 == rad deg] //we have provide values in radians, convert our degrees radians
Comments
Post a Comment