问题:
百度文心一言:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Canvas L Shape</title>
</head>
<body>
<canvas id="myCanvas" width="500" height="500"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.moveTo(250, 0); // 设置起始点
ctx.lineTo(500, 500); // 绘制线条
ctx.stroke(); // 描边路径
</script>
</body>
</html>
输出:
阿里通义千问:
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="300" height="150" style="border:1px solid #d3d3d3;">
Your browser does not support the HTML5 canvas tag.
</canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
// Set line color and width
ctx.strokeStyle = "black";
ctx.lineWidth = 2;
// Draw horizontal line
ctx.beginPath();
ctx.moveTo(40, 75);
ctx.lineTo(260, 75);
ctx.stroke();
// Draw vertical line
ctx.beginPath();
ctx.moveTo(150, 75);
ctx.lineTo(150, 25);
ctx.stroke();
</script>
</body>
</html>
输出:
GPT-3.5
<!DOCTYPE html>
<html>
<head>
<title>Canvas L Shape</title>
<style>
canvas {
border: 1px solid black;
}
</style>
</head>
<body>
<canvas id="myCanvas" width="200" height="200"></canvas>
<script>
// 获取Canvas元素
var canvas = document.getElementById("myCanvas");
var context = canvas.getContext("2d");
// 绘制L形状
context.beginPath();
context.moveTo(50, 50);
context.lineTo(50, 150);
context.lineTo(150, 150);
context.stroke();
</script>
</body>
</html>
输出:
似乎国产的差点意思,不过已经很屌了,加油吧!