如何在 HTML 脚本中制作图像?
要使用脚本制作图像,需使用 <canvas> 标签。HTML <canvas> 标签用于通过脚本绘制图像、动画等。
以下是 <canvas> 标签的属性:
| 属性 | 值 | 描述 |
|---|---|---|
| height | 像素 | 指定画布的高度。 |
| width | 像素 | 指定画布的宽度。 |
示例
可尝试运行以下代码来实现 <canvas> 标签并创建图像:
<!DOCTYPE html>
<html>
<head>
<title>HTML Canvas Tag</title>
</head>
<body>
<canvas id = "newCanvas">Your browser does not support canvas tag.</canvas>
<script>
var c = document.getElementById('newCanvas');
var ctx = c.getContext('2d');
ctx.fillStyle = '#00AEEF';
ctx.fillRect(0,0,180,50);
</script>
</body>
</html>
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP