JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<title>Functional programming - test0001.</title>
<link rel='stylesheet' type='text/css' href='style.css'>
</head>
<body>
<form id='formParameters'>
<input type='checkbox' id='x' name='x' checked=checked><label for='x'>Rotate X</label>
<input type='checkbox' id='y' name='y'><label for='y'>Rotate Y</label>
<input type='checkbox' id='z' name='z' checked=checked><label for='z'>Rotate Z</label>
<input type='number' id='s' name='s' min=1 max=250 value=10><label for='s'>Scale</label>
</form>
<canvas id="screen"></canvas>
</body>
<script src='graph.js'></script>
<script src='scene.js'></script>
<script src='script.js'></script>
</html>
CSS
body{
background:#000;
color:#bbeedd;
font-sise:14px;
font-family:verdana;
padding:0px;
margin:0px;
border:0px;
text-align:center;
}
#screen{
margin-top:20px;
background:#222;
}
#formParameters{
margin-top:20px;
}
#screen{
width:calc(100% - 40px);
height:calc(100vh - 80px);
}
JavaScript
class classGraph{
constructor( canvasElement ){
this.canvas = canvasElement ;
this.maxX = this.canvas.clientWidth ;
this.maxY = this.canvas.clientHeight ;
this.canvas.width = this.maxX ;
this.canvas.height = this.maxY ;
this.ctx = this.canvas.getContext("2d");
}
clearScr(){
this.ctx.fillStyle = "#000000";
this.ctx.clearRect ( 0, 0, this.maxX, this.maxY );
}
triangleFilled ( x1, y1, x2, y2, x3, y3, fillStyle ){
this.ctx.beginPath();
this.ctx.moveTo ( x1, y1 );
this.ctx.lineTo ( x2, y2 );
this.ctx.lineTo ( x3, y3 );
this.ctx.lineWidth = 1;
this.ctx.fillStyle = fillStyle;
this.ctx.fill();
}
triangle( x1, y1, x2, y2, x3, y3, strokeStyle ){
this.ctx.beginPath();
this.ctx.moveTo ( x1, y1 );
this.ctx.lineTo ( x2, y2 );
this.ctx.lineTo ( x3, y3 );
this.ctx.lineTo ( x1, y1);
this.ctx.lineWidth = 1;
this.ctx.strokeStyle = strokeStyle;
this.ctx.stroke();
}
};
var scene =...