コード例 #1
0
        public FormAutoCorrect()
        {
            InitializeComponent();
            this.DialogResult = DialogResult.None;
            ComboBoxHandler.ComboBoxPopulateClear(comboBoxAlbum, Properties.Settings.Default.AutoCorrectFormAlbum, "");
            ComboBoxHandler.ComboBoxPopulateClear(comboBoxAuthor, Properties.Settings.Default.AutoCorrectFormAuthor, "");
            ComboBoxHandler.ComboBoxPopulateClear(comboBoxComments, Properties.Settings.Default.AutoCorrectFormComments, "");
            ComboBoxHandler.ComboBoxPopulateClear(comboBoxDescription, Properties.Settings.Default.AutoCorrectFormDescription, "");
            ComboBoxHandler.ComboBoxPopulateClear(comboBoxTitle, Properties.Settings.Default.AutoCorrectFormTitle, "");
            checkBoxAlbum.Checked       = Properties.Settings.Default.UseAutoCorrectFormAlbum;
            checkBoxAuthor.Checked      = Properties.Settings.Default.UseAutoCorrectFormAuthor;
            checkBoxComments.Checked    = Properties.Settings.Default.UseAutoCorrectFormComments;
            checkBoxDescription.Checked = Properties.Settings.Default.UseAutoCorrectFormDescription;
            checkBoxTitle.Checked       = Properties.Settings.Default.UseAutoCorrectFormTitle;
            textBoxKeywords.Text        = "";

            AutoCorrect autoCorrect = AutoCorrect.ConvertConfigValue(Properties.Settings.Default.AutoCorrect);

            if (autoCorrect.UpdateDescription)
            {
                checkBoxDescription.Enabled = false;
                comboBoxDescription.Enabled = false;
                kryptonLabelDescriptionBecomesAlbum.Text = "Album values will overwrite Descriptions values, as setup in Config";
            }
        }
コード例 #2
0
 public string ToQueryString()
 {
     return("?autocorrect=" + AutoCorrect.ToString() +
            Helpers.AddParameter("pii", PII) +
            Helpers.AddParameter("listId", ListId) +
            Helpers.AddParameter("classify", Classify) +
            Helpers.AddParameter("language", Language));
 }
コード例 #3
0
        public Generator()
        {
            for (int i = 0; i < 6; i++)
            {
                myElevationTex[i] = new Texture(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize, PixelInternalFormat.R32f);
                myElevationTex[i].setName(String.Format("Elevation Tex {0}", i));
                myBiomeTex[i] = new Texture(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize, PixelInternalFormat.Rgba32f);
                myBiomeTex[i].setName(String.Format("Biome Tex {0}", i));
            }

            myElevationMap = new CubemapTexture(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize, PixelInternalFormat.R32f);
            myElevationMap.setName("Elevation Cubemap");

            myBiomeMap = new CubemapTexture(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize, PixelInternalFormat.Rgba32f);
            myBiomeMap.setName("Biome Cubemap");

            List <ShaderDescriptor> shadersDesc = new List <ShaderDescriptor>();

            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "World Editor.shaders.applyElevation-cs.glsl"));
            ShaderProgramDescriptor sd = new ShaderProgramDescriptor(shadersDesc);

            myApplyElevationShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "World Editor.shaders.applyHeat-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myApplyHeatShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "World Editor.shaders.applyMoisture-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myApplyMoistureShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            shadersDesc = new List <ShaderDescriptor>();
            shadersDesc.Add(new ShaderDescriptor(ShaderType.ComputeShader, "World Editor.shaders.applyBiome-cs.glsl"));
            sd = new ShaderProgramDescriptor(shadersDesc);
            myGenerateBiomeShader = Renderer.resourceManager.getResource(sd) as ShaderProgram;

            //setup generators
            myElevationGenerator   = new ModuleTree(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize);
            myElevationFractals[0] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal0") as Fractal;
            myElevationFractals[1] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal") as Fractal;
            myElevationFractals[2] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal2") as Fractal;
            myElevationFractals[3] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal3") as Fractal;
            myElevationFractals[4] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal4") as Fractal;
            myElevationFractals[5] = myElevationGenerator.addModule(Module.Type.Fractal, "fractal5") as Fractal;
            AutoCorrect Eac = myElevationGenerator.addModule(Module.Type.AutoCorect, "autocorrect") as AutoCorrect;

            myHeatGenerator     = createHeatGenerator();
            myMoistureGenerator = createMoistureGenerator();
        }
コード例 #4
0
    public static ModuleBase CavesAndMountains(uint seed = 10000)
    {
        AccidentalNoise.Gradient ground_gradient = new AccidentalNoise.Gradient(0, 0, 0, 1);

        // lowlands
        Fractal          lowland_shape_fractal = new Fractal(FractalType.BILLOW, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 2, 0.25, seed);
        AutoCorrect      lowland_autocorrect   = new AutoCorrect(lowland_shape_fractal, 0, 1);
        ScaleOffset      lowland_scale         = new ScaleOffset(.5, -0.45, lowland_autocorrect);
        ScaleDomain      lowland_y_scale       = new ScaleDomain(lowland_scale, null, 0);
        TranslatedDomain lowland_terrain       = new TranslatedDomain(ground_gradient, null, lowland_y_scale);

        // highlands
        Fractal          highland_shape_fractal = new Fractal(FractalType.FBM, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 4, 2, seed);
        AutoCorrect      highland_autocorrect   = new AutoCorrect(highland_shape_fractal, 0, 1.5);
        ScaleOffset      highland_scale         = new ScaleOffset(1, 0, highland_autocorrect);
        ScaleDomain      highland_y_scale       = new ScaleDomain(highland_scale, null, 1);
        TranslatedDomain highland_terrain       = new TranslatedDomain(ground_gradient, null, highland_y_scale);

        // mountains
        Fractal          mountain_shape_fractal = new Fractal(FractalType.RIDGEDMULTI, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 8, 1, seed);
        AutoCorrect      mountain_autocorrect   = new AutoCorrect(mountain_shape_fractal, -1, 1);
        ScaleOffset      mountain_scale         = new ScaleOffset(0.3, 0.3, mountain_autocorrect);
        ScaleDomain      mountain_y_scale       = new ScaleDomain(mountain_scale, null, 1);
        TranslatedDomain mountain_terrain       = new TranslatedDomain(ground_gradient, null, mountain_y_scale);

        // terrain
        Fractal     terrain_type_fractal          = new Fractal(FractalType.FBM, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 3, 0.125, seed);
        AutoCorrect terrain_autocorrect           = new AutoCorrect(terrain_type_fractal, 0, 1);
        ScaleDomain terrain_type_y_scale          = new ScaleDomain(terrain_autocorrect, null, 0);
        Cache       terrain_type_cache            = new Cache(terrain_type_y_scale);
        Select      highland_mountain_select      = new Select(terrain_type_cache, highland_terrain, mountain_terrain, 0.55, 0.2);
        Select      highland_lowland_select       = new Select(terrain_type_cache, lowland_terrain, highland_mountain_select, 0.25, 0.15);
        Cache       highland_lowland_select_cache = new Cache(highland_lowland_select);
        Select      ground_select = new Select(highland_lowland_select_cache, 0, 1, 0.5, null);

        // caves
        Fractal          cave_shape           = new Fractal(FractalType.RIDGEDMULTI, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 1, 2, seed);
        Bias             cave_attenuate_bias  = new Bias(highland_lowland_select_cache, 0.9);
        Combiner         cave_shape_attenuate = new Combiner(CombinerTypes.MULT, cave_shape, cave_attenuate_bias);
        Fractal          cave_perturb_fractal = new Fractal(FractalType.FBM, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 6, 3, seed);
        ScaleOffset      cave_perturb_scale   = new ScaleOffset(1, 0, cave_perturb_fractal);
        TranslatedDomain cave_perturb         = new TranslatedDomain(cave_shape_attenuate, cave_perturb_scale, null);
        Select           cave_select          = new Select(cave_perturb, 1, 0, 0.4, 0);

        return(new Combiner(CombinerTypes.MULT, cave_select, ground_select) as ModuleBase);
    }
コード例 #5
0
        OnWorkbookStartup
        (
            Microsoft.Office.Interop.Excel.Application application
        )
        {
            Debug.Assert(application != null);

            AutoCorrect oAutoCorrect = application.AutoCorrect;

            if (!oAutoCorrect.AutoExpandListRange)
            {
                const String CheckboxPath =
                    "Office Button, Excel Options, Proofing, AutoCorrect Options,"
                    + " AutoFormat As You Type, Include new rows and columns in"
                    + " table"
                ;

                String Message =
                    "Excel's \"auto table expansion\" feature is turned off, and"
                    + " NodeXL cannot work properly without it.  Do you want"
                    + " NodeXL to turn it on for you?"
                    + "\n\n"
                    + " (You can turn it off later if necessary using "
                    + CheckboxPath
                    + ".)"
                ;

                if (MessageBox.Show(Message, FormUtil.ApplicationName,
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Warning,
                                    MessageBoxDefaultButton.Button1) ==
                    DialogResult.Yes)
                {
                    oAutoCorrect.AutoExpandListRange = true;
                }
                else
                {
                    FormUtil.ShowError(
                        "NodeXL will not work properly.  You should turn on"
                        + " Excel's auto table expansion feature using "
                        + CheckboxPath
                        + "."
                        );
                }
            }
        }
コード例 #6
0
        ModuleTree createMoistureGenerator()
        {
            ModuleTree generated = new ModuleTree(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize);
            Fractal    f         = generated.addModule(Module.Type.Fractal, "fractal") as Fractal;

            f.seed      = WorldParameters.seed;
            f.octaves   = WorldParameters.theMoistureOctaves;
            f.frequency = WorldParameters.theMoistureFrequency;

            AutoCorrect ac = generated.addModule(Module.Type.AutoCorect, "autocorrect") as AutoCorrect;

            ac.output.setName("Moisture Autocorrect");
            ac.source = f;

            generated.final.source = ac;

            return(generated);
        }
コード例 #7
0
        ModuleTree defaultMoistureGenerator()
        {
            ModuleTree generated = new ModuleTree(WorldParameters.theWorldSize, WorldParameters.theWorldSize);
            Fractal2d  f         = generated.createModule(Module.Type.Fractal2d, "Moisture Fractal") as Fractal2d;

            f.seed      = WorldParameters.seed;
            f.octaves   = WorldParameters.theMoistureOctaves;
            f.frequency = WorldParameters.theMoistureFrequency;

            AutoCorrect ac = generated.createModule(Module.Type.AutoCorrect, "Moisture AutoCorrect") as AutoCorrect;

            ac.output.setName("Moisture AutoCorrect");
            ac.source = f;

            generated.output = ac;

            return(generated);
        }
コード例 #8
0
        ModuleTree defaultElevationGenerator()
        {
            ModuleTree generator = new ModuleTree(WorldParameters.theWorldSize, WorldParameters.theWorldSize);
            Fractal2d  f         = generator.createModule(Module.Type.Fractal2d, "Elevation Fractal") as Fractal2d;

            f.output.setName("fractal");
            f.seed      = WorldParameters.seed;
            f.octaves   = WorldParameters.theTerrainOctaves;
            f.frequency = WorldParameters.theTerrainFrequency;

            AutoCorrect ac = generator.createModule(Module.Type.AutoCorrect, "Elevation AutoCorrect") as AutoCorrect;

            ac.output.setName("Elevation AutoCorrect");
            ac.source = f;

            generator.output = ac;

            return(generator);
        }
コード例 #9
0
        ModuleTree createHeatGenerator()
        {
            ModuleTree generator = new ModuleTree(WorldParameters.theWorldTextureSize, WorldParameters.theWorldTextureSize);
            Fractal    f         = generator.addModule(Module.Type.Fractal, "fractal") as Fractal;

            f.output.setName("Heat Fractal");
            f.seed      = WorldParameters.seed;
            f.octaves   = WorldParameters.theHeatOctaves;
            f.frequency = WorldParameters.theHeatFrequency;

            AutoCorrect ac = generator.addModule(Module.Type.AutoCorect, "autocorrect") as AutoCorrect;

            ac.output.setName("Heat Autocorrect");
            ac.source = f;

            Gradient sg = generator.addModule(Module.Type.Gradient, "south gradient") as Gradient;

            sg.output.setName("Heat South gradient");
            sg.x0 = 0; sg.x1 = 1; sg.y0 = 0; sg.y1 = 1;

            Gradient ng = generator.addModule(Module.Type.Gradient, "north gradient") as Gradient;

            ng.output.setName("Heat North gradient");
            ng.x0 = 0; ng.x1 = 1; ng.y0 = 1; ng.y1 = 0;

            //          ScaleDomain s = generator.addModule(Module.Type.ScaleDomain, "scaleDomain") as ScaleDomain;
            //          s.x = 1.0f;
            //          s.y = 0.1f;
            //          s.input = g;

            Combiner comb = generator.addModule(Module.Type.Combiner, "combiner") as Combiner;

            comb.output.setName("Heat Combiner");
            comb.inputs[0] = ac;
            comb.inputs[1] = sg;
            comb.inputs[2] = ng;
            comb.action    = Combiner.CombinerType.Multiply;

            generator.final.source = comb;

            return(generator);
        }
コード例 #10
0
        void updateElevation()
        {
            Renderer.device.pushDebugMarker("Update Elevation");

            AutoCorrect ac = myElevationGenerator.findModule("autocorrect") as AutoCorrect;

            ac.reset();

            //generate each face
            for (int i = 0; i < 6; i++)
            {
                myElevationFractals[i].output     = myElevationTex[i];
                myElevationFractals[i].face       = i;
                myElevationFractals[i].seed       = elevation.seed;
                myElevationFractals[i].function   = elevation.function;
                myElevationFractals[i].octaves    = elevation.octaves;
                myElevationFractals[i].frequency  = elevation.frequency;
                myElevationFractals[i].offset     = elevation.offset;
                myElevationFractals[i].lacunarity = elevation.lacunarity;
                myElevationFractals[i].gain       = elevation.gain;
                myElevationFractals[i].H          = elevation.H;
                myElevationFractals[i].update();
            }

            //find the min/max of all the faces together
            ac.findMinMax(myElevationTex);

            //correct all the images with the global min/max
            for (int i = 0; i < 6; i++)
            {
                ac.output = myElevationTex[i];
                ac.correct(myElevationFractals[i].output);
            }

            //update the elevation height map
            myElevationMap.updateFaces(myElevationTex);
            Renderer.device.popDebugMarker();
        }
コード例 #11
0
ファイル: wordapp.cs プロジェクト: imiyu/DiscUsage
        static int Main()
        {
            WordAppMain myWord        = new WordAppMain();
            int         return_Result = 0;

            // Create a word object that we can manipulate
            Application Word_App = null;
            Document    Word_doc = null;

            try
            {
                Word_App = new Application();
                Word_doc = new Document();
            }
            catch (Exception e)
            {
                Console.WriteLine("Can't create a word document " + e.ToString());
                return_Result = 1;
                goto Exit;
            }

            AutoCorrect        autocorrect = Word_App.AutoCorrect;
            AutoCorrectEntries autoEntries = autocorrect.Entries;

            string theEnd = "\nThe End";

            autoEntries.Add("Inntroduction", "Introduction");

            Documents Docs = Word_App.Documents;

            if (Docs == null)
            {
                Console.WriteLine("Docs is null");
            }
            else
            {
                Console.WriteLine("Docs exists:" + Docs.Count);
            }

            Word_App.Visible = true;
            _Document my_Doc = (_Document)Word_doc;

            Word_doc = Docs.Add(ref missing, ref missing, ref missing, ref missing);

            object start = 0;
            object end   = 0;
            Range  range = Word_doc.Range(ref missing, ref missing);

            // add text to the doc -- this contains some deliberate misspellings so that we can correct them in a short while
            range.Text = "Microsoft Word Interoperability Sample\n\nInntroduction:\n\nMicrosoft .NET will allow the creation of truly distributed XML Web services. These services will integrate and collaborate with a range of complementary services to work for customers in ways that today's internet companies can only dream of. Microsoft .NET will drive the Next Generation Internet and will shift the focus from individual Web sites or devices connected to the Internet, to constellations of computers, devices, and services that work together to deliver broader, richer solutions.\nFor more info go to:\n   ";

            // Wait so the starting state can be admired
            Thread.Sleep(2000);

            // Format the title
            Font fc = new Font();

            try
            {
                Console.WriteLine("Formatting the title");
                start            = 0; end = 40;
                range            = Word_doc.Range(ref start, ref end);
                range.Font.Size  = 24;
                range.Font.Bold  = 1;
                range.Font.Color = WdColor.wdColorGray30;
                start            = 40; end = 54;
                range            = Word_doc.Range(ref start, ref end);
                range.Font.Size  = 14;
            }
            catch (Exception e)
            {
                Console.WriteLine(" Font exception:{0}", e.ToString());
            }


            // Wait so the new formatting can be appreciated
            Thread.Sleep(3000);

            autocorrect.ReplaceTextFromSpellingChecker = true;
            // Fix inntroduction
            string           obj      = "Introduction";
            AutoCorrectEntry errEntry = autoEntries.Add("Inntroduction", obj);

            Words myWords  = Word_doc.Words;
            Range errRange = myWords[7];

            errEntry.Apply(errRange);

            // Add a caption to the window and get it back
            Window myWindow = Word_App.ActiveWindow;

            myWindow.Caption = "Managed Word execution from C# ";
            string gotCaption = myWindow.Caption;

            if (gotCaption.Equals("Managed Word execution from C# "))
            {
                Console.WriteLine("Caption assigned and got back");
                return_Result = 1;
            }
            Thread.Sleep(2000);

            // define the selection object, find and  replace text
            Selection mySelection = myWindow.Selection;

            try
            {
                start = 65; end = 69;
                range = Word_doc.Range(ref start, ref end);
                Console.WriteLine("The color of .NET is being changed");

                range.Font.Bold  = 16;
                range.Font.Color = WdColor.wdColorLavender;
            }
            catch (Exception e)
            {
                Console.WriteLine(" Font exception:{0}", e.ToString());
            }
            Thread.Sleep(2000);

            // underline the selected text
            range           = Word_doc.Range(ref start, ref end);
            range.Underline = (WdUnderline.wdUnderlineDouble);

            // add hyperlink and follow the hyperlink
            Hyperlinks my_Hyperlinks = Word_doc.Hyperlinks;

            // Make the range past the end of all document text
            mySelection.Start = 9999;
            mySelection.End   = 9999;
            range             = mySelection.Range;

            // Add a hyperlink
            string myAddress   = "http://go.microsoft.com/fwlink/?linkid=3269&clcid=0x409";
            object obj_Address = myAddress;

            Console.WriteLine("Adding hyperlink to the document");
            Hyperlink my_Hyperlink1 = my_Hyperlinks._Add(range, ref obj_Address, ref missing);

            Word_App.ActiveWindow.Selection.InsertAfter("\n");

            Thread.Sleep(5000);

            // Open a window to Hyperlink
            Process ie = Process.Start("iexplore.exe", my_Hyperlink1.Address);

            // Wait for a short spell to allow the page to be examined
            Thread.Sleep(10000);

            // close the browser first
            Console.WriteLine("Removing browser window");
            ie.Kill();

            // Display "The End"
            Word_App.ActiveWindow.Selection.InsertAfter(theEnd);
            Word_App.ActiveWindow.Selection.Start = 0;
            Word_App.ActiveWindow.Selection.End   = 0;
            Word_App.Activate();
            Thread.Sleep(5000);

            // Close Microsoft Word
            object myBool = WdSaveOptions.wdDoNotSaveChanges;

            Word_App.ActiveWindow.Close(ref myBool, ref missing);
Exit:
            return(return_Result);
        }
コード例 #12
0
ファイル: Form1.cs プロジェクト: PsychoTeras/RatKing
        public Form1()
        {
            InitializeComponent();

            Bitmap bitmap = new Bitmap(pictureBox1.Width, pictureBox1.Height);

            Gradient ground_gradient = new Gradient(0, 0, 0, 1);

            #region lowlands
            Fractal          lowland_shape_fractal = new Fractal(FractalType.BILLOW, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 2, 0.25, null);
            AutoCorrect      lowland_autocorrect   = new AutoCorrect(lowland_shape_fractal, 0, 1);
            ScaleOffset      lowland_scale         = new ScaleOffset(0.125, -0.45, lowland_autocorrect);
            ScaleDomain      lowland_y_scale       = new ScaleDomain(lowland_scale, null, 0);
            TranslatedDomain lowland_terrain       = new TranslatedDomain(ground_gradient, null, lowland_y_scale);
            #endregion

            #region highlands
            Fractal          highland_shape_fractal = new Fractal(FractalType.FBM, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 4, 2, null);
            AutoCorrect      highland_autocorrect   = new AutoCorrect(highland_shape_fractal, -1, 1);
            ScaleOffset      highland_scale         = new ScaleOffset(0.25, 0, highland_autocorrect);
            ScaleDomain      highland_y_scale       = new ScaleDomain(highland_scale, null, 0);
            TranslatedDomain highland_terrain       = new TranslatedDomain(ground_gradient, null, highland_y_scale);
            #endregion

            #region mountains
            Fractal          mountain_shape_fractal = new Fractal(FractalType.RIDGEDMULTI, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 8, 1, null);
            AutoCorrect      mountain_autocorrect   = new AutoCorrect(mountain_shape_fractal, -1, 1);
            ScaleOffset      mountain_scale         = new ScaleOffset(0.3, 0.15, mountain_autocorrect);
            ScaleDomain      mountain_y_scale       = new ScaleDomain(mountain_scale, null, 0.15);
            TranslatedDomain mountain_terrain       = new TranslatedDomain(ground_gradient, null, mountain_y_scale);
            #endregion

            #region terrain
            Fractal     terrain_type_fractal          = new Fractal(FractalType.FBM, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 3, 0.125, null);
            AutoCorrect terrain_autocorrect           = new AutoCorrect(terrain_type_fractal, 0, 1);
            ScaleDomain terrain_type_y_scale          = new ScaleDomain(terrain_autocorrect, null, 0);
            Cache       terrain_type_cache            = new Cache(terrain_type_y_scale);
            Select      highland_mountain_select      = new Select(terrain_type_cache, highland_terrain, mountain_terrain, 0.55, 0.2);
            Select      highland_lowland_select       = new Select(terrain_type_cache, lowland_terrain, highland_mountain_select, 0.25, 0.15);
            Cache       highland_lowland_select_cache = new Cache(highland_lowland_select);
            Select      ground_select = new Select(highland_lowland_select_cache, 0, 1, 0.5, null);
            #endregion

            #region caves
            Fractal          cave_shape           = new Fractal(FractalType.RIDGEDMULTI, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 1, 4, null);
            Bias             cave_attenuate_bias  = new Bias(highland_lowland_select_cache, 0.65);
            Combiner         cave_shape_attenuate = new Combiner(CombinerTypes.MULT, cave_shape, cave_attenuate_bias);
            Fractal          cave_perturb_fractal = new Fractal(FractalType.FBM, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 6, 3, null);
            ScaleOffset      cave_perturb_scale   = new ScaleOffset(0.5, 0, cave_perturb_fractal);
            TranslatedDomain cave_perturb         = new TranslatedDomain(cave_shape_attenuate, cave_perturb_scale, null);
            Select           cave_select          = new Select(cave_perturb, 1, 0, 0.75, 0);
            #endregion

            Combiner gound_cave_multiply = new Combiner(CombinerTypes.MULT, cave_select, ground_select);

            //EXAMPLE 1
            //Gradient ground_gradient = new Gradient(0, 0, 0, 1);


            //Fractal ground_shape_fractal = new Fractal(FractalType.FBM,
            //                                           BasisTypes.GRADIENT,
            //                                           InterpTypes.QUINTIC,
            //                                           6, 2, null);

            //ScaleOffset ground_scale = new Accidental.ScaleOffset(0.5, 0, ground_shape_fractal);
            //ScaleDomain ground_scale_y = new ScaleDomain(null, 0, ground_scale);
            //TranslatedDomain ground_perturb = new TranslatedDomain(ground_gradient, null, ground_scale_y);


            //Fractal ground_overhang_fractal = new Fractal(FractalType.FBM,
            //                                              BasisTypes.GRADIENT,
            //                                              InterpTypes.QUINTIC,
            //                                              6, 2, 23434);
            //ScaleOffset ground_overhang_scale = new ScaleOffset(0.2, 0, ground_overhang_fractal);
            //TranslatedDomain ground_overhang_perturb = new TranslatedDomain(ground_perturb, ground_overhang_scale, null);

            //Select ground_select = new Select(ground_overhang_perturb, 0, 1, 0.5, null);


            //EXAMPLE 2
            //Fractal cave_shape = new Accidental.Fractal(FractalType.RIDGEDMULTI, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 1, 2, 4533);
            //Select cave_select = new Accidental.Select(cave_shape, 1, 0, 0.6, 0);

            //Fractal cave_perturb_fractal = new Fractal(FractalType.FBM, BasisTypes.GRADIENT, InterpTypes.QUINTIC, 6, 3, null);
            //ScaleOffset cave_perturb_scale = new ScaleOffset(0.25, 0, cave_perturb_fractal);
            //TranslatedDomain cave_perturb = new TranslatedDomain(cave_select, cave_perturb_scale, null);


            SMappingRanges ranges = new SMappingRanges();

            //finally update our image
            for (int x = 0; x < bitmap.Width; x++)
            {
                for (int y = 0; y < bitmap.Height; y++)
                {
                    double p = (double)x / (double)bitmap.Width;
                    double q = (double)y / (double)bitmap.Height;
                    double nx, ny = 0.0;

                    nx = ranges.mapx0 + p * (ranges.mapx1 - ranges.mapx0);
                    ny = ranges.mapy0 + q * (ranges.mapy1 - ranges.mapy0);

                    double val = gound_cave_multiply.Get(nx * 6, ny * 3);

                    bitmap.SetPixel(x, y, Color.Black.Lerp(Color.White, val));
                }
            }

            pictureBox1.Image = bitmap;
        }
コード例 #13
0
ファイル: frmMain.cs プロジェクト: PsychoTeras/RatKing
        private unsafe void BtnGenerateLabyrinthClick(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;

            FractalType type    = (FractalType)cbLabyrinthType.SelectedItem;
            BasisTypes  basis   = (BasisTypes)cbLabyrinthBasis.SelectedItem;
            InterpTypes interp  = (InterpTypes)cbLabyrinthInterp.SelectedItem;
            int?        octaves = !string.IsNullOrEmpty(tbLabyrinthOctaves.Text)
                ? int.Parse(tbLabyrinthOctaves.Text)
                : (int?)null;
            double?frequency = !string.IsNullOrEmpty(tbLabyrinthFrequency.Text)
                ? double.Parse(tbLabyrinthFrequency.Text)
                : (double?)null;
            double?angle = !string.IsNullOrEmpty(tbLabyrinthAngle.Text)
                ? double.Parse(tbLabyrinthAngle.Text)
                : (double?)null;
            double?lacunarity = !string.IsNullOrEmpty(tbLabyrinthLacunarity.Text)
                ? double.Parse(tbLabyrinthLacunarity.Text)
                : (double?)null;

            _labOldSeed = cbLabyrinthRnd.Checked ? (uint?)Environment.TickCount : _labOldSeed;

            ModuleBase moduleBase = new Fractal(type, basis, interp, octaves, frequency, _labOldSeed,
                                                angle, lacunarity);

            if (chkLabyrinthAC.Checked)
            {
                double        acLow    = double.Parse(tbLabyrinthACLow.Text);
                double        acHigh   = double.Parse(tbLabyrinthACHigh.Text);
                CombinerTypes combType = (CombinerTypes)cbLabyrinthACCombine.SelectedItem;
                AutoCorrect   correct  = new AutoCorrect(moduleBase, acLow, acHigh);
                moduleBase = new Combiner(combType, correct, moduleBase);
            }

//            Bias bias = new Bias(moduleBase, 0.01);
//            Gradient gradient = new Gradient(0, 0, 50, 100);
//            moduleBase = new TranslatedDomain(moduleBase, gradient, bias);

            if (chkLabyrinthSel.Checked)
            {
                double selLow       = double.Parse(tbLabyrinthSelLow.Text);
                double selHigh      = double.Parse(tbLabyrinthSelHigh.Text);
                double selThreshold = double.Parse(tbLabyrinthSelThreshold.Text);
                double?selFalloff   = !string.IsNullOrEmpty(tbLabyrinthSelFalloff.Text)
                    ? double.Parse(tbLabyrinthSelFalloff.Text)
                    : (double?)null;
                moduleBase = new Select(moduleBase, selLow, selHigh, selThreshold, selFalloff);
            }

            if (pbLabyrinth.Image != null)
            {
                pbLabyrinth.Image.Dispose();
            }

            ushort     width = 500, height = 500;
            Bitmap     bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
            BitmapData data   = bitmap.LockBits(new Rectangle(0, 0, width, height),
                                                ImageLockMode.ReadWrite, bitmap.PixelFormat);

            byte *pRoughMap = (byte *)Memory.HeapAlloc(width * height);

            Parallel.For(0, height, y =>
            {
                int *row = (int *)data.Scan0 + (y * data.Stride) / 4;
                Parallel.For(0, width, x =>
                {
                    double p   = (double)x / width;
                    double q   = (double)y / height;
                    double val = moduleBase.Get(p, q);
                    pRoughMap[y * width + x] = (byte)Math.Abs(val - 1);
                    Color color = Color.Black.Lerp(Color.White, val);
                    row[x]      = color.ToArgb();
                });
            });

            using (ServerMap map = new ServerMap(width, height, 0, pRoughMap))
            {
                map.SaveToFile("RK.save");
            }
            Memory.HeapFree(pRoughMap);

            bitmap.UnlockBits(data);
            pbLabyrinth.Image = bitmap;

            Cursor = DefaultCursor;
        }