/// <summary> /// Draws an Image in parts to form a horizontally waving image. /// </summary> /// <param name="image">The image to draw.</param> /// <param name="step">How many steps to iterate through for the wave.</param> /// <param name="timer">The timer the wave should act with.</param> /// <param name="rate">The rate which the wave should move at.</param> /// <param name="amp">How far the wave will offset the image.</param> /// <param name="freq">How frequent the wave should repeat.</param> /// <param name="x">The x position to draw the image from.</param> /// <param name="y">The y position to draw the image from.</param> static public void ImageWaveX(OtterDrawables.Image image, int step, float timer, float rate, float amp, float freq, float x = 0, float y = 0) { for (var yy = 0; yy < image.Height; yy += step) { yy = (int)Util.Clamp(yy, image.Height); var xx = (int)Util.SinScale(timer * rate + yy * freq, -amp, amp); ImageClip(image, new Rectangle(0, yy, image.Width, step), x + xx, y); } }
/// <summary> /// Draws an Image in parts to form a vertically waving image. /// </summary> /// <param name="image">The image to draw.</param> /// <param name="step">How many steps to iterate through for the wave.</param> /// <param name="timer">The timer the wave should act with.</param> /// <param name="rate">The rate which the wave should move at.</param> /// <param name="amp">How far the wave will offset the image.</param> /// <param name="freq">How frequent the wave should repeat.</param> /// <param name="x">The x position to draw the image from.</param> /// <param name="y">The y position to draw the image from.</param> static public void ImageWaveY(OtterDrawables.Image image, int step, float timer, float rate, float amp, float freq, float x = 0, float y = 0) { for (var xx = 0; xx < image.Width; xx += step) { xx = (int)Util.Clamp(xx, image.Width); var yy = (int)Util.SinScale(timer * rate + xx * freq, -amp, amp); ImageClip(image, new Rectangle(xx, 0, step, image.Height), x, y + yy); } }
/// <summary> /// Renders a clipped Image to the current target Surface. /// </summary> /// <param name="image">the Image to render.</param> /// <param name="clip">The portion of the Image to render.</param> /// <param name="x">The x offset to position the Image at.</param> /// <param name="y">The y offset to position the Image at.</param> static public void ImageClip(OtterDrawables.Image image, Rectangle clip, float x = 0, float y = 0) { var tempRect = image.ClippingRegion; image.ClippingRegion = clip; image.Render(x, y); image.ClippingRegion = tempRect; }