Exemplo n.º 1
0
        private void Initialize()
        {
            Cursor.Hide();
            this.WindowState = FormWindowState.Maximized;
            w = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
            h = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;

            goryokakuList = new List <Goryokaku>();

            Pen[]  pp     = { Pens.Blue, Pens.Red, Pens.Lime, Pens.Magenta, Pens.Cyan, Pens.Yellow, Pens.White };
            Random random = new Random();

            for (int i = 0; i < 20; i++)
            {
                Goryokaku go         = new Goryokaku(pp[random.Next(pp.Length)]);
                int       cx         = random.Next(this.w);
                int       cy         = random.Next(this.h);
                double    rate       = random.NextDouble() + 0.2;
                double    startTheta = random.NextDouble() * 6.28;
                string    halfMoon   = "";
                for (int j = 0; j < 5; j++)
                {
                    halfMoon += random.Next(100) > 50 ? "1" : "0";
                }
                GoryokakuGenerator.Prepare(go, cx, cy, rate, startTheta, halfMoon);
                goryokakuList.Add(go);
            }
            Refresh();
            timer1.Start();
        }
Exemplo n.º 2
0
        public static void Prepare(Goryokaku go, double cx, double cy, double rate, double startTheta, string halfMoon)
        {
            double r     = DEFAULT_R;
            double r2    = r + 10;
            double r21   = r2 - 40;
            double rh1   = r + 15;
            double rh2   = r + 6;
            double theta = startTheta;

            r   *= rate;
            r2  *= rate;
            r21 *= rate;
            rh1 *= rate;
            rh2 *= rate;

            for (int i = 0; i < 5; i++)
            {
                // ★★★ 外側の五芒星を描くための座標
                int zx1 = (int)(Math.Cos(theta) * r2 + cx);
                int zy1 = (int)(Math.Sin(theta) * r2 + cy);
                int zx2 = (int)(Math.Cos(theta + DELTA36) * r21 + cx);
                int zy2 = (int)(Math.Sin(theta + DELTA36) * r21 + cy);
                int zx3 = (int)(Math.Cos(theta + DELTA72) * r2 + cx);
                int zy3 = (int)(Math.Sin(theta + DELTA72) * r2 + cy);

                go.PointList1.Add(new Point(zx1, zy1));
                go.PointList1.Add(new Point(zx2, zy2));
                go.PointList1.Add(new Point(zx3, zy3));

                // ★★★ 半月堡
                if (halfMoon[i] == '1')
                {
                    List <Point> pointList4a = new List <Point>();
                    List <Point> pointList4b = new List <Point>();
                    double       vx1         = zx2 - zx1;
                    double       vy1         = zy2 - zy1;
                    double       vx2         = zx3 - zx2;
                    double       vy2         = zy3 - zy2;

                    double xx1 = zx1 + vx1 * 0.6;
                    double yy1 = zy1 + vy1 * 0.6;
                    double xx2 = Math.Cos(theta + DELTA36) * rh1 + cx;
                    double yy2 = Math.Sin(theta + DELTA36) * rh1 + cy;
                    double xx3 = zx3 - vx2 * 0.6;
                    double yy3 = zy3 - vy2 * 0.6;

                    //Console.WriteLine("{0}, {1} と {2}, {3} の中点 = {4}, {5}", zx1, zy1, zx2, zy2, xx1, yy1);

                    pointList4a.Add(new Point((int)xx1, (int)yy1));
                    pointList4a.Add(new Point((int)xx2, (int)yy2));
                    pointList4a.Add(new Point((int)xx3, (int)yy3));
                    go.PointLists.Add(pointList4a);

                    xx1 = zx1 + vx1 * 0.7;
                    yy1 = zy1 + vy1 * 0.7;
                    xx2 = Math.Cos(theta + DELTA36) * rh2 + cx;
                    yy2 = Math.Sin(theta + DELTA36) * rh2 + cy;
                    xx3 = zx3 - vx2 * 0.7;
                    yy3 = zy3 - vy2 * 0.7;
                    pointList4b.Add(new Point((int)xx1, (int)yy1));
                    pointList4b.Add(new Point((int)xx2, (int)yy2));
                    pointList4b.Add(new Point((int)xx3, (int)yy3));
                    go.PointLists.Add(pointList4b);
                }

                // ★★★ へこみのある五芒星
                MakePointList(go.PointList2, theta, DEFAULT_R, cx, cy, 0.75, true, rate);
                MakePointList(go.PointList3, theta, DEFAULT_R - 10, cx, cy, 0.6, false, rate);

                theta += DELTA72;
            }
        }