如何在 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