public void Transform_Operations_OnScalableAngle () { LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 360f, true); Matrix clone = lgb.Transform.Clone (); Matrix mul = clone.Clone (); Matrix m = new Matrix (); m.Scale (2, 1); m.Translate (rect.Width, rect.Height); m.Rotate (30f); clone.Multiply (mul, MatrixOrder.Append); lgb.MultiplyTransform (mul, MatrixOrder.Append); Assert.AreEqual (lgb.Transform, clone, "Multiply/Append"); clone.Multiply (mul, MatrixOrder.Prepend); lgb.MultiplyTransform (mul, MatrixOrder.Prepend); Assert.AreEqual (lgb.Transform, clone, "Multiply/Prepend"); clone.Rotate (45, MatrixOrder.Append); lgb.RotateTransform (45, MatrixOrder.Append); Assert.AreEqual (lgb.Transform, clone, "Rotate/Append"); clone.Rotate (45, MatrixOrder.Prepend); lgb.RotateTransform (45, MatrixOrder.Prepend); Assert.AreEqual (lgb.Transform, clone, "Rotate/Prepend"); clone.Scale (0.25f, 2, MatrixOrder.Append); lgb.ScaleTransform (0.25f, 2, MatrixOrder.Append); Assert.AreEqual (lgb.Transform, clone, "Scale/Append"); clone.Scale (0.25f, 2, MatrixOrder.Prepend); lgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend); Assert.AreEqual (lgb.Transform, clone, "Scale/Prepend"); clone.Translate (10, 20, MatrixOrder.Append); lgb.TranslateTransform (10, 20, MatrixOrder.Append); Assert.AreEqual (lgb.Transform, clone, "Translate/Append"); clone.Translate (30, 40, MatrixOrder.Prepend); lgb.TranslateTransform (30, 40, MatrixOrder.Prepend); Assert.AreEqual (lgb.Transform, clone, "Translate/Prepend"); clone.Reset (); lgb.ResetTransform (); Assert.AreEqual (lgb.Transform, clone, "Reset"); }
public void ScaleTransform_InvalidOrder () { LinearGradientBrush lgb = new LinearGradientBrush (pt1, pt2, c1, c2); lgb.ScaleTransform (1, 1, (MatrixOrder) Int32.MinValue); }
public void Transform_Operations () { LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 45f); Matrix clone = lgb.Transform.Clone (); Matrix mul = clone.Clone (); clone.Multiply (mul, MatrixOrder.Append); lgb.MultiplyTransform (mul, MatrixOrder.Append); Assert.AreEqual (lgb.Transform, clone, "Multiply/Append"); clone.Multiply (mul, MatrixOrder.Prepend); lgb.MultiplyTransform (mul, MatrixOrder.Prepend); Assert.AreEqual (lgb.Transform, clone, "Multiply/Prepend"); clone.Rotate (45, MatrixOrder.Append); lgb.RotateTransform (45, MatrixOrder.Append); Assert.AreEqual (lgb.Transform, clone, "Rotate/Append"); clone.Rotate (45, MatrixOrder.Prepend); lgb.RotateTransform (45, MatrixOrder.Prepend); Assert.AreEqual (lgb.Transform, clone, "Rotate/Prepend"); clone.Scale (0.25f, 2, MatrixOrder.Append); lgb.ScaleTransform (0.25f, 2, MatrixOrder.Append); Assert.AreEqual (lgb.Transform, clone, "Scale/Append"); clone.Scale (0.25f, 2, MatrixOrder.Prepend); lgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend); Assert.AreEqual (lgb.Transform, clone, "Scale/Prepend"); clone.Translate (10, 20, MatrixOrder.Append); lgb.TranslateTransform (10, 20, MatrixOrder.Append); Assert.AreEqual (lgb.Transform, clone, "Translate/Append"); clone.Translate (30, 40, MatrixOrder.Prepend); lgb.TranslateTransform (30, 40, MatrixOrder.Prepend); Assert.AreEqual (lgb.Transform, clone, "Translate/Prepend"); clone.Reset (); lgb.ResetTransform (); Assert.AreEqual (lgb.Transform, clone, "Reset"); }
public void ScaleTransform_MaxMin () { LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f); lgb.ScaleTransform (Single.MaxValue, Single.MinValue); float[] elements = lgb.Transform.Elements; Assert.AreEqual (Single.MaxValue, elements[0], 1e33, "matrix.0"); Assert.AreEqual (0, elements[1], 0.1, "matrix.1"); Assert.AreEqual (0, elements[2], 0.1, "matrix.2"); Assert.AreEqual (Single.MinValue, elements[3], 1e33, "matrix.3"); Assert.AreEqual (0, elements[4], 0.1, "matrix.4"); Assert.AreEqual (0, elements[5], 0.1, "matrix.5"); }
public void ScaleTransform_45 () { LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 45f); lgb.ScaleTransform (3, 3); float[] elements = lgb.Transform.Elements; Assert.AreEqual (3, elements[0], 0.1, "matrix.0"); Assert.AreEqual (3, elements[1], 0.1, "matrix.1"); Assert.AreEqual (-3, elements[2], 0.1, "matrix.2"); Assert.AreEqual (3, elements[3], 0.1, "matrix.3"); Assert.AreEqual (16, elements[4], 0.1, "matrix.4"); Assert.AreEqual (-16, elements[5], 0.1, "matrix.5"); }
public void ScaleTransform () { LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f); lgb.ScaleTransform (2, 4); float[] elements = lgb.Transform.Elements; Assert.AreEqual (2, elements[0], 0.1, "matrix.0"); Assert.AreEqual (0, elements[1], 0.1, "matrix.1"); Assert.AreEqual (0, elements[2], 0.1, "matrix.2"); Assert.AreEqual (4, elements[3], 0.1, "matrix.3"); Assert.AreEqual (0, elements[4], 0.1, "matrix.4"); Assert.AreEqual (0, elements[5], 0.1, "matrix.5"); lgb.ScaleTransform (0.5f, 0.25f); Assert.IsTrue (lgb.Transform.IsIdentity, "Transform.IsIdentity"); }
public void Rectangle () { LinearGradientBrush lgb = new LinearGradientBrush (rect, c1, c2, 0f); CheckDefaultRectangle ("Original", lgb.Rectangle); lgb.MultiplyTransform (new Matrix (2, 0, 0, 2, 2, 2)); CheckDefaultRectangle ("Multiply", lgb.Rectangle); lgb.ResetTransform (); CheckDefaultRectangle ("Reset", lgb.Rectangle); lgb.RotateTransform (90); CheckDefaultRectangle ("Rotate", lgb.Rectangle); lgb.ScaleTransform (4, 0.25f); CheckDefaultRectangle ("Scale", lgb.Rectangle); lgb.TranslateTransform (-10, -20); CheckDefaultRectangle ("Translate", lgb.Rectangle); lgb.SetBlendTriangularShape (0.5f); CheckDefaultRectangle ("SetBlendTriangularShape", lgb.Rectangle); lgb.SetSigmaBellShape (0.5f); CheckDefaultRectangle ("SetSigmaBellShape", lgb.Rectangle); }
Image genPlayButton() { Image play = new Bitmap(132, 32); Image icon = Bitmap.FromFile(Application.StartupPath + "\\icons\\play.png"); ColorBlend blend = new ColorBlend(); blend.Positions = new float[] { 0, 0.5f, 1 }; blend.Colors = new Color[] { Color.FromArgb(100, Color.Gray), Color.FromArgb(192, 107, 107, 107), Color.FromArgb(192, 159, 159, 159) }; LinearGradientBrush gradientBrush = new LinearGradientBrush(new Rectangle(0, 0, 1, 1), Color.Black, Color.Black, 0, false); gradientBrush.InterpolationColors = blend; gradientBrush.ResetTransform(); gradientBrush.ScaleTransform(64, 64); gradientBrush.RotateTransform(90); Graphics gfx = Graphics.FromImage(play); gfx.SmoothingMode = SmoothingMode.HighQuality; gfx.FillPie(gradientBrush, new Rectangle(0, 0, 132, 64), 180, 180); //background gfx.DrawPie(new Pen(Color.Black, 4), new Rectangle(2, 2, 128, 56), 180, 180); //outline gfx.DrawImage(icon, 50, 0); //icon gradientBrush.Dispose(); gfx.Dispose(); icon.Dispose(); return play; }