Browse Source

3.14159265358979323846

master
quegzacov 2 years ago
parent
commit
25185446e0
  1. 2
      index.php
  2. 7
      script.js

2
index.php

@ -20,7 +20,7 @@ var_dump($res);
<g stroke="black" stroke-width=2></g> <g stroke="black" stroke-width=2></g>
</svg> </svg>
<script type="text/javascript"> <script type="text/javascript">
draw_roulette(3, 200, 200); draw_roulette(3, 200, 200, 200);
</script> </script>
</body> </body>
</html> </html>

7
script.js

@ -1,10 +1,11 @@
function draw_roulette(nb_person, x, y){ function draw_roulette(nb_person, x, y, r){
let chart = document.getElementById("roulette").querySelector('g')[0]; let chart = document.getElementById("roulette").querySelector('g');
let starting_coo= new Array(x, y); let starting_coo= new Array(x, y);
let center = new Array(x + r, y + r);
let angle = 0; let angle = 0;
for (let i=0; i < nb_person; i++){ for (let i=0; i < nb_person; i++){
let coo_arr = new Array(250 - 50 * Math.cos(2 * Math.PI / nb_person * (i+1)), 200 - 50 * Math.sin(2 * Math.PI / nb_person * (i+1))); let coo_arr = new Array(center[0] - r * Math.cos(2 * Math.PI / nb_person * (i+1)), center[y] - r * Math.sin(2 * Math.PI / nb_person * (i+1)));
let new_path = document.createElement("path"); let new_path = document.createElement("path");
new_path.setAttribute('fill', 'green'); new_path.setAttribute('fill', 'green');
new_path.setAttribute('d', "M " + starting_coo[0] + " " + starting_coo[1] + " A 50 50 0 0 1 " + coo_arr[0] + " " + coo_arr[1] + " L 250 200 Z"); new_path.setAttribute('d', "M " + starting_coo[0] + " " + starting_coo[1] + " A 50 50 0 0 1 " + coo_arr[0] + " " + coo_arr[1] + " L 250 200 Z");

Loading…
Cancel
Save