0% found this document useful (0 votes)
68 views1 page

Form1 Form: // R: Determines The Size of The Star. // XC, Yc: Determine The Location of The Star

The document contains code for drawing a yellow star shape within a Windows form application. It defines variables for the star's location and size, calculates trigonometric values needed to define the star's points, and fills a polygon defined by those points to render the star graphic on the form.

Uploaded by

Tomić Miroslav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
68 views1 page

Form1 Form: // R: Determines The Size of The Star. // XC, Yc: Determine The Location of The Star

The document contains code for drawing a yellow star shape within a Windows form application. It defines variables for the star's location and size, calculates trigonometric values needed to define the star's points, and fills a polygon defined by those points to render the star graphic on the form.

Uploaded by

Tomić Miroslav
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

using using using using using using using using using

System; System.Collections.Generic; System.ComponentModel; System.Data; System.Drawing; System.Linq; System.Text; System.Windows.Forms; System.Drawing.Drawing2D;

namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } protected override void OnPaint(PaintEventArgs e) { int xc; int yc; Graphics g = e.Graphics; g.SmoothingMode = SmoothingMode.AntiAlias; xc = (int)(ClientSize.Width / 2); yc = (int)(ClientSize.Height / 2); DrawStar(g, this.Width / 3, xc, yc); g.Dispose(); } private void DrawStar(Graphics g, float r, float xc, float yc) { // r: determines the size of the star. // xc, yc: determine the location of the star. float sin36 = (float)Math.Sin(36.0 * Math.PI / 180.0); float sin72 = (float)Math.Sin(72.0 * Math.PI / 180.0); float cos36 = (float)Math.Cos(36.0 * Math.PI / 180.0); float cos72 = (float)Math.Cos(72.0 * Math.PI / 180.0); float r1 = r * cos72 / cos36; // Fill the star: PointF[] pts = new PointF[10]; pts[0] = new PointF(xc, yc - r); pts[1] = new PointF(xc + r1 * sin36, yc - r1 * cos36); pts[2] = new PointF(xc + r * sin72, yc - r * cos72); pts[3] = new PointF(xc + r1 * sin72, yc + r1 * cos72); pts[4] = new PointF(xc + r * sin36, yc + r * cos36); pts[5] = new PointF(xc, yc + r1); pts[6] = new PointF(xc - r * sin36, yc + r * cos36); pts[7] = new PointF(xc - r1 * sin72, yc + r1 * cos72); pts[8] = new PointF(xc - r * sin72, yc - r * cos72); pts[9] = new PointF(xc - r1 * sin36, yc - r1 * cos36); g.FillPolygon(Brushes.Yellow, pts); } } }

You might also like