From 3e92c6bceb70e16268673ca56e14e3072537e6e5 Mon Sep 17 00:00:00 2001 From: quegzacov Date: Wed, 28 Dec 2022 12:46:00 +0100 Subject: [PATCH] 3.141592653589793238462643 --- index.php | 2 +- script.js | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/index.php b/index.php index c111cf5..f62f7ab 100755 --- a/index.php +++ b/index.php @@ -20,7 +20,7 @@ var_dump($res); diff --git a/script.js b/script.js index 43c3b3b..4f8438e 100755 --- a/script.js +++ b/script.js @@ -1,16 +1,24 @@ -function draw_roulette(nb_person, x, y, r){ +function draw_roulette(nb_person, x, y, r, names){ let chart = document.getElementById("roulette").querySelector('g'); - let starting_coo= new Array(x, y + r); + let starting_coo = new Array(x, y + r); + let text_coo = starting_coo; let center = new Array(x + r, y + r); let angle = 0; for (let i=0; i < nb_person; i++){ let coo_arr = new Array(center[0] - r * Math.cos(2 * Math.PI / nb_person * (i+1)), center[1] - r * Math.sin(2 * Math.PI / nb_person * (i+1))); let new_path = document.createElement("path"); new_path.setAttribute('fill', 'green'); - new_path.setAttribute('d', "M " + starting_coo[0] + " " + starting_coo[1] + " A " + r + " " + r " 0 0 1 " + coo_arr[0] + " " + coo_arr[1] + " L " + center[0] + " " + center[1] + " Z"); + new_path.setAttribute('d', "M " + starting_coo[0] + " " + starting_coo[1] + " A " + r + " " + r + " 0 0 1 " + coo_arr[0] + " " + coo_arr[1] + " L " + center[0] + " " + center[1] + " Z"); + + let text = document.createElement("text"); + text.innerTEXT = names[i]; + text.setAttribute("transform", "rotate("+(-360)/nb_person+", "+center[0]+", "+center[1]+")"); + chart.appendChild(new_path); + chart.appendChild(text); chart.innerHTML += ' '; + console.log(new_path.getAttribute('d')); starting_coo = coo_arr