110,534
社区成员
发帖
与我相关
我的任务
分享
<!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();
}
pthGrBrush.InterpolationColors = new ColorBlend(3)
{
Colors = new[] { Color.Blue, Color.Yellow, Color.Red },
Positions = new[] { 0f, .5f, 1f },
};