Registriert seit: 10. Jun 2004
Ort: Garching (TUM)
4.579 Beiträge
|
Re: Stardesigner - Make your Star
26. Okt 2009, 14:37

Zitat von NamenLozer:
Hmm, also wenn schon, dann bitte mit Quellcode 
Nagut, ist ja sowiso nicht viel *g*
Code:
public partial class Form1 : Form
{
Pen pen;
Brush brush;
public Form1()
{
InitializeComponent();
pen = new Pen(Color.Black, 3);
brush = new SolidBrush(Color.OrangeRed);
}
private PointF PolarToPic(double r, double phi)
{
PointF Result = new PointF();
Result.X = (float)(r * Math.Cos(phi + Math.PI / 2) + pictureBox1.Width / 2d);
Result.Y = (float)(-r * Math.Sin(phi + Math.PI / 2) + pictureBox1.Height / 2d);
return Result;
}
private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
double phi = 0;
double dphi = Math.PI / (double)Zackenzahl.Value;
double ri = InnerRadius.Value;
double ra = OuterRadius.Value;
PointF[] Points = new PointF[(int)Zackenzahl.Value * 2];
for (int i = 0; i < Zackenzahl.Value * 2; i = i + 2)
{
Points[i] = PolarToPic(ra, phi);
phi += dphi;
Points[i + 1] = PolarToPic(ri, phi);
phi += dphi;
}
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
e.Graphics.FillPolygon(brush, Points);
e.Graphics.DrawPolygon(pen, Points);
}
private void ParamChanged(object sender, EventArgs e)
{
pictureBox1.Invalidate();
}
private void Form1_SizeChanged(object sender, EventArgs e)
{
pictureBox1.Invalidate();
}
}
|
|
Zitat
|