<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>canvas文本属性textBaseline</title>
<style>
body{margin: 0;overflow: hidden}
#test{background: antiquewhite;}
</style>
</head>
<body>
<canvas id="test"></canvas>
<script>
const cvs=document.getElementById('test');
cvs.width=window.innerWidth;
cvs.height=window.innerHeight;
const ctx=cvs.getContext('2d');
/*辅助线*/
ctx.strokeStyle='#999';
ctx.setLineDash([8]);
ctx.moveTo(30,300);
ctx.lineTo(700,300);
ctx.stroke();
/*font 设置字号字体*/
ctx.font="24px Arial";
canvas文本属性-textBaseline-垂直对齐
最新推荐文章于 2024-05-01 16:40:00 发布