Run ❯
zig
.
com
Result Size:
625 x 565
×
Change Orientation
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <canvas id="myCanvas" width="400px" height="400px" style="width:100%;max-width:400px;border:1px solid black"></canvas> <script> // Create a Plotter let myPlotter = new XYPlotter("myCanvas"); myPlotter.transformXY(); // Plot a Line myPlotter.plotLine(0, 0, myPlotter.xMax, myPlotter.yMax, "red"); // Plotter Object function XYPlotter(id) { this.canvas = document.getElementById(id); this.ctx = this.canvas.getContext("2d"); this.xMin = 0; this.yMin = 0; this.xMax = this.canvas.width; this.yMax = this.canvas.height; // Transform XY Function this.transformXY = function () { this.ctx.transform(1, 0, 0, -1, 0, this.canvas.height) } // Plot a Line Function this.plotLine = function (x0, y0, x, y, color) { this.ctx.moveTo(x0, y0); this.ctx.lineTo(x, y); this.ctx.strokeStyle = color; this.ctx.stroke(); } } // End Plotter Object </script> </body> <!-- /ai/tryit.asp?filename=tryai_plotter_transform by HTTrack Website Copier/3.x [XR&CO'2014], Thu, 06 Feb 2025 18:50:36 GMT --> </html>