void Start() { circle circle = new circle("circle", 3); shape square = new square("square", 2, 3); Debug.Log(circle.Area()); }
private void Form1_Load(object sender, EventArgs e) { var sb = new StringBuilder(); var rec1 = new rectangle(); this.shps.Text += rec1.heigth.ToString() + " " + rec1.width.ToString() + "\r\n"; var rec2 = new rectangle(); this.shps.Text += rec2.heigth.ToString() + " " + rec2.width.ToString() + "\r\n"; var tr1 = new triangle(); this.shps.Text += tr1.a + " " + tr1.b + " " + tr1.c + "\r\n"; var tr2 = new triangle(); this.shps.Text += tr2.a + " " + tr2.b + " " + tr2.c + "\r\n"; var ccl1 = new circle(); var ccl2 = new circle(); rec1.insertShape(tr1); rec1.insertShape(ccl1); tr1.insertShape(tr2); //rec1 - composition, rec2- composition chi, ccl2- composition chi shapes.Add(rec1); shapes.Add(rec2); shapes.Add(ccl2); }
static void Main() { All[] alls = new All[4]; int a = int.Parse(Console.ReadLine()); switch (a) { case 1: alls[0] = new circle(); alls[0].GD(); break; case 2: alls[1] = new Cube(); alls[1].GD(); break; case 3: alls[2] = new delta(); alls[2].GD(); break; } Console.ReadLine(); }
public static BaseShape createShape(string type) { BaseShape shape = null; switch (type) { case "三角形": shape = new triangle(); shape.type = type; break; case "圆形": shape = new circle(); shape.type = type; break; case "正方形": shape = new rectangle(); shape.type = type; break; case "矩形": shape = new square(); shape.type = type; break; } return(shape); }
private void button18_Click(object sender, EventArgs e) { circle c = new circle(); double d; d = c.circ(Convert.ToInt32(textBox1.Text)); textBox1.Text = Convert.ToString(d); }
static void Main(string[] args) { square s1 = new square(5); rectangle r1 = new rectangle(5, 6); rectangle r2 = new rectangle(6, 6); circle c1 = new circle(5); ArrayList list = new ArrayList(); list.Add(r1); list.Add(s1); list.Add(c1); foreach (var x in list) { Console.Write("{0} ", x); } list.Sort(); Console.WriteLine("\nArray list after sorting"); foreach (var x in list) { Console.Write("{0} ", x); } List <geom_shape> list1 = new List <geom_shape>(); list1.Add(r1); list1.Add(s1); list1.Add(c1); Console.WriteLine("\nList before sorting"); foreach (var x in list1) { Console.Write("{0} ", x); } list1.Sort(); Console.WriteLine("\nList after sorting"); foreach (var x in list1) { Console.Write("{0} ", x); } Console.WriteLine(""); Matrix3dimensional <geom_shape> figure = new Matrix3dimensional <geom_shape>(4, 4, 4, null); figure[0, 0, 0] = r1; figure[1, 1, 1] = c1; figure[2, 2, 2] = s1; figure[1, 2, 3] = r2; Console.WriteLine(figure.ToString()); SimpleStack <geom_shape> Stack = new SimpleStack <geom_shape>(); Stack.Push(r1); Stack.Push(r2); Stack.Push(s1); Stack.Push(c1); while (Stack.Count > 0) { Console.WriteLine(Stack.Pop()); } Console.ReadKey(); }
public void BVHTest1() { BVHTree2 bvh = new BVHTree2(); var c = new circle(vec2.zero, 10); bvh.Add(c.bound, c); Assert.IsFalse(false, "1 should not be prime"); }
static void Main() { rectangle rect = new rectangle(5, 4); square square = new square(5); circle circle = new circle(5); ArrayList l1 = new ArrayList(); l1.Add(circle); l1.Add(rect); l1.Add(square); Console.WriteLine("ArrayList:"); foreach (object i in l1) { Console.Write(i.ToString() + " "); } Console.Write("\nList:"); List <geometr_figur> l2 = new List <geometr_figur>(); l2.Add(circle); l2.Add(rect); l2.Add(square); Console.WriteLine("\nПеред сортировкой:"); foreach (object i in l2) { Console.Write(i.ToString() + " "); } l2.Sort(); Console.WriteLine("\nПосле сортировки:"); foreach (object i in l2) { Console.Write(i.ToString() + " "); } Console.WriteLine(""); Console.WriteLine("Стек"); SimpleStack <geometr_figur> stack = new SimpleStack <geometr_figur>(); stack.Push(rect); stack.Push(square); stack.Push(circle); while (stack.Count > 0) { geometr_figur f = stack.Pop(); Console.WriteLine(f); } Console.WriteLine("\nМатрица"); Matrix <geometr_figur> matrix = new Matrix <geometr_figur>(3, 3, 3, new FigureMatrixCheckEmpty()); matrix[0, 0, 0] = rect; matrix[1, 1, 1] = square; matrix[2, 2, 2] = circle; Console.WriteLine(matrix.ToString()); }
static void Main(string[] args) { rectangle rect = new rectangle(10, 10); circle circ = new circle(20); square sqr = new square(15); ArrayList figures_array_list = new ArrayList(); figures_array_list.Add(rect); figures_array_list.Add(circ); figures_array_list.Add(sqr); Console.WriteLine("ArrayList:"); for (int i = 0; i < figures_array_list.Count; i++) { Console.WriteLine(figures_array_list[i].ToString()); } figures_array_list.Sort(); Console.WriteLine("Sorted:"); for (int i = 0; i < figures_array_list.Count; i++) { Console.WriteLine(figures_array_list[i].ToString()); } List <abstract_figure> figure_list_t = new List <abstract_figure> (); figure_list_t.Add(circ); figure_list_t.Add(rect); figure_list_t.Add(sqr); Console.WriteLine("List<T>"); foreach (var i in figure_list_t) { Console.WriteLine(i.ToString()); } figure_list_t.Sort(); Console.WriteLine("Sorted:"); foreach (var i in figure_list_t) { Console.WriteLine(i.ToString()); } Console.WriteLine("3d Sparse-matrix:"); Matrix <abstract_figure> figure_matrix = new Matrix <abstract_figure>(10, 10, 10, null); figure_matrix[1, 1, 1] = circ; figure_matrix[9, 0, 9] = sqr; figure_matrix[6, 9, 1] = rect; Console.Write(figure_matrix.ToString()); Console.WriteLine("Stack:"); SimpleStack <abstract_figure> figure_stack = new SimpleStack <abstract_figure>(); figure_stack.push(circ); figure_stack.push(rect); figure_stack.push(sqr); for (int i = 0; i < 3; i++) { Console.WriteLine(figure_stack.pop().ToString()); } Console.ReadKey(); }
public void ComputePerimeterTest() { double expected = 0; circle input = new circle(); input.Radius = 0; double actual = ShapeHelper.ComputePerimeter(input); Assert.AreEqual(expected, actual); }
static void Main(string[] args) { rectangle rectangle = new rectangle(23.21, 23.23); rectangle.getArea(); circle circle = new circle(23.12); circle.getArea(); Console.WriteLine("area of rectangle is" + rectangle.getArea()); Console.WriteLine("area of circle is" + circle.getArea()); Console.ReadLine(); }
// этот скрипт накинут на камеру и запускается сразу после генерации камеры в игровом движке void Start() { int count_elem = Random.Range(5, 20); //количество елементов int ran_elem; // тип елемента // обьяление существующих елементов trapeze trapeze_el; triangle triangle_el; circle circle_el; square square_el; // Массив обьектов ArrayList ms = new ArrayList(); for (int i = 0; i < count_elem; i++) { ran_elem = Random.Range(0, 3); if (ran_elem == 0) // Если ran_elem 0 то создается трапеция { trapeze_el = new trapeze(); trapeze_el.get_date(); ms.Add(trapeze_el); } else if (ran_elem == 1) // Если ran_elem 1 то создается треугольник { triangle_el = new triangle(); triangle_el.get_date(); ms.Add(triangle_el); } else if (ran_elem == 2) // Если ran_elem 2 то создается круг { circle_el = new circle(); circle_el.get_date(); ms.Add(circle_el); } else // иначе квадрат { square_el = new square(); square_el.get_date(); ms.Add(square_el); } } // это не работает и лучше его не трогать... Оно здесь для красоты // for (int b = 0; b < ms.Count; b++){ // Debug.Log("ELEMENT #"+b); // Debug.Log(ms[b].get_date()); // } }
static void Main(string[] args) { circle a = new circle(3); circle b = new circle(4); circle d = a; d.Diameter = 5; Console.WriteLine("a is {0}", a.Diameter); // shows 5 Console.WriteLine("b is {0}", b.Diameter); // shows 4 Console.WriteLine("d is {0}", d.Diameter); // shows 5 }
public static void Ex9() { double r = 20; circle rad = new circle(); rad.r = r; rad.Run(); Console.WriteLine("圓心(X,Y):(15,25)"); Console.WriteLine("圓半徑:" + r); Console.WriteLine("圓面積:" + rad.r); Console.ReadLine(); }
static void Main(string[] args) { rectangle rec = new rectangle(5, 6); rec.Print(); square sq = new square(5); sq.Print(); circle cir = new circle(5); cir.Print(); Console.ReadKey(); }
public void ComputePerimeterTest() { double expected = 0; circle input = new circle(); input.Radius = 0; CircleService operation = new CircleService(); operation.Target = input; double actual = operation.ComputePerimeter(); Assert.AreEqual(expected, actual); }
static void Start(string[] args) { circle obj2 = new circle(); obj2.Calculate(20, (3.14)); decimal a = obj2.Cal(60, (3.14)); Console.WriteLine($"area of the circle from Return Method is {a}"); obj2.Calcy(); int b = obj2.Calcu(); Console.WriteLine($"area of the circle from Return Method is {b}"); Console.ReadKey(); }
public Form1() { InitializeComponent(); //создание объектов cirс = new circle[4]; cirс[0] = new circle(new Point(0, 100), "Right", false, Brushes.Red); cirс[1] = new circle(new Point(1085, 200), "Left", true, Brushes.Blue); cirс[2] = new circle(new Point(0, 300), "Right", true, Brushes.Red); cirс[3] = new circle(new Point(1085, 400), "Left", true, Brushes.Blue); //подписка на обработчик события cirс[0].stopm += cirс[1].StopMove; cirс[1].stopm += cirс[2].StopMove; cirс[2].stopm += cirс[3].StopMove; cirс[3].stopm += cirс[0].StopMove; }
public static circle[] GetCircles() { Random rng = new Random(); circle[] circles = new circle[8];//rng.Next(5, 12)]; for (int i = 0; i < circles.Length; i++) { circles[i].k = (double)(rng.Next(40)); circles[i].h = (double)(rng.Next(40)); circles[i].r = (double)(rng.Next(6)) + 2.5; circles[i].max_r = (rng.Next(20)) + 4; circles[i].counter = 0; circles[i].Color = consoleColors[rng.Next(consoleColors.Length)]; circles[i].dir_r = false; } return(circles); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { label = EditorGUI.BeginProperty(position, label, property); { circle obj = (circle)fieldInfo.GetValue(property.serializedObject.targetObject); Rect contentPosition = EditorGUI.PrefixLabel(position, label); contentPosition.height = 16f; EditorGUIUtility.labelWidth = 16f; obj.o = MathExGUI.vec2Field(contentPosition, "o:", obj.o, false); contentPosition.y += 16f; EditorGUIUtility.labelWidth = 48f; obj.r = EditorGUI.FloatField(contentPosition, new GUIContent("Radius:"), obj.r); } EditorGUI.EndProperty(); }
public static void Main(string[] args) { // Shapes collection List <shape> shapes = new List <shape>(); Console.WriteLine("Hello to Shape World"); circle c = new circle(0, 0, 3.2); shapes.Add(c); shapes.Add(new circle(0, 0, 4.0)); // Add your other shapes here....... // foreach (var s in shapes) { Console.WriteLine("Shape: {0}", s.getName()); } }
protected override void BuildRenderTree(RenderTreeBuilder builder) { int par_id = (Parent as CompUsedColors).UsedColors_List.IndexOf(Color); circle c = new circle() { cx = (9 - par_id) * 30 + 15, cy = 15, r = 10, fill = Color, stroke = "black", stroke_width = 1, onclick = "notEmpty", }; SvgHelper1.Cmd_Render(c, 0, builder); base.BuildRenderTree(builder); }
public static void Main() { my0926 my = new my0926(); my.assign(2, 3); my.add(); circle circle = new circle(); circle.setradius(10); circle.assign(5, 4); circle.move(1, 1); circle.area(); ellipse ellipse = new ellipse(); ellipse.setradius(10); ellipse.setradius2(20); ellipse.area(); }
static void Main(string[] args) { circle cir = new circle(); double pi = 3.14159; Console.WriteLine("Enter the radius: "); cir.radius = Convert.ToDouble(Console.ReadLine()); Console.WriteLine("\n"); //çevre cir.circumference = 2 * pi * cir.radius; //alan cir.area = pi * cir.radius * cir.radius; Console.WriteLine("Area of the circle: "); Console.WriteLine(cir.area); Console.WriteLine("\n"); Console.WriteLine("Circumference of the circle: "); Console.WriteLine(cir.circumference); }
public static shape createShape(string shapeKind, string shapeName) { shape myShape = null; if (shapeKind.Equals("square")) { myShape = new square(shapeName); } else if (shapeKind.Equals("circle")) { myShape = new circle(shapeName); } else if (shapeKind.Equals("rectangle")) { myShape = new rectangle(shapeName); } else if (shapeKind.Equals("delta")) { myShape = new delta(shapeName); } return(myShape); }
public circle Add_Visual_Point(MyPoint p, bool b) { circle c = new circle { cx = p.X, cy = p.Y, stroke = _parent.ChartSettings.PointStroke, fill = _parent.ChartSettings.PointFill, stroke_width = _parent.ChartSettings.PointLineWidth, }; if (b) { c.r = _parent.ChartSettings.PointRadius; } else { c.r = _parent.ChartSettings.PointRadius * 0.8; } return(c); }
static void Main(string[] args) { var MyMenu = new Menu(); //Reads string into Menu._MenuOptionList[firstemptyindex] // //in simpler terms, build your menu MyMenu.MenuOptionAdd("3) Calculate the area of a triangle.", 3); MyMenu.MenuOptionAdd("Choose from the following options", 0); MyMenu.MenuOptionAdd("1) Circles and circular shapes.", 1); MyMenu.MenuOptionAdd("2) Calculate the area of a square or rectangle.", 2); MyMenu.MenuOptionAdd("4) Open an OpenGL Window.", 4); int showMenu = 1; while (showMenu > 0) { //When showMenu returns a 0, then Program stops showMenu = MyMenu.ShowMenu(); switch (showMenu) { case 1: var docircles = new circle(); docircles.CircleMenu(); break; case 2: var myRectangleArea = new rectangle(); var rectarea = myRectangleArea.Area(); if (rectarea > 0.00) { Console.WriteLine($"The area of your rectangle or square is: {rectarea}"); } else { Console.WriteLine("Something went wrong. Sorry, quitting."); } break; case 3: var myTriangleArea = new triangle(); var triarea = myTriangleArea.Area(); if (triarea > 0.00) { Console.WriteLine($"The area of your triangle is: {triarea}"); } else { Console.WriteLine("Something went wrong. Sorry, quitting."); } break; case 4: var win = new Window(600, 600); win.Run(1, 10); break; default: Console.Clear(); System.Environment.Exit(0); break; } Console.WriteLine("Press any key to return to main menu"); Console.ReadKey(); } /* TODO: * * Add more math classes/methods * * */ }
public static void Draw()// Graphics g) { Pen lePen = new Pen(Color.White, 3); foreach (DrawingObject obj in objectIdentifier) //iterates through the objects { switch (obj.shapeType) { case 2: //line { Line temp = (Line)drawingList[obj.indexNo]; lePen.Color = temp.AccessContourColor; lePen.Width = temp.AccessLineWidth; gcodeString[gcodeStringIndex].AppendFormat("(Line color{0} )\r\n", temp.AccessContourColor); temp.Draw(mainScale); break; } case 3: //rectangle { rectangle temp = (rectangle)drawingList[obj.indexNo]; lePen.Color = temp.AccessContourColor; // lePen.Width = temp.AccessLineWidth; gcodeString[gcodeStringIndex].AppendFormat("(Rect color{0} )\r\n", temp.AccessContourColor); temp.Draw(); // lePen, g); break; } case 4: //circle { circle temp = (circle)drawingList[obj.indexNo]; lePen.Color = temp.AccessContourColor; lePen.Width = temp.AccessLineWidth; gcodeString[gcodeStringIndex].AppendFormat("(Circle color{0} )\r\n", temp.AccessContourColor); if (mainScale == 0) { mainScale = 1; } temp.Draw(); // lePen, g, mainScale); break; } case 5: //polyline { polyline temp = (polyline)drawingList[obj.indexNo]; lePen.Color = temp.AccessContourColor; lePen.Width = temp.AccessLineWidth; gcodeString[gcodeStringIndex].AppendFormat("(Poly color{0} )\r\n", temp.AccessContourColor); if (mainScale == 0) { mainScale = 1; } temp.Draw(mainScale); break; } case 6: //arc { arc temp = (arc)drawingList[obj.indexNo]; lePen.Color = temp.AccessContourColor; lePen.Width = temp.AccessLineWidth; gcodeString[gcodeStringIndex].AppendFormat("(Arc color{0} )\r\n", temp.AccessContourColor); if (mainScale == 0) { mainScale = 1; } temp.Draw(); // lePen, g, mainScale); break; } } } // g.Dispose(); //not disposed because "g" is get from the paintbackground event.. lePen.Dispose(); }
void drawHand(double pos, double length, string color, double Line_Width, double satelite_Pos, double satelite_R, double animationDuration) { pos = pos * 6; //MyPoint p = GetPoint(pos, length); //_Svg.Children.Add(new line() //{ // x1 = ClockSettings.radius_Origin, // y1 = ClockSettings.radius_Origin, // x2 = p.x, // y2 = p.y, // opacity = 1, // stroke = color, // stroke_width = Line_Width, // stroke_linecap = strokeLinecap.round, //}); pos = pos - 90; line l = new line() { x1 = 0, y1 = 0, x2 = length, y2 = 0, opacity = 1, stroke = color, stroke_width = Line_Width, stroke_linecap = strokeLinecap.round, transform = "translate (" + ClockSettings.radius_Origin + "," + ClockSettings.radius_Origin + ") rotate(" + pos + ")" }; l.Children.Add(new animateTransform() { attributeName = "transform", attributeType = "xml", by = 360, dur = animationDuration, repeatCount = "indefinite", type = "rotate", }); _Svg.Children.Add(l); //MyPoint p2 = GetPoint(pos, ClockSettings.radius_90_Percent * satelite_Pos); //_Svg.Children.Add(new circle() //{ // cx =p2.x, // cy= p2.y, // r = Line_Width/2 * satelite_R, // fill = color, //}); circle c = new circle() { cx = ClockSettings.radius_90_Percent * satelite_Pos, cy = 0, r = Line_Width / 2 * satelite_R, fill = color, transform = "translate (" + ClockSettings.radius_Origin + "," + ClockSettings.radius_Origin + ") rotate(" + pos + ")" }; c.Children.Add(new animateTransform() { attributeName = "transform", attributeType = "xml", by = 360, dur = animationDuration, repeatCount = "indefinite", type = "rotate", }); _Svg.Children.Add(c); }
public void Generate_SVG() { _Svg = new svg { id = "svgPaint", width = par_width, height = par_height, xmlns = "http://www.w3.org/2000/svg", }; _Svg.Children.Add(new rect { width = par_width, height = par_height, fill = "wheat", stroke = "red", stroke_width = 1, }); foreach (var item in (parent as CompBlazorPaint).ObjectsList.OrderBy(x => x.SequenceNumber)) { switch (item.ObjectType) { case BPaintOpbjectType.HandDraw: _Svg.Children.Add(drawPath(item as BPaintHandDraw)); if (item.Selected) { MyPointRect p_rect = BPaintFunctions.Get_Border_Points(item as BPaintHandDraw); _Svg.Children.Add(new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "red", stroke_width = 1, style = "opacity:0.2", }); } break; case BPaintOpbjectType.Line: BPaintLine currLine = item as BPaintLine; _Svg.Children.Add(drawLine(currLine)); if (item.Selected) { circle c1 = new circle() { cx = currLine.StartPosition.x + currLine.PositionChange.x, cy = currLine.StartPosition.y + currLine.PositionChange.y, r = currLine.width * 1.5, fill = "wheat", stroke = currLine.Color, stroke_width = 2, }; if (currLine.Scale.x != 0 || currLine.Scale.y != 0) { c1.transform = "scale(" + currLine.Scale.x + "," + currLine.Scale.y + ")"; } _Svg.Children.Add(c1); circle c2 = new circle() { cx = currLine.end.x + currLine.PositionChange.x, cy = currLine.end.y + currLine.PositionChange.y, r = currLine.width * 1.5, fill = "wheat", stroke = currLine.Color, stroke_width = 2, }; if (currLine.Scale.x != 0 || currLine.Scale.y != 0) { c2.transform = "scale(" + currLine.Scale.x + "," + currLine.Scale.y + ")"; } _Svg.Children.Add(c2); MyPointRect p_rect = BPaintFunctions.Get_Border_Points(item as BPaintLine); _Svg.Children.Add(new rect { x = p_rect.x, y = p_rect.y, width = p_rect.width, height = p_rect.height, fill = "none", stroke = "red", stroke_width = 1, style = "opacity:0.2", }); } break; default: break; } } }
static bool insidecircle(circle a, int x, int y) { return (((x - a.x) * (x - a.x)) + ((y - a.y) * (y - a.y))) <= a.r * a.r; }