newton.html

URL: https://mirkwood.cs.edinboro.edu/~bennett/class/cmsc3780/spring2026/notes/javascript/code/start/newton.html
 
<html lang="en">

<head>
<title> Newton Fractal </title>
</head>

<body>
    <canvas id="MyCanvas" height="400" width="400" 
          style="border: 2px solid black;">
    </canvas>
    <div id="output"> 
    </div>
<script>
"use strict"

// get the canvas and associated parts
const canvas = document.getElementById("MyCanvas")
const ctx = canvas.getContext("2d")

const height = canvas.height
const width  = canvas.width

ctx.beginPath()
ctx.moveTo(0,0)
ctx.lineTo(width,height)
ctx.strokeStyle="Red"
ctx.stroke()

ctx.beginPath()
ctx.strokeStyle="Blue"
ctx.moveTo(0,height);
ctx.lineTo(width,0)
ctx.stroke()

// get the output area
const outputArea = document.getElementById("output")
outputArea.innerHTML = "The canvas is ";
outputArea.innerHTML += "<br> width: "+ width;
outputArea.innerHTML += "<br> height: "+ height;

</script>
</body>
</html>