static void Main(string[] args) { // 7 IFigure dc7 = new Circle(new Point(0.0, -50.0), 50.0); IFigure dr7 = new Rectangle(new Point(50, 50), new Point(150, 50), new Point(150, 150), new Point(50, 150)); IFigure dt7 = new Triangle(new Point(-150, 50), new Point(-50, 50), new Point(-100, 150)); CompositeFigure cf7 = new CompositeFigure(dc7, dr7, dt7); AShower shower = new WindowShower(100.0, 100.0); User user = new User(); user.AddFigure(dc7); user.AddFigure(dr7); user.AddFigure(dt7); //user.Show(shower); user.DecorateWithShadow(2); user.AddFigure(cf7); user.DelFigure(cf7); user.MakeComposite(0, 1, 2); user.DecorateWithBorder(0); user.Show(shower); user.Undo(5); user.Show(shower); Console.ReadKey(); }
public static void DrawCircle(Circle circle, Color color) { GLUtil.SetColor(color); Gl.glBegin(Gl.GL_LINE_LOOP); PlotCircleVertices(circle.X, circle.Y, circle.Radius); Gl.glEnd(); }
public void Stage1_Prototype_circle() { IFigure ci = new Circle( new Point(-10.0, -10.0), 5.0 ); IFigure ci1 = ci.Clone(); Assert.IsNotNull(ci1); }
/// <summary> /// Checks all the vertices of a polygon and against a point. /// If that point is within the radius of a vertex, then the index to that vertex is returned. /// Otherwise -1 is returned. /// </summary> /// <param name="radius">The radius the position must come within for a vertex to be selected.</param> /// <param name="position">The poisition to check against the vertices</param> /// <param name="polygon">The polygon which will have it's vertices checked. A null polygon will return -1</param> /// <returns>Index to vertex in the radius of the position or minus one if no suitable vertex can be found.</returns> private int FindSelectedVertex(Point position, ConvexPolygon polygon, int radius) { if (polygon == null) { return -1; } for (int i = 0; i < polygon.Vertices.Count; i++) { Circle circle = new Circle(polygon.Vertices[i].X, polygon.Vertices[i].Y, radius); if (circle.Intersects(position)) { return i; } } return -1; }
private void ReadLevel() { this.updating = true; var d = new OpenFileDialog(); if (d.ShowDialog() == DialogResult.OK) { this.ClearLevel(); var level = new Level(); level.SetFileName(d.FileName); this.lstLevel.Items.Add(level); XmlDocument xml = new XmlDocument(); xml.Load(d.FileName); level.Read(xml["level"]); foreach (XmlElement el in xml["level"]["actors"]) { Actor actor = new Actor(); actor.Read(el); } foreach (XmlElement el in xml["level"]["physics"]) { Physic p; if (el.Name == "circle") p = new Circle(); else if (el.Name == "polygon") p = new Polygon(); else { MessageBox.Show(string.Format("unsupported physic '{0}'. Element skipped.", el.Name)); continue; } p.Read(el); } } this.updating = false; this.UpdateControls(); this.GetCurrent().SelectedItem = this.GetCurrent().Items[0]; }
internal static void DrawCircle(Point point, int radius, Color color) { Circle circle = new Circle(point.X, point.Y, radius); DrawCircle(circle, color); }