示例#1
0
        // todo: move in pool
        public void Reset(int outputWidth, int outputHeight, string seed,
                          BitmapImage input, int patternSizeX, int patternSizeY,
                          bool periodicInputX, bool periodicInputY,
                          bool inputPatternRotations, bool inputPatternReflections)
        {
            outputWidth  = Math.Max(outputWidth, 9);
            outputHeight = Math.Max(outputHeight, 9);

            Img_Input.Source = input;
            RenderOptions.SetBitmapScalingMode(Img_Input, BitmapScalingMode.NearestNeighbor);

            //Set up the input.

            Color[,] inputPixelGrid = new Color[input.PixelWidth, input.PixelHeight];
            Utilities.Convert(input, ref inputPixelGrid);

            state = new Generator.State(new Generator.Input(inputPixelGrid,
                                                            new Vector2i(patternSizeX, patternSizeY),
                                                            periodicInputX, periodicInputY,
                                                            inputPatternRotations,
                                                            inputPatternReflections),
                                        new Vector2i(outputWidth, outputHeight),
                                        Check_PeriodicOutputX.IsChecked.Value,
                                        Check_PeriodicOutputY.IsChecked.Value,
                                        HashSeed(seed));

            // apply
            Textbox_ViolationClearSize.Text = state.ViolationClearSize.ToString();
            Textbox_OutputWidth.Text        = outputWidth.ToString();
            Textbox_OutputHeight.Text       = outputHeight.ToString();
            Readonly_Seed.Text = seed;

            UpdateOutputTex();
        }