Пример #1
0
        public void Execute(IList <Dot> dots)
        {
            string promptValue = UserPrompter.ShowDialog("Введите радиус кластера", "Введите радиус кластера");

            if (int.TryParse(promptValue, out int radius) && radius > 0)
            {
                IList <Cluster> clusterList = analyzer.SearchClusters(radius - DrawDots.DOT_RADIUS, dots);

                drawDotsCommand.Execute(clusterList.SelectMany(d => d.Dots).ToList());

                using (Graphics g = Graphics.FromImage(MainWindow.ImageBox))
                {
                    foreach (var cluster in clusterList)
                    {
                        var pen  = new Pen(RandomColors.GetColor(cluster.Number));
                        int x    = (int)(cluster.RadiusDot.X - cluster.Radius - DrawDots.DOT_RADIUS);
                        int y    = (int)(cluster.RadiusDot.Y - cluster.Radius - DrawDots.DOT_RADIUS);
                        int size = (int)(cluster.Radius + DrawDots.DOT_RADIUS) * 2;
                        g.DrawEllipse(pen, x, y, size, size);

                        DrawText(g, cluster);
                    }
                }
                MainWindow.ImageBox = (Image)MainWindow.ImageBox.Clone();
            }
        }
Пример #2
0
 public void RandomColorsGUI(RandomAvatar ra, RandomColors rc)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Shared Color", GUILayout.Width(80));
     EditorGUILayout.LabelField(rc.ColorName, EditorStyles.textField, GUILayout.Width(80));
     EditorGUILayout.LabelField("Color Table", GUILayout.Width(80));
     rc.ColorTable = (SharedColorTable)EditorGUILayout.ObjectField(rc.ColorTable, typeof(SharedColorTable), false, GUILayout.ExpandWidth(true));
     EditorGUILayout.EndHorizontal();
 }
Пример #3
0
    public Bitmap GenerateBitmapMendelbrot(double criticalPointZx, double criticalPointZy, double circleRadius, int IterationMax)
    {
        Color[] colors = RandomColors.Generate(colorsCount);

        double ER2 = circleRadius * circleRadius;

        double PixelWidth  = (CxMax - CxMin) / iXmax;
        double PixelHeight = (CyMax - CyMin) / iYmax;

        int Iteration;

        double Cx, Cy;

        /* Z=Zx+Zy*i  ;   Z0 = 0 */
        double Zx, Zy;
        double Zx2, Zy2; /* Zx2=Zx*Zx;  Zy2=Zy*Zy  */


        Parallel.For(0, iYmax, iY => {
            Cy = CyMin + iY * PixelHeight;
            if (Math.Abs(Cy) < PixelHeight / 2)
            {
                Cy = 0.0;
            }

            for (int iX = 0; iX < iXmax; iX++)
            {
                Cx = CxMin + iX * PixelWidth;

                Zx  = criticalPointZx;
                Zy  = criticalPointZy;
                Zx2 = Zx * Zx;
                Zy2 = Zy * Zy;

                for (Iteration = 0; Iteration < IterationMax && ((Zx2 + Zy2) < ER2); Iteration++)
                {
                    Zy  = 2 * Zx * Zy + Cy;
                    Zx  = Zx2 - Zy2 + Cx;
                    Zx2 = Zx * Zx;
                    Zy2 = Zy * Zy;
                }

                SetPixel(iX, iY, colors[Iteration % colorsCount]);
            }
        });

        for (int x = 0; x < iXmax; x++)
        {
            for (int y = 0; y < iYmax; y++)
            {
                FractalBitmap.SetPixel(x, y, bitmapColors[x, y]);
            }
        }

        return(FractalBitmap);
    }
 public void RandomColorsGUI(RandomAvatar ra, RandomWardrobeSlot rws, RandomColors rc)
 {
     EditorGUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("Shared Color", GUILayout.Width(80));
     rc.CurrentColor = EditorGUILayout.Popup(rc.CurrentColor, rws.PossibleColors, GUILayout.Width(80));
     rc.ColorName    = rws.PossibleColors[rc.CurrentColor];
     EditorGUILayout.LabelField("Color Table", GUILayout.Width(80));
     rc.ColorTable = (SharedColorTable)EditorGUILayout.ObjectField(rc.ColorTable, typeof(SharedColorTable), false, GUILayout.ExpandWidth(true));
     EditorGUILayout.EndHorizontal();
 }
Пример #5
0
    private void Awake()
    {
        //if (Colors == null)
        {
            //Colors = Resources.Load<AllRandomColors>("RingColors");
        }
        if (Colors.List.Count == 0)
        {
            Colors.List.Add(new RandomColors(Color.white, Color.red));
        }

        _randColor = Colors.List[Random.Range(0, Colors.List.Count)];
    }
Пример #6
0
        public bool RandomColorsGUI(RandomAvatar ra, RandomWardrobeSlot rws, RandomColors rc)
        {
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Shared Color", GUILayout.Width(80));
            rc.CurrentColor = EditorGUILayout.Popup(rc.CurrentColor, rws.PossibleColors, GUILayout.Width(80));
            rc.ColorName    = rws.PossibleColors[rc.CurrentColor];
            EditorGUILayout.LabelField("Color Table", GUILayout.Width(80));
            rc.ColorTable = (SharedColorTable)EditorGUILayout.ObjectField(rc.ColorTable, typeof(SharedColorTable), false, GUILayout.ExpandWidth(true));
            bool retval = GUILayout.Button("\u0078", EditorStyles.miniButton, GUILayout.ExpandWidth(false));

            EditorGUILayout.EndHorizontal();
            return(retval);
        }
Пример #7
0
        public void Execute(int parameter = 50)
        {
            Point screSize   = MainWindow.GetDrawableSize();
            var   randomDots = new List <Dot>(parameter);

            randomDots.AddRange(Enumerable.Range(0, parameter)
                                .Select(variable => new Dot
            {
                X = Random.Next(0, screSize.X),
                Y = Random.Next(0, screSize.Y),
                C = Random.Next(0, RandomColors.RandomColorNum())
            }));
            AddNesList(randomDots);
        }
Пример #8
0
        public void Execute(IList <Dot> dots)
        {
            Point screeSize = MainWindow.GetDrawableSize();
            var   image     = new Bitmap(screeSize.X, screeSize.Y);

            using (Graphics g = Graphics.FromImage(image))
            {
                g.Clear(Color.White);
                foreach (Dot dot in dots)
                {
                    g.FillEllipse(RandomColors.GetBrush(dot.C), dot.X - DOT_RADIUS, dot.Y - DOT_RADIUS, 2 * DOT_RADIUS,
                                  2 * DOT_RADIUS);
                }
            }

            MainWindow.ImageBox = image;
        }
Пример #9
0
        public void RandomWardrobeSlotGUI(RandomAvatar ra, RandomWardrobeSlot rws)
        {
            // do random colors
            // show each possible item.
            string name = "<null>";

            if (rws.WardrobeSlot != null)
            {
                name = rws.WardrobeSlot.name;
            }

            GUIHelper.FoldoutBar(ref rws.GuiFoldout, name + " (" + rws.Chance + ")", out rws.Delete);
            if (rws.GuiFoldout)
            {
                GUIHelper.BeginVerticalPadded(10, new Color(0.75f, 0.75f, 0.75f));
                rws.Chance = EditorGUILayout.IntSlider("Weighted Chance", rws.Chance, 1, 100);
                if (rws.PossibleColors.Length > 0)
                {
                    if (GUILayout.Button("Add Shared Color"))
                    {
                        rws.AddColorTable = true;
                    }
                    RandomColors delme = null;
                    foreach (RandomColors rc in rws.Colors)
                    {
                        if (RandomColorsGUI(ra, rws, rc))
                        {
                            delme = rc;
                        }
                    }
                    if (delme != null)
                    {
                        rws.Colors.Remove(delme);
                        EditorUtility.SetDirty(this.target);
                        AssetDatabase.SaveAssets();
                    }
                }
                else
                {
                    GUILayout.Label("Wardrobe Recipe has no Shared Colors");
                }
                GUIHelper.EndVerticalPadded(10);
            }
        }
Пример #10
0
    // Start is called before the first frame update
    void Start()
    {
        changedcolor = false;
        turret.SetActive(false);
        turrettwo.SetActive(false);
        shooterone.SetActive(false);
        shootertwo.SetActive(false);
        madearoom = false;

        Color pickedcolor = RandomColors.selectcolor();

        thisbackground.GetComponent <SpriteRenderer>().color = pickedcolor;

        if (!firstroom)
        {
            createtiles();
            spawnturrets();
        }
    }
Пример #11
0
        private void DrawText(Graphics g, Cluster cluster)
        {
            GraphicsPath myPath = new GraphicsPath();

            string     stringText = $"{cluster.Number}";
            FontFamily family     = new FontFamily("Arial");
            int        fontStyle  = (int)FontStyle.Regular;
            int        emSize     = (int)cluster.Radius / 2;
            Point      origin     = new Point(cluster.RadiusDot.X - emSize * stringText.Length / 3,
                                              cluster.RadiusDot.Y - emSize / 2);
            StringFormat format = StringFormat.GenericDefault;

            myPath.AddString(stringText,
                             family,
                             fontStyle,
                             emSize,
                             origin,
                             format);

            g.SmoothingMode = SmoothingMode.AntiAlias;

            g.FillPath(RandomColors.GetBrush(cluster.Number), myPath);
            //g.DrawPath(new Pen(Brushes.Black,2), myPath);
        }
Пример #12
0
 public RandomColorsSettingsAction(RandomColors randomColors, ColorSettingsProvider colorSettingsProvider)
 {
     this.randomColors          = randomColors;
     this.colorSettingsProvider = colorSettingsProvider;
 }