hi all here is my challenge.
Write a program to draw a stick figure. Combine hair,face and body to make the figure. Create 'hair', 'face' and 'body' classes to draw each of these parts. Each class will have a draw method that accepts a graphics parameter. use the graphics object to draw that part. do the drawing relative to the size of the window.
now the previous challenge was to draw a face eyes, nose and mouth but all this is drawn within OnPaint, when i create new class within the program i cannot then use the e.graphics in order to draw the sections.
i dont quite understand because i tried before playing around with the different Onpaintbackground, onmousedown etc and couldnt get the e.graphics either. can anyone help me out with advice please here is the code in previous challenge for the face
Write a program to draw a stick figure. Combine hair,face and body to make the figure. Create 'hair', 'face' and 'body' classes to draw each of these parts. Each class will have a draw method that accepts a graphics parameter. use the graphics object to draw that part. do the drawing relative to the size of the window.
now the previous challenge was to draw a face eyes, nose and mouth but all this is drawn within OnPaint, when i create new class within the program i cannot then use the e.graphics in order to draw the sections.
i dont quite understand because i tried before playing around with the different Onpaintbackground, onmousedown etc and couldnt get the e.graphics either. can anyone help me out with advice please here is the code in previous challenge for the face
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Drawing; using System.Windows.Forms; public class StickFigure : Form { public StickFigure() { Size = new Size(800, 800); Text = "Stick Figure"; BackColor = Color.White; } protected override void OnPaint(PaintEventArgs e) { int w = DisplayRectangle.Width; int h = DisplayRectangle.Height; Graphics g = e.Graphics; //Head g.DrawEllipse(Pens.Black, w / 20 * 8, h / 20 * 6, w / 20 * 4, h / 20 * 4); //body g.DrawLine(Pens.Black, w / 20 * 10, h / 20 * 10, w / 20 * 10, h / 20 * 15); //legs g.DrawLine(Pens.Black, w / 20 * 10, h / 20 * 15, w / 20 * 7, h / 20 * 18); g.DrawLine(Pens.Black, w / 20 * 10, h / 20 * 15, w / 20 * 13, h / 20 * 18); //arms g.DrawLine(Pens.Black, w / 20 * 10, h / 20 * 12, w / 20 * 7, h / 20 * 12); g.DrawLine(Pens.Black, w / 20 * 10, h / 20 * 12, w / 20 * 13, h / 20 * 12); //eyes g.DrawEllipse(Pens.Black, w / 20 * (int)9, h / 20 * (int)7.5, 20, 20); g.DrawEllipse(Pens.Black, w / 20 * (int)10 + 15, h / 20 * (int)7.5, 20, 20); //nose g.DrawArc(Pens.Black, w / 20 * 10 - 10, h / 20 * 8 - 5, 20, 20, -200, -130); //mouth g.DrawArc(Pens.Black, w / 20 * 10 - 25, h / 20 * 8, 50, 50, -180, -180); base.OnPaint(e); } static void Main() { Application.Run(new StickFigure()); } }