欢迎光临
我们一直在努力

Asp.Net 使用 GDI+ 绘制3D饼图入门篇源码-.NET教程,Asp.Net开发

建站超值云服务器,限时71元/月

topn3dpie.aspx

——————

<%@ page language="c#" codebehind="topn3dpie.aspx.cs" autoeventwireup="false" inherits="yeefly.topn3dpie" %>

topn3dpie.aspx.cs

—————–

using system;

using system.collections;

using system.componentmodel;

using system.data;

using system.drawing;

using system.web;

using system.web.sessionstate;

using system.web.ui;

using system.web.ui.webcontrols;

using system.web.ui.htmlcontrols;

using system.drawing.imaging;

using system.drawing.drawing2d;

using system.io;

namespace yeefly

{

/// <summary>

/// graph 的摘要说明。

/// </summary>

public class topn3dpie : system.web.ui.page

{

private void page_load(object sender, system.eventargs e)

{

response.contenttype = "image/jpeg";

const int width = 300, height = 300;

int x = 30, y = 50;

int piewidth = 120, pieheight = 40, pieshadow = 15;

int[] arrvote = {70,90,80,20,60,40};

random oran = new random();

bitmap objbitmap = new bitmap(width, height);

graphics objgraphics = graphics.fromimage(objbitmap);

objgraphics.drawrectangle(new pen(color.black),0,0,width,height);

objgraphics.fillrectangle(new solidbrush(color.white), 1, 1,width – 2, height – 2);

solidbrush objbrush = new solidbrush(color.blue);

objgraphics.smoothingmode = smoothingmode.antialias;

int icurrentpos = 0;

color[] arrcolor = {color.red,color.red,color.red,color.red,color.red,color.red};

for(int i = arrvote.length – 1 ; i >= 0; i–)

{

arrcolor[i] = color.fromargb(oran.next(255), oran.next(255), oran.next(255));

}

for(int i = arrvote.length – 1 ; i >= 0; i–)

{

objbrush.color = arrcolor[i];

for(int iloop2 = 0; iloop2 < pieshadow; iloop2++)

objgraphics.fillpie(new hatchbrush(hatchstyle.percent50,objbrush.color),x, y + iloop2, piewidth, pieheight, icurrentpos, arrvote[i]);

icurrentpos += arrvote[i];

}

icurrentpos = 0;

for(int i = arrvote.length – 1 ; i >= 0;i–)

{

objbrush.color = arrcolor[i];

objgraphics.fillpie(objbrush,x, y, piewidth, pieheight, icurrentpos, arrvote[i]);

icurrentpos += arrvote[i];

}

objbitmap.save(response.outputstream, imageformat.jpeg);

// clean up…

objgraphics.dispose();

objbitmap.dispose();

}

#region web 窗体设计器生成的代码

override protected void oninit(eventargs e)

{

//

// codegen: 该调用是 asp.net web 窗体设计器所必需的。

//

initializecomponent();

base.oninit(e);

}

/// <summary>

/// 设计器支持所需的方法 – 不要使用代码编辑器修改

/// 此方法的内容。

/// </summary>

private void initializecomponent()

{

this.load += new system.eventhandler(this.page_load);

}

#endregion

}

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Asp.Net 使用 GDI+ 绘制3D饼图入门篇源码-.NET教程,Asp.Net开发
分享到: 更多 (0)

相关推荐

  • 暂无文章