c# 绘图–飘带
杨贺宏
//————————————-
// drawstreamer.cs by flycrane
//————————————-
using system;
using system.drawing;
using system.windows.forms;
class drawstreamer : form
{
publicstaticvoidmain()
{
application.run( new drawstreamer() );
}
public drawstreamer()
{
text= "飘带图案-flycrane";
backcolor= color.aliceblue;
forecolor= color.gold;
resizeredraw= true;
width= 600;
height= 350;
}
protectedoverridevoid onpaint(painteventargs e)
{
graphics mygraphics= e.graphics;
pen mypen= new pen( forecolor,2 );
// center of the circle.
float originx=clientsize.width/2;
float originy=clientsize.height;
float x1,x2,y1;
// draw streamer,which comprise series of horizontal line segment;
for ( double a=0;a<=math.pi ;a+=math.pi/380 )
{
x1 =(float) ( 280*math.cos( 1.6*a ) +originx );
y1 =(float) ( 479-( ( 90*math.sin( 8*a ) )*math.cos( a/2.5 )+originy ) );
x2 =(float) ( 280*math.cos( 1.8*a )+originx );
mygraphics.drawline ( mypen,x1,y1,x2,y1);
}
}
}
