<!DOCTYPE html>
<html>
<head>
	<title>输出文字图片</title>
	<script>
		function outputImg() {
			var inputText = document.getElementById("inputText").value;
			var img = document.createElement("img");
			var canvas = document.createElement("canvas");
			var ctx = canvas.getContext("2d");
			ctx.font = "bold 24px 宋体";
			ctx.fillStyle = "pink";
			ctx.rotate(Math.PI);
			ctx.fillText(inputText, -100, -100);
			img.src = canvas.toDataURL();
			document.body.appendChild(img);
		}
	</script>
</head>
<body>
	<label for="inputText">请输入文字:</label>
	<input type="text" id="inputText">
	<button onclick="outputImg()">生成图片</button>
</body>
</html
编写html代码在文本框输入文字后点击按钮以图片形式输出文字顺时针旋转180度文字是二号字文字的字体是宋体文字的颜色是粉红色。

原文地址: https://www.cveoy.top/t/topic/ezuu 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录