📄 form1.cs
字号:
for(x=-180;x<=180;x+=2)
{
y=a*x*(x-x0)*(x+x0)*(x-x2)*(x+x2);
px=(int)(200+x/2+xx);
py=(int)(160-y+yy);
px=(int)(px*0.8);
py=(int)(py*0.8);
if(x==-180)
{
p1.X=px;
p1.Y=py;
}
else
{
p2.X=px;
p2.Y=py;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
private void menuItem5_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int px,py;
double yy,a,x,y,x1,y1,x0,x2;
x0=160;
x1=180;
y1=120;
x2=80;
a=y1/(x1*(x1-x0)*(x1+x0)*(x1-x2)*(x1+x2));
for(yy=-60;yy<=60;yy+=5)
{
for(x=-180;x<=180;x+=2)
{
y=a*x*(x-x0)*(x+x0)*(x-x2)*(x+x2);
px=(int)(300+x);
py=(int)(240-y+yy);
px=(int)(px/2);
py=(int)(py/2);
if(x==-180)
{
p1.X=px;
p1.Y=py;
}
else
{
p2.X=px;
p2.Y=py;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
double d,t,al,PI,x1,y1;
int x,y,r,px,py;
PI=3.14159;
r=30;
for(px=40;px<=300;px+=60)
{
for(py=40;py<=220;py+=50)
{
for(al=0;al<=2*PI;al+=PI/16)
{
d=r*(1+0.2*Math.Sin(12*al));
t=d*(0.5+0.5*Math.Sin(4*al));
x1=t*Math.Cos(al);
y1=-t*Math.Sin(al);
x=px+(int)(x1);
y=py+(int)(y1);
if(al==0)
{
p1.X=x;
p1.Y=y;
}
else
{
p2.X=x;
p2.Y=y;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
private void menuItem7_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int px,py,i;
double xx,yy,a,x,y,x1,y1,x0;
x0=120;
x1=180;
y1=120;
a=y1/(x1*(x1-x0)*(x1+x0));
i=1;
for(yy=-100;yy<=100;yy+=75)
{
i=i+1;
for(xx=-50;xx<=50;xx+=5)
{
for(x=-180;x<=180;x+=2)
{
y=a*x*(x-x0)*(x+x0);
px=(int)(180+x/2+xx/2);
py=(int)(200-y+yy);
px=(int)(px/2);
py=(int)(py/2);
if(x==-180)
{
p1.X=px;
p1.Y=py;
}
else
{
p2.X=px;
p2.Y=py;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int px,py;
double a,x,y,x1,y1,x0,th;
x0=120;
x1=180;
y1=120;
th=0.6;
a=y1/(x1*(x1-x0)*(x1+x0));
for(x=-180;x<=180;x+=2)
{
y=a*x*(x-x0)*(x+x0);
px=(int)(300+x/2);
py=(int)(40-y);
px=(int)(px*Math.Cos(th)-py*Math.Sin(th));
py=(int)(px*Math.Sin(th)+py*Math.Cos(th));
if(x==-180)
{
p1.X=px;
p1.Y=py;
}
else
{
p2.X=px;
p2.Y=py;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
private void menuItem13_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int x,y;
double al,t,a,x1,y1,x2,y2,px,py;
const double PI=3.1416;
t=Math.Sqrt(170*170*2.0);
for(px=-170;px<=170;px+=20)
{
for(py=-170;py<=170;py+=20)
{
a=Math.Sqrt(px*px+py*py)/t*PI/2+PI/4;
for(al=0;al<=2*PI;al+=PI/2)
{
x1=10*Math.Cos(al);
y1=10*Math.Sin(al);
//使用变换公式如下:
x2=x1*Math.Cos(a)-y1*Math.Sin(a);
y2=x1*Math.Sin(a)+y1*Math.Cos(a);
x=(int)(px+300+x2);
y=(int)(py+300-y2);
x=(int)(x/2);
y=(int)(y/2);
if(al==0)
{
p1.X=x;
p1.Y=y;
}
else
{
p2.X=x;
p2.Y=y;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
private void menuItem14_Click(object sender, System.EventArgs e)
{
//将程序中的a改为:
//a=Math.Sqrt(px*px)/t*PI/2
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int x,y;
double al,t,a,x1,y1,x2,y2,px,py;
const double PI=3.1416;
t=Math.Sqrt(170*170*2.0);
for(px=-170;px<=170;px+=20)
{
for(py=-170;py<=170;py+=20)
{
a=Math.Sqrt(px*px)/t*PI/2;
for(al=0;al<=2*PI;al+=PI/2)
{
x1=10*Math.Cos(al);
y1=10*Math.Sin(al);
x2=x1*Math.Cos(a)-y1*Math.Sin(a);
y2=x1*Math.Sin(a)+y1*Math.Cos(a);
x=(int)(px+300+x2);
y=(int)(py+300-y2);
x=(int)(x/2);
y=(int)(y/2);
if(al==0)
{
p1.X=x;
p1.Y=y;
}
else
{
p2.X=x;
p2.Y=y;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
private void menuItem15_Click(object sender, System.EventArgs e)
{
//将程序中的a改为:
//a=px/t*PI/2+PI/4
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int x,y;
double al,t,a,x1,y1,x2,y2,px,py;
const double PI=3.1416;
t=Math.Sqrt(170*170*2.0);
for(px=-170;px<=170;px+=20)
{
for(py=-170;py<=170;py+=20)
{
a=px/t*PI/2+PI/4;
for(al=0;al<=2*PI;al+=PI/2)
{
x1=10*Math.Cos(al);
y1=10*Math.Sin(al);
x2=x1*Math.Cos(a)-y1*Math.Sin(a);
y2=x1*Math.Sin(a)+y1*Math.Cos(a);
x=(int)(px+300+x2);
y=(int)(py+300-y2);
x=(int)(x/2);
y=(int)(y/2);
if(al==0)
{
p1.X=x;
p1.Y=y;
}
else
{
p2.X=x;
p2.Y=y;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
private void menuItem11_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int px,py;
double a,x,y,x1,y1,x0;
x0=120;
x1=180;
y1=120;
a=y1/(x1*(x1-x0)*(x1+x0));
for(x=-180;x<=180;x+=2)
{
y=a*x*(x-x0)*(x+x0);
px=(int)(320+x/2);
py=(int)(160-y);
px=(int)(px/2);
py=(int)(py/2);
if(x==-180)
{
p1.X=px;
p1.Y=py;
}
else
{
p2.X=px;
p2.Y=py;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
for(x=-180;x<=180;x+=2)
{
y=a*x*(x-x0)*(x+x0);
px=(int)(320-x/2);
py=(int)(460-y);
px=(int)(px/2);
py=(int)(py/2);
if(x==-180)
{
p1.X=px;
p1.Y=py;
}
else
{
p2.X=px;
p2.Y=py;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
private void menuItem12_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int i,px,py,x2,y2;
double xx,yy,a,x,y,x1,y1,x0,th;
x0=120;
x1=180;
y1=120;
th=0.4;
a=y1/(x1*(x1-x0)*(x1+x0));
i=1;
for(yy=-100;yy<=100;yy+=75)
{
i=i+1;
for(xx=-50;xx<=50;xx+=5)
{
for(x=-180;x<=180;x+=2)
{
y=a*x*(x-x0)*(x+x0);
px=(int)(240+x/2+xx/2);
py=(int)(100-y+yy);
x2=(int)(px*Math.Cos(th)-py*Math.Sin(th));
y2=(int)(px*Math.Sin(th)+py*Math.Cos(th));
if(x==-180)
{
p1.X=x2;
p1.Y=y2;
}
else
{
p2.X=x2;
p2.Y=y2;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
private void menuItem18_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int a,cx,cy,z,x2,y2;
double d,x,y,al;
const double PI=3.14159;
a=30;
d=0.0;
for(cx=100;cx<=500;cx=cx+200)
{
for(cy=100;cy<=300;cy=cy+150)
{
d=d+0.5;
for(z=-90;z<=90;z=z+5)
{
x=z;
al=(z+90)*2*PI/180;
y=a*Math.Sin(al)*Math.Sin(d*al);
x2=(int)(cx+x);
y2=(int)(cy-y);
if(z==-90)
{
p1.X=x2;
p1.Y=y2;
}
else
{
p2.X=x2;
p2.Y=y2;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
private void menuItem19_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int a,cx,cy,z,x2,y2,x3,y3,cx1,cy1,z1;
double d,x,y,al,a0,x0,y0,d1;
const double PI=3.14159;
a=30;d=0.0;d1=0.0;
for(cx=100;cx<=500;cx=cx+200)
for(cy=100;cy<=300;cy=cy+150)
{
d=d+0.5;
for(z=-90;z<=90;z=z+5)
{
x=z;
al=(z+90)*2*PI/180;
y=a*Math.Sin(al)*Math.Sin(d*al);
x2=(int)(cx+x);
y2=(int)(cy-y);
if(z==-90)
{
p1.X=x2;p1.Y=y2;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -