hi all,
My english is not very well,my question is I use HTML5 on the page to draw a circle, and I need to export it for pdf. so I also use c# to draw a circle, but it can't achieve the same effect. Using c# draw a circle, the color of center of cricle is blue(alpha=255), the color of frame of circle is black(alpha=0), but the effect is the blue gradient to blue transparent, not blue fade to black transparent.following is my code.
thanks.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body onload="">
<canvas id="myCanvas" width="500" height="500">
Your browser does not support the canvas element.
</canvas>
<script type="text/javascript">
function tt()
{
var c = document.getElementById("myCanvas");
var cxt = c.getContext("2d");
var radGrad = cxt.createRadialGradient(200, 200, 0, 200, 200, 100);
radGrad.addColorStop(0.0, 'rgba(0,0,255,1)');
radGrad.addColorStop(1.0, 'rgba(0,0,0,0)');
cxt.fillStyle = radGrad;
cxt.fillRect(0, 100, 400, 200);
}
tt();
</script>
</body>
</html>
protected void Page_Load(object sender, EventArgs e)
{
Bitmap bmp = new Bitmap(200, 200);
Graphics g = Graphics.FromImage(bmp);
Color cStart = Color.FromArgb(0, 0, 0, 0);
Color cEnd = Color.FromArgb(255, 0, 0, 255);
int radius = 100;
GraphicsPath path = new GraphicsPath();
path.AddEllipse(0, 0, radius * 2, radius * 2);
PathGradientBrush pthGrBrush = new PathGradientBrush(path);
pthGrBrush.CenterColor = cEnd;
Color[] colors = { cStart };
pthGrBrush.SurroundColors = colors;
g.FillEllipse(pthGrBrush, 0, 0, radius * 2, radius * 2);
bmp.Save("d:\\1.png");
bmp.Dispose();
g.Dispose();
}