$(function () {
/* add onchange listener */
$("#NoOfCircles").change(function () {
/* get the value in the textbox */
var noOfCircles = $("#NoOfCircles").val();
/* equally divide 360 by the no of circles to be drawn */
var degreeAngle = 360 / noOfCircles;
/* get handle on the wrapper canvas */
var wrapper = $(".circle-container");
/* clear it first */
wrapper.html("");
/* initialize angle incrementer variable */
var currAngle = 0;
/* draw each circle at the specified angle */
for (var i = 0; i < noOfCircles; i++) {
/* add to the wrapper */
wrapper.append(getDiv(currAngle));
/* increment the angle incrementer */
currAngle = currAngle + degreeAngle;
}
});
/*
Function returns a new DIV with the angles translation using CSS.
It also applies a random color for fun.
stole the CSS from :http://stackoverflow.com/questions/12813573/position-icons-into-circle
*/
function getDiv(currAngle) {
if(currAngle == 0) {
return "<div class='circle' style='transform: rotate(" + currAngle + "deg) translate(6em) rotate(-" + currAngle + "deg);background-color:" + "'><img src='https://i1.wp.com/visualcppconcepts.files.wordpress.com/2015/12/rsz_file-page67.jpg?w=450'></div>"
}
if(currAngle == 90) {
return "<div class='circle' style='transform: rotate(" + currAngle + "deg) translate(6em) rotate(-" + currAngle + "deg);background-color:" + "'><img src='https://i1.wp.com/visualcppconcepts.files.wordpress.com/2015/12/rsz_file-page52.jpg?w=450'></div>"
}
if(currAngle == 180) {
return "<div class='circle' style='transform: rotate(" + currAngle + "deg) translate(6em) rotate(-" + currAngle + "deg);background-color:" + "'><img...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.