示例#1
0
文件: Pyramid.cs 项目: Anovi-Soft/KGG
 public Pyramid(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 top, Brush[] color)
 {
     triangles[0] = new Triangle(a, b, c) { Color = color[0] };
     triangles[1] = new Triangle(c, d, a) { Color = color[0] };
     triangles[2] = new Triangle(a, top, b) { Color = color[1] };
     triangles[3] = new Triangle(b, top, c) { Color = color[2] };
     triangles[4] = new Triangle(c, top, b) { Color = color[3] };
     triangles[5] = new Triangle(d, top, a) { Color = color[4] };
 }
示例#2
0
        /// <summary>
        /// Split Rectangle to 2^(n+1) triangles
        /// </summary>
        /// <param name="n"></param>
        /// <returns></returns>
        public IEnumerable<Triangle> Triangulation(uint n)
        {
            var triangles = new Triangle(A, B, C).Triangulation(n)
                .Concat(new Triangle(C, D, A).Triangulation(n));
            foreach (var z in triangles)
                z.Color = Color;

            return triangles;
        }
示例#3
0
        public void DrawFigure(Triangle triangle)
        {
            var polygon = new Polygon();
            new[]{triangle.A, triangle.B, triangle.C}
                .Select(a => new Point(300 + a.XX * 50, 300 + a.YY * 50))
                .ToList<Point>()
                .ForEach(polygon.Points.Add);
            polygon.Fill = polygon.Stroke = triangle.Color;
            polygon.StrokeThickness = 0.35;
            canvas.Children.Add(polygon);

        }
示例#4
0
 public void DrawTriangle(Triangle triangle)
 {
     var halfWidth = MapWidth / 2;
     var halfHeight = MapHeight / 2;
     var x1 = (int)triangle.A.XX;
     var y1 = (int)triangle.A.YY;
     var x2 = (int)triangle.B.XX;
     var y2 = (int)triangle.B.YY;
     var x3 = (int)triangle.C.XX;
     var y3 = (int)triangle.C.YY;
     bitmap.FillTriangle(
         x1 + halfWidth,
         y1 + halfHeight,
         x2 + halfWidth,
         y2 + halfHeight,
         x3 + halfWidth,
         y3 + halfHeight,
         triangle.Color);
 }