//You may use the following two functions to create a texture and use it, not creating a texture every frame! public static Texture2D CreateCircleTexture(int Radius, Color color) { Radius = (int)MathCompanion.Clamp(Radius, 1, Radius); int Diameter = 2 * Radius; Color[] Pixels = new Color[Diameter * Diameter]; Vector2 PointIterator = Vector2.Zero; Vector2 Center = Radius * Vector2.One; for (int i = 0; i < Diameter; i++) { for (int j = 0; j < Diameter; j++) { PointIterator.X = j; PointIterator.Y = i; if ((Center - PointIterator).Length() <= Radius) { Pixels[i * Diameter + j] = color; } //else // Pixels[i * Diameter + j] = Color.Transparent; } } Texture2D texture = new Texture2D(Setup.GraphicsDevice, Diameter, Diameter); texture.SetData(Pixels); return(texture); }
public static bool AddLayer(string Name, int Value) { if (LayerWithValue.Count >= Maximum) { return(false); } if (LayerWithValue.ContainsValue(Value * 0.01f)) { return(false); } if (LayerWithValue.ContainsKey(Name)) { return(false); } LayerWithValue.Add(Name, MathCompanion.Clamp(Value * 0.01f, 0, 0.19f)); return(true); }
public void Update(GameTime gameTime) { if (!Finished) { if (!Paused) { TimeCounter = MathCompanion.Clamp(TimeCounter + (float)gameTime.ElapsedGameTime.TotalSeconds, 0, TimeDuration); } if (TimeCounter >= TimeDuration) { FinishedButIsLooping = false; Finished = true; if (ReverseAfterFinishing) { ReverseKeyFrame(); } if (PlayAfterFinishing) { Play(); PlayAfterFinishing = false; } if (IsLooping) { FinishedButIsLooping = true; Play(); } } } else if (ReverseAfterFinishing) { ReverseKeyFrame(); } }