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);
        }
        public SvgDocument GenerateFlag()
        {
            SvgDocument SvgDoc = new SvgDocument()
            {
                Width  = FLAG_WIDTH,
                Height = FLAG_HEIGHT
            };

            FlagMainPattern mainPattern = GetRandomMainPattern();

            mainPattern.Apply(SvgDoc);

            return(SvgDoc);
        }
Exemple #3
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;
            }
        }
        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);
        }
Exemple #5
0
        public override void Draw(SvgDocument Svg, FlagMainPattern flag, PointF pos, float size, Color c, Random R)
        {
            string[] files      = Directory.GetFiles(Path.GetDirectoryName(Program.SavePath) + "/../../../RelatedProjects/FlagGeneration/Resources/CoatOfArms");
            string   chosenPath = files[R.Next(files.Length)];

            SvgDocument prefab = SvgDocument.Open(chosenPath);

            prefab.Width  = size;
            prefab.Height = size;
            prefab.X      = pos.X - size / 2;
            prefab.Y      = pos.Y - size / 2;
            SvgColourServer colServ = new SvgColourServer(c);

            prefab.Fill   = colServ;
            prefab.Stroke = colServ;
            foreach (SvgElement elem in prefab.Children)
            {
                FillElement(elem, colServ);
            }

            Svg.Children.Add(prefab);
        }
Exemple #6
0
 public abstract void Draw(SvgDocument Svg, FlagMainPattern flag, PointF pos, float size, float angle, Color c);
Exemple #7
0
 public override void Draw(SvgDocument Svg, FlagMainPattern flag, PointF center, float size, float angle, Color c)
 {
     flag.DrawCircle(Svg, center, size / 2, c);
 }
        public override void Draw(SvgDocument Svg, FlagMainPattern flag, PointF pos, float size, Color c, Random R)
        {
            Symbol symbol = flag.GetRandomSymbol();

            symbol.Draw(Svg, flag, pos, size, 0, c);
        }