Exemplo n.º 1
0
        private void button4_Click(object sender, EventArgs e)
        {
            nbHarry = 6;
            nbFrames = 0;
            InitDurationAndRecord();
            LstFrame.Clear();
            pack = Pack.BuildPack(6, Convert.ToInt32(nudBig.Value), 305, Convert.ToInt32(numericUpDown2.Value));

            g.Clear(SystemColors.Control);
            pack.Draw(g);
            timer1.Enabled = true;
        }
Exemplo n.º 2
0
        public static Pack BuildPack(int circleNb, int numBig, int diametreMax, int yCircle)
        {
            Pack pack = new Pack() { DiametreMax = diametreMax };
            R = diametreMax;

            // Create circles
            circles = new List<Circle>() { new Circle() { num = 1 }, new Circle() { num = 2 }, new Circle() { num = 3 } };
            if (circleNb > 3) circles.Add(new Circle() { num = 4 });
            if (circleNb > 4) circles.Add(new Circle() { num = 5 });
            if (circleNb > 5) circles.Add(new Circle() { num = 6 });

            // Big One position
            int bigOnePosition = numBig;

            // Radius
            List<double> rayon = new List<double>();

            //if (circleNb == 6)
            //{
            //    rayon.Add(1.0);
            //    rayon.Add(rayon[0] * 0.8);
            //    rayon.Add(rayon[1] * 0.9);
            //    rayon.Add(rayon[2] * 0.95);
            //    rayon.Add(rayon[3] * 0.975);
            //    rayon.Add(rayon[4] * 1);
            //}

            //2015_03_24 définition position en dur (dans un 1er temps) des cercles englobants
            if (circleNb == 6)
            {
                circles[0].BoundingCircle_x = 400;
                circles[0].BoundingCircle_y = 400;
                circles[0].BoundingCircle_r = 100; // Millieu

                circles[1].BoundingCircle_x = 200;
                circles[1].BoundingCircle_y = 450;
                circles[1].BoundingCircle_r = 100; // Gauche

                circles[2].BoundingCircle_x = 400;
                circles[2].BoundingCircle_y = 600;
                circles[2].BoundingCircle_r = 100; // Gauche

                circles[3].BoundingCircle_x = 280;
                circles[3].BoundingCircle_y = 230;
                circles[3].BoundingCircle_r = 100; // Gauche

                circles[4].BoundingCircle_x = 600;
                circles[4].BoundingCircle_y = 450;
                circles[4].BoundingCircle_r = 100; // Gauche

                circles[5].BoundingCircle_x = 510;
                circles[5].BoundingCircle_y = 230;
                circles[5].BoundingCircle_r = 100; // Gauche

                foreach (Circle c in circles)
                {
                    c.x = c.BoundingCircle_x;
                    c.y = c.BoundingCircle_y;
                    c.r = c.BoundingCircle_r /3;
                }
            }

            return pack;

            if (circleNb == 6)
            {

                int parent = 0;
                int fils = 1;

                // Un Y n'est possible que sur les noeuds 2 à 4
                // puisque le 1er noeud n'a pas de parent, on ne peut pas faire de Y
                if (yCircle == 1) yCircle = 2;
                // On ne peut pas dépasser 4 car il n'y a plus assez de fils pour faire un Y
                if (yCircle > 3) yCircle = 4;
                for (int i = 0; fils < circleNb; i++)
                {
                    circles[parent].next.Add(circles[fils]); circles[fils].previous = circles[parent];
                    if (yCircle == parent + 1)
                    {
                        // On est dans le cas où on a 2 enfants à ce noeud
                        // On reclacul l'angleWithPrevious du fils courant avant de passer au suivant.
                        double min = 0;
                        min = circles[fils].angleWithPrevious = RandomManager.getDouble2(min, Math.PI / 2);

                        fils++;
                        circles[parent].next.Add(circles[fils]); circles[fils].previous = circles[parent];
                        circles[fils].angleWithPrevious = RandomManager.getDouble2(-Math.PI / 2, min / 6);
                    }
                    if (yCircle < parent + 1)
                        circles[fils].angleWithPrevious = circles[parent].angleWithPrevious + RandomManager.getDouble2(-0.8, 0.8);
                    parent++; fils++;
                }
            }

            circlesInitial = new List<Circle>();

            // Création des cercles dans la représentation initiale des cercles.
            foreach (var item in circles)
                circlesInitial.Add(new Circle() { x = item.x, y = item.y, num = item.num, r = item.r, angleWithPrevious = item.angleWithPrevious, angleWithPreviousVelocity = item.angleWithPreviousVelocity });

            // Hiérarchisation de la représentation initiale des cercles.
            return pack;
        }