📄 form1.cs
字号:
else
{
p2.X=x2;p2.Y=y2;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
for(cx1=100;cx1<=500;cx1=cx1+200)
for(cy1=100;cy1<=300;cy1=cy1+150)
{
d1=d1+0.5;
for(z1=-90;z1<=90;z1=z1+5)
{
x0=z1;
a0=(z1+90)*2*PI/180;
y0=-a*Math.Sin(a0)*Math.Sin(d1*a0);
x3=(int)(cx1+x0);
y3=(int)(cy1-y0);
if(z1==-90)
{
p3.X=x3;p3.Y=y3;
}
else
{
p4.X=x3;p4.Y=y3;
g.DrawLine(pen1,p3,p4);
p3=p4;
}
}
}
}
private void menuItem20_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int a,cx,cy,l,z,x2,y2,s;
double d,x,y,al,temp;
const double PI=3.14159;
a=30;
d=0.0;
for(cx=100;cx<=600;cx+=200)
for(cy=100;cy<=300;cy+=200)
{
d=d+0.5;
for(s=1;s<=2;s+=1)
{
for(l=-1;l<=1;l+=2)
{
for(z=-90;z<=90;z+=5)
{
x=z;
al=(z+90)*2*PI/180;
y=l*a*Math.Sin(al)*Math.Sin(d*al);
if(s==2)
{
temp=x;
x=y;
y=temp;
}
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 menuItem29_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int a,cx,cy,l,z,x1,y1,x2,y2,s;
double d,x,y,al,temp,bt,bt1,bt2;
const double PI=3.14159;
a=30;
d=0.0;
bt=PI/4;
bt1=Math.Cos(bt);
bt2=Math.Sin(bt);
for(cx=100;cx<=500;cx+=150)
for(cy=100;cy<=300;cy+=150)
{
d=d+0.5;
for(s=1;s<=2;s+=1)
{
for(l=-1;l<=1;l+=2)
{
for(z=-90;z<=90;z+=5)
{
x=z;
al=(z+90)*2*PI/180;
y=l*a*Math.Sin(al)*Math.Sin(d*al);
if(s==2)
{
temp=x;
x=y;
y=temp;
}
x1=(int)(x*bt1-y*bt2);
y1=(int)(x*bt2+y*bt1);
x2=(int)(cx+x1);
y2=(int)(cy-y1);
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 menuItem30_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
int a,cx,cy,l,z,x1,y1,x2,y2,s;
double d,x,y,al,temp,bt,bt1,bt2;
const double PI=3.14159;
a=30;
d=0.0;
bt=PI/4;
bt1=Math.Cos(bt);
bt2=Math.Sin(bt);
for(cx=100;cx<=600;cx+=150)
for(cy=100;cy<=300;cy+=150)
{
d=d+0.5;
for(s=1;s<=2;s+=1)
{
for(l=-1;l<=1;l+=2)
{
for(z=-90;z<=90;z+=5)
{
x=z;
al=(z+90)*2*PI/180;
y=l*a*Math.Sin(al)*Math.Sin(d*al);
if(s==2)
{
temp=x;
x=y;
y=temp;
}
x1=(int)(x*bt1-y*bt2);
y1=(int)(x*bt2+y*bt1);
x2=(int)(cx+x1);
y2=(int)(cy-y1);
if(z==-90)
{
p1.X=x2;p1.Y=y2;
}
else
{
p2.X=x2;p2.Y=y2;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
d=0.0;
for(cx=100;cx<=600;cx+=200)
for(cy=100;cy<=300;cy+=200)
{
d=d+0.5;
for(s=1;s<=2;s+=1)
{
for(l=-1;l<=1;l+=2)
{
for(z=-90;z<=90;z+=5)
{
x=z;
al=(z+90)*2*PI/180;
y=l*a*Math.Sin(al)*Math.Sin(d*al);
if(s==2)
{
temp=x;
x=y;
y=temp;
}
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 menuItem22_Click(object sender, System.EventArgs e)
{
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
const double PI=3.14159;
int a,cx,cy,l,z,x2,y2,n,x1,y1;
double d,x,y,al,st,ed,bt,bt1,bt2;
d=0.0;
n=5;
a=20;
st=2*PI/n;
ed=st*(n-1);
for(cx=105;cx<=525;cx+=210)
for(cy=100;cy<=300;cy+=200)
{
d=d+0.5;
for(bt=0;bt<=ed;bt+=st)
{
bt1=Math.Sin(bt);
bt2=Math.Cos(bt);
for(l=-1;l<=1;l+=2)
{
for(z=0;z<=90;z+=5)
{
x=z;
al=(z+90)*2*PI/180;
y=l*a*Math.Sin(al)*Math.Sin(d*al);
x1=(int)(x*bt1-y*bt2);
y1=(int)(x*bt2+y*bt1);
x2=(int)(cx+x1);
y2=(int)(cy-y1);
if(z==0)
{
p1.X=x2;p1.Y=y2;
}
else
{
p2.X=x2;p2.Y=y2;
g.DrawLine(pen1,p1,p2);
p1=p2;
}
}
}
}
}
}
private void menuItem23_Click(object sender, System.EventArgs e)
{
//平移变换
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
double[] x1=new double[]{0.0,10.0,100.0,110.0,0.0};
double[] y1=new double[]{0.0,50.0,40.0,10.0,0.0};
double[] x2=new double[5];
double[] y2=new double[5];
int i,x;
Class1 end=new Class1();
for(x=-150;x<=100;x+=10)
{
end.parallel(x,x/2);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x1[i],y1[i],1.0);
y2[i]=end.affiney(x1[i],y1[i],1.0);
}
for(i=0;i<=3;i++)
{
g.DrawLine(pen1,(int)(end.scx(x2[i])),(int)(end.scy(y2[i])),(int)(end.scx(x2[i+1])),(int)(end.scy(y2[i+1])));
}
}
}
private void menuItem24_Click(object sender, System.EventArgs e)
{
//旋转120度
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
double[] x1=new double[]{0.0,10.0,100.0,110.0,0.0};
double[] y1=new double[]{0.0,50.0,40.0,10.0,0.0};
double[] x2=new double[5];
double[] y2=new double[5];
int i;
Class1 end=new Class1();
for(i=0;i<=3;i++)
{
g.DrawLine(pen1,(int)end.scx(x1[i]),(int)end.scy(y1[i]/2),(int)end.scx(x1[i+1]),(int)end.scy(y1[i+1]/2));
}
end.rotate(120.0);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x1[i],y1[i],1.0);
y2[i]=end.affiney(x1[i],y1[i],1.0)/2;
}
for(i=0;i<=3;i++)
{
g.DrawLine(pen1,(int)(end.scx(x2[i])),(int)(end.scy(y2[i])),(int)(end.scx(x2[i+1])),(int)(end.scy(y2[i+1])));
}
}
private void menuItem25_Click(object sender, System.EventArgs e)
{
//旋转变换
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
double[] x1=new double[]{0.0,10.0,100.0,110.0,0.0};
double[] y1=new double[]{0.0,50.0,40.0,10.0,0.0};
double[] x2=new double[5];
double[] y2=new double[5];
int i,r;
Class1 end=new Class1();
for(r=0;r<=360;r+=10)
{
end.rotate(r);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x1[i],y1[i],1.0);
y2[i]=end.affiney(x1[i],y1[i],1.0);
}
for(i=0;i<=3;i++)
{
g.DrawLine(pen1,(int)(end.scx(x2[i])),(int)(end.scy(y2[i])),(int)(end.scx(x2[i+1])),(int)(end.scy(y2[i+1])));
}
}
}
private void menuItem26_Click(object sender, System.EventArgs e)
{
//沿椭圆旋转
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
double[] x1=new double[]{-20.0,0.0,30.0,10.0,-20.0};
double[] y1=new double[]{0.0,18.0,-10.0,-20.0,0.0};
double[] x2=new double[5];
double[] y2=new double[5];
int i;
double pi,r;
pi=3.14159;
Class1 end=new Class1();
for(r=0;r<=360;r+=10)
{
end.rotate(r);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x1[i],y1[i],1.0);
y2[i]=end.affiney(x1[i],y1[i],1.0);
}
end.parallel(-Math.Cos(r/180*pi)*150.0,Math.Sin(r/180*pi)*100.0);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x2[i],y2[i],1.0);
y2[i]=end.affiney(x2[i],y2[i],1.0);
}
for(i=0;i<=3;i++)
{
g.DrawLine(pen1,(int)(end.scx(x2[i])),(int)(end.scy(y2[i])),(int)(end.scx(x2[i+1])),(int)(end.scy(y2[i+1])));
}
}
}
private void menuItem27_Click(object sender, System.EventArgs e)
{
//比例变换
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
double[] x1=new double[]{-20.0,0.0,30.0,10.0,-20.0};
double[] y1=new double[]{0.0,18.0,-10.0,-20.0,0.0};
double[] x2=new double[5];
double[] y2=new double[5];
int i;
Class1 end=new Class1();
double s;
for(s=0;s<10;s+=0.5)
{
end.scale(s);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x1[i],y1[i],1.0);
y2[i]=end.affiney(x1[i],y1[i],1.0)/2;
}
for(i=0;i<=3;i++)
{
g.DrawLine(pen1,(int)(end.scx(x2[i])),(int)(end.scy(y2[i])),(int)(end.scx(x2[i+1])),(int)(end.scy(y2[i+1])));
}
}
}
private void menuItem28_Click(object sender, System.EventArgs e)
{
//旋转比例平移
Graphics g=pictureBox1.CreateGraphics();
Pen pen1=new Pen(Color.Blue);
g.Clear(pictureBox1.BackColor);
double[] x1=new double[]{-20.0,0.0,30.0,10.0,-20.0};
double[] y1=new double[]{0.0,18.0,-10.0,-20.0,0.0};
double[] x2=new double[5];
double[] y2=new double[5];
int i;
double pi,r;
pi=3.14159;
Class1 end=new Class1();
for(r=0;r<=360;r+=10)
{
end.rotate(r);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x1[i],y1[i],1.0);
y2[i]=end.affiney(x1[i],y1[i],1.0);
}
end.scale(Math.Sin(r/180*pi)*1.5);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x2[i],y2[i],1.0);
y2[i]=end.affiney(x2[i],y2[i],1.0);
}
end.parallel(-Math.Cos(r/180*pi)*150.0,Math.Sin(r/180*pi)*100.0);
for(i=0;i<=4;i++)
{
x2[i]=end.affinex(x2[i],y2[i],1.0);
y2[i]=end.affiney(x2[i],y2[i],1.0);
}
for(i=0;i<=3;i++)
{
g.DrawLine(pen1,(int)(end.scx(x2[i])),(int)(end.scy(y2[i])),(int)(end.scx(x2[i+1])),(int)(end.scy(y2[i+1])));
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -