Beispiel #1
0
        public override void Draw(SvgDocument Svg, FlagMainPattern flag, PointF center, float size, float angle, Color c)
        {
            int   numCorners  = 5;
            float startAngle  = angle + 180;
            float outerRadius = size * 0.5f;
            float innerRadius = outerRadius * 0.4f;

            int numVertices = numCorners * 2;

            PointF[] vertices = new PointF[numVertices];

            // Create vertices
            float angleStep = 360f / numVertices;

            for (int i = 0; i < numVertices; i++)
            {
                float curAngle    = startAngle + (i * angleStep);
                bool  outerCorner = i % 2 == 0;
                float radius      = outerCorner ? outerRadius : innerRadius;
                float x           = center.X + (float)(radius * Math.Sin(DegreeToRadian(curAngle)));
                float y           = center.Y + (float)(radius * Math.Cos(DegreeToRadian(curAngle)));
                vertices[i] = new PointF(x, y);
            }

            flag.DrawPolygon(Svg, vertices, c);
        }
Beispiel #2
0
        public override void Draw(SvgDocument Svg, FlagMainPattern flag, PointF pos, float size, Color c, Random R)
        {
            switch (GetRandomFrameType(R))
            {
            case FrameType.Circle:
                flag.DrawCircle(Svg, pos, size / 2, c);
                Color coaColor = ColorManager.GetRandomColor(new List <Color>()
                {
                    c
                });
                CoatOfArms coa = flag.GetRandomCoa();
                coa.Draw(Svg, flag, pos, size * 0.8f, coaColor, R);
                break;

            case FrameType.Star:
                int   numCorners  = R.Next(17) + 8;
                float startAngle  = 180;
                float outerRadius = size * 0.5f;
                float innerRadius = outerRadius * flag.RandomRange(0.6f, 0.95f);

                int      numVertices = numCorners * 2;
                PointF[] vertices    = new PointF[numVertices];

                // Create vertices
                float angleStep = 360f / numVertices;
                for (int i = 0; i < numVertices; i++)
                {
                    float curAngle    = startAngle + (i * angleStep);
                    bool  outerCorner = i % 2 == 0;
                    float radius      = outerCorner ? outerRadius : innerRadius;
                    float x           = pos.X + (float)(radius * Math.Sin(DegreeToRadian(curAngle)));
                    float y           = pos.Y + (float)(radius * Math.Cos(DegreeToRadian(curAngle)));
                    vertices[i] = new PointF(x, y);
                }

                flag.DrawPolygon(Svg, vertices, c);

                coaColor = ColorManager.GetRandomColor(new List <Color>()
                {
                    c
                });
                coa = flag.GetRandomCoa();
                coa.Draw(Svg, flag, pos, innerRadius * 2 * 0.8f, coaColor, R);
                break;
            }
        }
Beispiel #3
0
        public override void Draw(SvgDocument Svg, FlagMainPattern flag, PointF center, float size, float angle, Color c)
        {
            float startAngle  = angle + 180;
            float outerRadius = size * 0.5f;
            float innerRadius = outerRadius * RadiusRatio;

            int numVertices = NumSpikes * 2;

            PointF[] vertices = new PointF[numVertices];

            // Create vertices
            if (!HalfStar) // Full star
            {
                float angleStep = 360f / numVertices;
                for (int i = 0; i < numVertices; i++)
                {
                    float curAngle    = startAngle + (i * angleStep);
                    bool  outerCorner = i % 2 == 0;
                    float radius      = outerCorner ? outerRadius : innerRadius;
                    float x           = center.X + (float)(radius * Math.Sin(DegreeToRadian(curAngle)));
                    float y           = center.Y + (float)(radius * Math.Cos(DegreeToRadian(curAngle)));
                    vertices[i] = new PointF(x, y);
                }
            }
            else // Half star
            {
                startAngle -= 90;
                if (HalfStarMoved) // 50% chance to move center of half star so its the actual center
                {
                    center = new PointF(center.X + (float)(size / 4 * Math.Sin(DegreeToRadian(startAngle - 90))), center.Y + (float)(size / 4 * Math.Cos(DegreeToRadian(startAngle - 90))));
                }
                float angleStep = 180f / (numVertices - 2);
                for (int i = 0; i < numVertices; i++)
                {
                    float curAngle    = startAngle + ((i - 1) * angleStep);
                    bool  outerCorner = i % 2 == 1;
                    float radius      = i == 0 ? 0 : outerCorner ? outerRadius : innerRadius;
                    float x           = center.X + (float)(radius * Math.Sin(DegreeToRadian(curAngle)));
                    float y           = center.Y + (float)(radius * Math.Cos(DegreeToRadian(curAngle)));
                    vertices[i] = new PointF(x, y);
                }
            }

            flag.DrawPolygon(Svg, vertices, c);
        }