Click here to Skip to main content
15,888,237 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
why the line is not so clear.i want to draw fine line.(Line drawn by javascript code is not clear.)

ASP.NET
<%@ 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:

HTML
<!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>


this code is working properly, but when the width and heigth are change to 500, it's not working why.ot working why.
Posted
Updated 14-Aug-12 9:06am
v5

1 solution

HTML
<canvas style=" border:thin solid red; width:500px; height:500px;" id="c"></canvas>


Hope you find it useful.
 
Share this answer
 
Comments
Yvan Rodrigues 14-Aug-12 12:28pm    
And if it's still not clear, your browser may be anti-aliasing the image.
Christian Amado 14-Aug-12 13:09pm    
The question is fuzzy, anyway.
Sergey Alexandrovich Kryukov 14-Aug-12 16:03pm    
Or just not clear. :-)
--SA
Christian Amado 14-Aug-12 16:05pm    
So many clearance around here! May be opacity: 0% ;)
footballpardeep 14-Aug-12 14:21pm    
i m not talking about border line, the line drawn on the canvas by javascript code is not clear.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900