示例#1
0
 public static void Init()
 {
     currentFractal = Fractal.BuildDefault();
 }
示例#2
0
        private static Fractal readFlameNode(XmlNode flameNode, FractronConfig conf)
        {
            Fractal newFractal = new Fractal();
            Palette apoPalette = null;
            float   xSize      = 800.0f;
            float   ySize      = 600.0f;
            float   xCenter    = 0.0f;
            float   yCenter    = 0.0f;
            float   scale      = 100.0f;
            float   zoom       = 1.0f;
            float   rotate     = 0.0f;

            if (flameNode == null)
            {
                return(null);
            }

            newFractal.OriginalXml = flameNode;

            foreach (XmlAttribute attr in flameNode.Attributes)
            {
                if (attr.Name == "name")
                {
                    newFractal.Name = attr.Value;
                }
                else if (attr.Name == "version")
                {
                    newFractal.Version = attr.Value;
                }
                else if (attr.Name == "size")
                {
                    try{
                        string[] xyStr = attr.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                        xSize = float.Parse(xyStr[0]);
                        ySize = float.Parse(xyStr[1]);
                    }catch (Exception) {}
                }
                else if (attr.Name == "center")
                {
                    try{
                        string[] xyStr = attr.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                        xCenter = float.Parse(xyStr[0]);
                        yCenter = float.Parse(xyStr[1]);
                    }catch (Exception) {}
                }
                else if (attr.Name == "scale")
                {
                    readFloatAttr(attr, ref scale);
                }
                else if (attr.Name == "zoom")
                {
                    readFloatAttr(attr, ref zoom);
                }
                else if (attr.Name == "rotate")
                {
                    readFloatAttr(attr, ref rotate);
                }
                else if (attr.Name == "background")
                {
                    try{
                        string[] rgbStr = attr.Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                        newFractal.BackgroundColor.X = float.Parse(rgbStr[0]);
                        newFractal.BackgroundColor.Y = float.Parse(rgbStr[1]);
                        newFractal.BackgroundColor.Z = float.Parse(rgbStr[2]);
                        newFractal.BackgroundColor.W = 1.0f;
                    }catch (Exception) {}
                }
                else if (attr.Name == "brightness")
                {
                    readFloatAttr(attr, ref newFractal.Brightness);
                }
                else if (attr.Name == "gamma")
                {
                    readFloatAttr(attr, ref newFractal.Gamma);
                }
                else if (attr.Name == "vibrancy")
                {
                    readFloatAttr(attr, ref newFractal.Vibrancy);
                }
            }

            newFractal.SetCameraFromFlame(xSize, ySize, xCenter, yCenter, scale, zoom, rotate);

            foreach (XmlNode node in flameNode.ChildNodes)
            {
                if (node.Name == "xform")
                {
                    newFractal.Branches.Add(readBranchNode(node));
                }
                else if (node.Name == "palette")
                {
                    apoPalette = readPaletteNode(node, conf);
                }
                else if (node.Name == "color")                //handle the old style palettes
                {
                    if (apoPalette == null)
                    {
                        apoPalette = new Palette(256, 1, Palette.PaletteType.OneDimensional);
                        for (int i = 0; i < 256; i++)
                        {
                            apoPalette.SetPixel(i, 0, Color.White);
                        }
                    }

                    try{
                        int      index  = int.Parse(node.Attributes["index"].Value);
                        string[] rgbStr = node.Attributes["rgb"].Value.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
                        Color    c      = Color.FromArgb(
                            int.Parse(rgbStr[0]),
                            int.Parse(rgbStr[1]),
                            int.Parse(rgbStr[2]));
                        apoPalette.SetPixel(index, 0, c);
                    }
                    catch (Exception) {}
                }
            }

            if (apoPalette != null)
            {
                newFractal.Palette = apoPalette;
            }

            return(newFractal);
        }
示例#3
0
 public static void LoadNewFractal()
 {
     SetCurrentCopy(Fractal.BuildDefault());
 }