public void TestReact() { var f = new LowerBoundFunction<int, Int32Order>(); var x = new[] {1, 1, 3, 5, 6, 9}.ToList(); Assert.That(f.React(3, x.ToLog(Δ1.Empty), 4.ToLog(false)), Is.EqualTo(3.ToLog(false))); Assert.That(f.React(3, x.ToLog(Δ1.Empty), 4.ToLog(true)), Is.EqualTo(3.ToLog(false))); Assert.That(f.React(3, x.ToLog(Δ1.Empty), 5.ToLog(true)), Is.EqualTo(3.ToLog(false))); Assert.That(f.React(3, x.ToLog(Δ1.Empty), 3.ToLog(true)), Is.EqualTo(2.ToLog(true))); Assert.That(f.React(3, x.Mutate(Expressions.Numbers(5).ToSub(), (key, j) => 20), 4.ToLog(false)), Is.EqualTo(3.ToLog(false))); Assert.That(f.React(3, x.Mutate(Expressions.Numbers(3).ToSub(), (key, j) => 3), 4.ToLog(false)), Is.EqualTo(4.ToLog(true))); }
/// <summary> /// Draws a hollow rectangle whose center is position, of width lineWidth (default 1px, does not exceed width) /// </summary> /// <param name="batch"> SpriteBatch for drawing </param> /// <param name="position"> Center of the rectangle </param> /// <param name="color"> Color of the rectangle </param> /// <param name="dimensions"> Dimensions of the rectangle </param> /// <param name="rotation"> Rotation in radians about the center </param> /// <param name="lineWidth"> Width in pixels of the line </param> public static void DrawRectangleOutline(SpriteBatch batch, Vector2 position, Color color, Vector2 dimensions, float rotation, float lineWidth = 1) { if (!CanDraw) return; var dim2 = dimensions/2; var corners = new[] { position + new Vector2(-dim2.X + lineWidth, -dim2.Y + lineWidth), position + new Vector2(-dim2.X + lineWidth, dim2.Y - lineWidth), position + new Vector2(dim2.X - lineWidth, dim2.Y - lineWidth), position + new Vector2(dim2.X - lineWidth, -dim2.Y + lineWidth), position + new Vector2(-dim2.X + lineWidth, -dim2.Y + lineWidth) }; corners = corners.Mutate(v => v.RotateAbout(position, rotation)).ToArray(); var scale = new Vector2(0, lineWidth); for (int i = 0; i < 4; i++) { var segment = (corners[i + 1] - corners[i]); scale.X = segment.Length() + lineWidth; batch.Draw(pixel1x1, corners[i], null, color, (float) segment.AsAngle(), Vector2.Zero, scale, SpriteEffects.None, 0); } }