当前位置: 首页>>代码示例>>C#>>正文


C# PathGradientBrush.MultiplyTransform方法代码示例

本文整理汇总了C#中System.Drawing.Drawing2D.PathGradientBrush.MultiplyTransform方法的典型用法代码示例。如果您正苦于以下问题:C# PathGradientBrush.MultiplyTransform方法的具体用法?C# PathGradientBrush.MultiplyTransform怎么用?C# PathGradientBrush.MultiplyTransform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Drawing.Drawing2D.PathGradientBrush的用法示例。


在下文中一共展示了PathGradientBrush.MultiplyTransform方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBrush

			public sd2.PathGradientBrush GetBrush(RectangleF rect)
			{
				var scale = 1f;
				var bounds = rect;
				if (Matrix != null)
				{
					bounds = Matrix.Inverse().TransformRectangle(bounds);
				}

				scale = GradientHelper.GetRadialScale(Center, Radius, GradientOrigin, bounds);

				if (brush == null || lastScale != scale)
				{
					lastScale = scale;

					var scaledRect = new RectangleF(GradientOrigin - (GradientOrigin - Center + Radius) * scale, GradientOrigin + (Center + Radius - GradientOrigin) * scale);

					var path = new sd2.GraphicsPath();
					path.AddEllipse(scaledRect.ToSD());

					brush = new sd2.PathGradientBrush(path);
					brush.CenterColor = StartColor.ToSD();
					brush.CenterPoint = GradientOrigin.ToSD();
					brush.WrapMode = wrapMode.ToSD();
					brush.SurroundColors = new[] { EndColor.ToSD() };

					if (Matrix != null)
						brush.MultiplyTransform(Matrix.ToSD());

					if (scale > 1f)
					{
						var paths = GradientHelper.GetGradientStops(StartColor.ToSD(), EndColor.ToSD(), scale, wrapMode);

						brush.InterpolationColors = new sd2.ColorBlend
						{
							Positions = paths.Reverse().Select(r => 1f - r.Item1).ToArray(),
							Colors = paths.Reverse().Select(r => r.Item2).ToArray()
						};
					}
				}

				return brush;
			}
开发者ID:mhusen,项目名称:Eto,代码行数:43,代码来源:RadialGradientBrushHandler.cs

示例2: ToGdiPlus

		public static d.Brush ToGdiPlus(this RadialGradientBrush brush, Rect bounds) {
			var db = CheckDegenerate(brush);
			if (db != null) return db;
			var bt = new BrushTransform(brush, bounds);
			if (bt.DegenerateBrush != null) return bt.DegenerateBrush;

			var center = brush.Center;
			var focus = brush.GradientOrigin;
			var size = new Vector(brush.RadiusX, brush.RadiusY);
			if (brush.MappingMode == BrushMappingMode.RelativeToBoundingBox) {
				center = bt.ToAbsolute.Transform(center);
				focus = bt.ToAbsolute.Transform(focus);
				size = bt.ToAbsolute.Transform(size);
			}

			var ts = bt.ToBrush.Transform(size);
			var delta = (int)Math.Ceiling(4 * (bounds.BottomRight - bounds.TopLeft).Length 
				/ Math.Min(Math.Abs(ts.X), Math.Abs(ts.Y)));
			size *= delta;
			center += (delta - 1) * (center - focus);
			brush = brush.Clone();
			var g = brush.GradientStops;
			var last = g.Count - 1;
			var offset = 1.00000001;
			switch(brush.SpreadMethod) {
			case GradientSpreadMethod.Pad:
				g.Add(new GradientStop(g[last].Color, delta));
				break;
			case GradientSpreadMethod.Repeat:
				for(var i = 0; i < delta; ++i)
					for(var j = 0; j <= last; ++j)
						g.Add(new GradientStop(g[j].Color, i + g[j].Offset + (j == last ? 1 : offset)));
				break;
			case GradientSpreadMethod.Reflect:
				for(var i = 0; i < delta; ++i)
					if (i % 2 == 0) 
						for(var j = 0; j <= last; ++j)
							g.Add(new GradientStop(g[j].Color, i + (1 - g[j].Offset) + (j == 0 ? 1 : offset)));
					else
						for(var j = 0; j <= last; ++j)
							g.Add(new GradientStop(g[j].Color, i + g[j].Offset + (j == last ? 1 : offset)));
				break;
			}

			var b = new d2.PathGradientBrush(new EllipseGeometry(center, size.X, size.Y).ToGdiPlus());
			b.CenterPoint = focus.ToGdiPlus();
			b.InterpolationColors = ConvertGradient(brush);
			b.WrapMode = brush.SpreadMethod.ToGdiPlus();
			b.MultiplyTransform(bt.ToBrush.ToGdiPlus(), d2.MatrixOrder.Append);
			return b;
		}
开发者ID:goutkannan,项目名称:ironlab,代码行数:51,代码来源:XamlToys.cs

示例3: Transform_Operations

		public void Transform_Operations ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
				Matrix clone = pgb.Transform.Clone ();
				Matrix mul = clone.Clone ();

				clone.Multiply (mul, MatrixOrder.Append);
				pgb.MultiplyTransform (mul, MatrixOrder.Append);
				Assert.AreEqual (pgb.Transform, clone, "Multiply/Append");

				clone.Multiply (mul, MatrixOrder.Prepend);
				pgb.MultiplyTransform (mul, MatrixOrder.Prepend);
				Assert.AreEqual (pgb.Transform, clone, "Multiply/Prepend");

				clone.Rotate (45, MatrixOrder.Append);
				pgb.RotateTransform (45, MatrixOrder.Append);
				Assert.AreEqual (pgb.Transform, clone, "Rotate/Append");

				clone.Rotate (45, MatrixOrder.Prepend);
				pgb.RotateTransform (45, MatrixOrder.Prepend);
				Assert.AreEqual (pgb.Transform, clone, "Rotate/Prepend");

				clone.Scale (0.25f, 2, MatrixOrder.Append);
				pgb.ScaleTransform (0.25f, 2, MatrixOrder.Append);
				Assert.AreEqual (pgb.Transform, clone, "Scale/Append");

				clone.Scale (0.25f, 2, MatrixOrder.Prepend);
				pgb.ScaleTransform (0.25f, 2, MatrixOrder.Prepend);
				Assert.AreEqual (pgb.Transform, clone, "Scale/Prepend");

				clone.Translate (10, 20, MatrixOrder.Append);
				pgb.TranslateTransform (10, 20, MatrixOrder.Append);
				Assert.AreEqual (pgb.Transform, clone, "Translate/Append");

				clone.Translate (30, 40, MatrixOrder.Prepend);
				pgb.TranslateTransform (30, 40, MatrixOrder.Prepend);
				Assert.AreEqual (pgb.Transform, clone, "Translate/Prepend");

				clone.Reset ();
				pgb.ResetTransform ();
				Assert.AreEqual (pgb.Transform, clone, "Reset");
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:43,代码来源:PathGradientBrushTest.cs

示例4: MultiplyTransform_NonInvertible

		public void MultiplyTransform_NonInvertible ()
		{
			using (Matrix noninvertible = new Matrix (123, 24, 82, 16, 47, 30)) {
				using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
					pgb.MultiplyTransform (noninvertible);
				}
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:8,代码来源:PathGradientBrushTest.cs

示例5: MultiplyTransform2_Invalid

		public void MultiplyTransform2_Invalid ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
				pgb.MultiplyTransform (empty_matrix, (MatrixOrder) Int32.MinValue);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:6,代码来源:PathGradientBrushTest.cs

示例6: MultiplyTransform2_Null

		public void MultiplyTransform2_Null ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
				pgb.MultiplyTransform (null, MatrixOrder.Append);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:6,代码来源:PathGradientBrushTest.cs

示例7: MultiplyTransform1_Null

		public void MultiplyTransform1_Null ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.Clamp)) {
				pgb.MultiplyTransform (null);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:6,代码来源:PathGradientBrushTest.cs

示例8: Rectangle

		public void Rectangle ()
		{
			using (PathGradientBrush pgb = new PathGradientBrush (pts_2f, WrapMode.TileFlipXY)) {
				CheckDefaultRectangle ("Original", pgb.Rectangle);
				pgb.MultiplyTransform (new Matrix (2, 0, 0, 2, 2, 2));
				CheckDefaultRectangle ("Multiply", pgb.Rectangle);
				pgb.ResetTransform ();
				CheckDefaultRectangle ("Reset", pgb.Rectangle);
				pgb.RotateTransform (90);
				CheckDefaultRectangle ("Rotate", pgb.Rectangle);
				pgb.ScaleTransform (4, 0.25f);
				CheckDefaultRectangle ("Scale", pgb.Rectangle);
				pgb.TranslateTransform (-10, -20);
				CheckDefaultRectangle ("Translate", pgb.Rectangle);

				pgb.SetBlendTriangularShape (0.5f);
				CheckDefaultRectangle ("SetBlendTriangularShape", pgb.Rectangle);
				pgb.SetSigmaBellShape (0.5f);
				CheckDefaultRectangle ("SetSigmaBellShape", pgb.Rectangle);
			}
		}
开发者ID:nlhepler,项目名称:mono,代码行数:21,代码来源:PathGradientBrushTest.cs


注:本文中的System.Drawing.Drawing2D.PathGradientBrush.MultiplyTransform方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。