日期:2014-05-18 浏览次数:20978 次
<!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(40, 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(); }