C # drawing - diamond

xiaoxiao2021-03-06  133

C # drawing - diamond

// -------------------------------------

// DrawDiamond.cs by Flycrane

// -------------------------------------

Using system;

Using system.drawing;

Using system.windows.forms;

Class DrawDiamond: Form

{

Public static void main ()

{

Application.run (new drawdiamond ());

}

Public drawdiamond ()

{

Text = "Diamond Pattern - Flycrane";

Backcolor = color.black;

Forecolor = color.white;

Resizeredraw = true;

Width = 400;

HEIGHT = 400;

}

Protected Override Void Onpaint (Painteventargs E)

{

Graphics mygraphics = E.Graphics;

Pen Mypen = New Pen (Forecolor, 2);

Float radius = (float) (Width / 2.2);

Constint Partitionnum = 25;

Float angleunit = (float) (2 * math.pi / partitionnum);

Float [] circlex = newfloat [partitionnum];

Float [] Circley = newfloat [partitionnum];

// center of the circle.

Float Originx = ClientSize.width / 2;

Float Originy = ClientSize.height / 2;

// Store Coordinates of the Nodes on The Circle Verge.

For (int i = 0; i

{

Circlex [i] = (float) (Radius * Math.cos (i * angleunit)) Originx;

Circley [i] = (float) (i * angleunit) Originy;

}

// link nodes on the circle verge.

For (INT i = 0; i <= partitionnum-2; i )

{

For (int J = i 1; j <= partitionnum-1; j )

MyGraphics.drawline (Mypen, Circlex [I], Circley [i], Circlex [J], Circley [J]);

}

}

}

references:

CHARLES PETZOLD. Programming Microsoft Windows with c # .microsoft press. 2002.

2. Lu Runmin. C language drawing tutorial. Tsinghua University Press. April 1996 First Edition.

转载请注明原文地址:https://www.9cbs.com/read-127620.html

New Post(0)