Browse Source

3.14159265

master
quegzacov 2 years ago
parent
commit
e163e9daf9
  1. 2
      index.php
  2. 10
      script.js

2
index.php

@ -4,7 +4,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<title>Roulette à eau</title> <title>Roulette à eau</title>
<script type="text/javascript" src="script.js" defer></script> <script type="text/javascript" src="script.js"></script>
</head> </head>
<body> <body>
<code> <code>

10
script.js

@ -1,8 +1,8 @@
function draw_roulette(ctx, w, h, datalist){ function draw_roulette(ctx, w, h, datalist){
var radius = h / 2 - 5; var radius = h / 2 - 5;
var center = new Array(w / 2, h / 2); var center = new Array(w / 2, h / 2);
var total = 0; var init = 0;
var sum = datalist.reduce((acc, value) => acc + value, total); var total = datalist.reduce((acc, value) => acc + value, init);
var lastend = 0; var lastend = 0;
var offset = Math.PI / 2; var offset = Math.PI / 2;
for (i=0; i < datalist.length; i++){ for (i=0; i < datalist.length; i++){
@ -19,9 +19,3 @@ function draw_roulette(ctx, w, h, datalist){
lastend += arcsector; lastend += arcsector;
} }
} }
var datalist= new Array(35, 25, 20, 12, 7, 1);
var colist = new Array('blue', 'red', 'green', 'orange', 'gray', 'yellow');
var canvas = document.getElementById("roulette");
var rendu = canvas.getContext('2d');
draw_roulette(rendu, canvas.width, canvas.height, datalist);

Loading…
Cancel
Save