Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
    <script>
        window.onload = function () {
            var canvas = document.getElementById("myCanvas");
            var context = canvas.getContext("2d");
            context.lineWidth = 2;
            context.strokeStyle = "black";
            context.font = "30pt Calibri";
            context.fillText('Pythagorean Theorem', 230, 40);
            //Draw right triangle
            context.moveTo(300, 50);
            context.lineTo(300, 150);
            context.lineTo(350, 150);
            context.lineTo(300, 50);
            context.stroke();
            context.fillText('a', 270, 110);
            context.fillText('b', 310, 180);
            context.fillText('c', 340, 130);
            context.lineWidth = 1;
            context.moveTo(300, 140);
            context.lineTo(310, 140);
            context.lineTo(310, 150);
            context.stroke();
            context.font = "14pt Calibri";
            context.fillText('In any right triangle with legs a and b and hypotenuse c:', 80, 220);
            context.fillText('a  + b   = c ', 220, 260);
            context.font = "10pt Calibri";
            context.fillText('2        2          2', 228, 254);
            context.font = "14pt Calibri";
            do {
                var ranA = Math.floor((Math.random() * 200) + 1);
                var ranB = Math.floor((Math.random() * 200) + 1);
                var coverOne = Math.floor((Math.random() * 3) + 1);
                hypoNum = Math.sqrt((ranA * ranA) + (ranB * ranB));
            } while (hypoNum > Math.floor(hypoNum));
            context.fillText('Here we have provided two of the', 200, 300);
            context.fillText('three values and you will need', 200, 320);
            context.fillText('to solve for the unknown.', 200, 340);
            context.fillText('a =  ' + ranA, 230, 370);
            context.fillText('b =  ' + ranB, 230, 390);
            context.fillText('c =  ' + hypoNum, 230, 410);
            context.fillText('ANSWER =        ', 230, 430);
            context.fillText('Click on  the box', 230, 450);
            context.fillText('to see the unknown value.', 230, 470);
            context.fillText('Side Hidden: ' + coverOne, 230, 490);
            // Adding the below draw to see if it gets to this.
            //  context.fillRect(230, 370, 100, 50);
            // It doesn't complete this, so something is missing in the above script
            // The purpose of the below conditional statement is to cover over one of the three answers
            // with a rectangle.
            if (coverOne == 1) {
                context.fillRect(230, 370, 100, 50);
            }
            else if (coverOne == 2) {
                context.fillRect(230, 390, 100, 50);
            }
            else if (coverOne == 3) {
                context.fillRect(230, 410, 100, 50);
            }
        }
    </script>
</head>
<body>
    <div align="center">
        <canvas id="myCanvas" width="800" height="800" style="border:1px solid black;">
        </canvas>
    </div>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers