本文介绍了为什么线不是那么清晰?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
为什么线条不太清晰.我想绘制细线.(用javascript代码绘制的线条不清楚.)
why the line is not so clear.i want to draw fine line.(Line drawn by javascript code is not clear.)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
window.onload = function () {
// get the canvas DOM element by its ID
var canvas = document.getElementById("c");
var context = canvas.getContext("2d");
context.lineWidth =2;
context.strokeStyle = "blue";
context.moveTo(0,0);
context.lineTo(400,200);
context.stroke();
};
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<canvas style=" border:2px solid red; width:500px; height:500px;" id="c"></canvas>
</div>
</form>
</body>
</html>
****************************************************** ******
还有一个问题:
********************************************************
one more problem:
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
ctx.moveTo(10,10);
ctx.lineTo(150,50);
ctx.lineTo(10,50);
ctx.stroke();
</script>
</body>
</html>
这段代码正常工作,但是当宽度和高度更改为500时,why.ot无法工作.
this code is working properly, but when the width and heigth are change to 500, it''s not working why.ot working why.
推荐答案
<canvas style=" border:thin solid red; width:500px; height:500px;" id="c"></canvas>
希望您觉得它有用.
Hope you find it useful.
这篇关于为什么线不是那么清晰?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!