body { font-family: Arial, sans-serif; text-align: center; }
.container { margin-top: 50px; }
input, select, button { margin: 10px; padding: 10px; }
canvas { border: 1px solid #000; margin-top: 20px; }
<textarea id="text" placeholder="输入中文内容"></textarea><br>
<input type="color" id="color" value="#000000"><br>
<input type="number" id="fontSize" placeholder="字体大小" value="30"><br>
<select id="fontFamily">
<option value="Arial">Arial</option>
<option value="Sans-serif">Sans-serif</option>
<option value="Serif">Serif</option>
<button onclick="generateImage()">生成图片</button>
<canvas id="canvas" width="500" height="500"></canvas>
function generateImage() {
const text = document.getElementById('text').value;
const color = document.getElementById('color').value;
const fontSize = document.getElementById('fontSize').value;
const fontFamily = document.getElementById('fontFamily').value;
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.font = `${fontSize}px ${fontFamily}`;
ctx.fillText(text, 50, 100);