"Here is an example of HTML code that creates a simple smiley face using a canvas element:
<html> <head> <title>Canvas Smiley Face</title> </head> <body> <canvas id="smiley" width="200" height="200"></canvas> <script> var canvas = document.getElementById("smiley"); var ctx = canvas.getContext("2d"); // Draw the face ctx.beginPath(); ctx.arc(100, 100, 80, 0, 2 * Math.PI); ctx.fillStyle = "yellow"; ctx.fill(); // Draw the eyes ctx.beginPath(); ctx.arc(70, 75, 10, 0, 2 * Math.PI); ctx.arc(130, 75, 10, 0, 2 * Math.PI); ctx.fillStyle = "black"; ctx.fill(); // Draw the mouth ctx.beginPath(); ctx.arc(100, 120, 50, 0, Math.PI); ctx.strokeStyle = "black"; ctx.lineWidth = 5; ctx.stroke(); </script> </body> </html>
This code creates a canvas element with an id of "smiley" and a width and height of 200 pixels. It then uses JavaScript to draw a yellow circle to represent the face, two black circles for the eyes, and a black arc for the mouth." -ChatGPT
No comments:
Post a Comment