JSFiddle - React, Tailwind, and code Playground
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/dot-luv/jquery-ui.css">
<canvas id="canv"></canvas>
CSS
canvas { border: solid 1px #ddd; }
JavaScript
function circ (cv, x, y, r) {
cv.beginPath ();
cv.arc (x, y, r, 0, Math.PI*2, true);
cv.closePath ();
cv.stroke ();
}
function BoxMuller ()
{
var u1 = Math.random ();
var u2 = Math.random ();
var g = new Array (Math.sqrt (-2*Math.log (u1))*Math.cos (2*Math.PI*u2), Math.sqrt (-2*Math.log (u1))*Math.sin (2*Math.PI*u2));
return g;
}
function hyperbol (cv, x, y, r) {
cv.beginPath();
for (var i = x-r,j=y; i <= x; i++,j++){
cv.moveTo(i,y);
cv.lineTo(x,j);
}
for (var i = x+r,j=y; i >= x; i--,j++){
cv.moveTo(i,y);
cv.lineTo(x,j);
}
for (var i = x-r,j=y; i <= x; i++,j--){
cv.moveTo(i,y);
cv.lineTo(x,j);
}
for (var i = x+r,j=y; i >= x; i--,j--){
cv.moveTo(i,y);
cv.lineTo(x,j);
}
cv.closePath();
cv.stroke();
}
function circlesBG (cv, col, wd, hg) {
cv.fillStyle = col;
cv.strokeStyle = col;
var x1, y1, r1, x2, y2, r2, g;
var i = 0;
for (i = 0; i < 600; i++) {
g = BoxMuller ();
x1 = Math.random () * wd;
//x2 = Math.random () * 1600;
y1 = Math.random () * hg;
//y2 = Math.random () * 1000;
r1 = g[0] * g[0] * 5;
//r2 = g[1] * g[1] * 5;
hyperbol(cv, x1, y1, r1);
//hyperbol(cv, x2, y2, r2);
}
}
$(document).ready (function () {
$("#cont").load ("cont.php");
var cv = $('#canv')[0].getContext("2d");
var col = "#2c2c2c";
alert (screen.availWidth+' '+screen.availHeight);
circlesBG (cv, col, screen.availWidth, screen.availHeight);
$('#canv').width(screen.availWidth);
$('#canv').height(screen.availHeight);
//cv.setAttribute('width',screen.availWidth);
//cv.setAttribute('height',screen.availHeight);
//cv.css('width',(screen.availWidth*3));
//cv.css('height',(screen.availHeight*3));
//cv.width = screen.availWidth();
//cv.height = screen.availHeight();
$("#lnav a").click (function...