public static void Generate_Texture2D() { Game1.iterateGenerateFrame = true; if (FieldState != DataState.Updated) { //if (FieldState == DataState.Free) // Update_NewFieldSet(Game1.field); if (Update_FieldSet_Active == false) { Task.Factory.StartNew(Game1.Make_FieldSet_Copy); } Game1.iterateGenerateFrame = false; return; } FieldState = DataState.Active; int maxIterates, count = 0; int[,] mcount; int width = Game1.Width, height = Game1.Height; ScaleToTextureSize(out maxIterates, out mcount, width, height); if (Catmul_Spline.NewColourScale_Available) { ColourScale = Catmul_Spline.Get_NewColourScale(); } int mc, loop; Color[] frameCol = new Color[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { mc = mcount[j, i]; loop = 0; while (mc > ColourScale[loop] && loop < ColourRange) { loop++; } frameCol[count++] = Game1.mcolor[loop]; } } Game1.freshFrame[1 - Game1._fFdb].SetData(frameCol); Game1._fFdb = 1 - Game1._fFdb; FieldState = DataState.Free; Game1.iterateGenerateFrame = false; }
public static void Initialise(int colourRange, int fieldN) { ColourRange = colourRange; // FieldN = fieldN; // NewFieldSet = new float[fieldN, fieldN]; FieldState = DataState.Null; ColourScale = Catmul_Spline.Get_NewColourScale(); Update_NewFieldSet(); }
protected override void LoadContent() { font = Content.Load <SpriteFont>("Overlay"); TextHeight = (int)font.MeasureString("0").Y - 5; _1by1 = new Texture2D(GraphicsDevice, 1, 1); _1by1.SetData(new Color[1] { Color.White }); ColourScale = Catmul_Spline.Catmul_Init(graphics, _numColors); GenerateTexture.Initialise(_numColors, fieldN); }
/// <summary> /// Draw /// NOTE : PlotQuilt uses `Task.Factory` parallel routine and fills Texture framebuffer on completion. /// </summary> /// <param name="gameTime"></param> protected override void Draw(GameTime gameTime) { FPS++; if (TValues != null && TValues[0] != null) { for (int i = 0; i < TValues.Length; i++) { DebugWindow.Add("Tval" + TValues[i].qid.ToString(), TValues[i].running); } } DebugWindow.Update(); if (Update_Catmul()) { } GraphicsDevice.SetRenderTarget(null); GraphicsDevice.Clear(Color.Transparent); spriteBatch.Begin(); switch (programState) { case ProgramState.menu: QuiltOutline(); DrawQuilt(); DisplaySampleData(); switch (quiltType) { case QuiltType.Square: MenuText(Quilt, gameTime); break; case QuiltType.Hexagon: MenuText(Hexgn, gameTime); break; case QuiltType.Icon: MenuText(Icon1, gameTime); break; case QuiltType.Icon3: MenuText(Icon3, gameTime); break; default: break; } Draw_Colour_Band(5); break; case ProgramState.iterate: QuiltOutline(); DrawQuilt(); IterateText(); if (isPaused) { Draw_Colour_Band(_screenHit - 32); DisplaySampleData(); Paused(); } break; case ProgramState.sampling: Draw_Colour_Band(_screenHit - 32); DoSampling(_screenHit - 36); DrawQuilt(); SamplingText(); break; default: break; } Catmul_Spline.Draw(ref spriteBatch); Vector2 pos = new Vector2(800, 20); foreach (var line in DebugText) { spriteBatch.DrawString(font, line, pos, Color.White); pos.Y += 20; } DebugWindow.Draw(); spriteBatch.End(); base.Draw(gameTime); }
private bool Update_Catmul() { return(Catmul_Spline.Update(mouse, MaxHitCount < _numColors ? _numColors : MaxHitCount)); }