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


C# CGAffineTransform.Multiply方法代码示例

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


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

示例1: Draw

			public void Draw(GraphicsHandler graphics, RectangleF rect)
			{
				var outerRadius = Radius.Width;
				var yscale = Radius.Height / Radius.Width;
				var center = Center;
				var origin = GradientOrigin;
				var scale = 1f;

				if (wrap != GradientWrapMode.Pad)
				{
					// use eto's transformrectangle as it'll make the rect encompass the resulting transformed area
					var boundRect = transform.Invert().ToEto().TransformRectangle(rect);

					// find max number of iterations we need to fill the bounding rectangle
					scale = GradientHelper.GetRadialScale(Center, Radius, GradientOrigin, boundRect);
				}

				if (Gradient == null || scale > lastScale)
				{
					var stops = GradientHelper.GetGradientStops(StartColor.ToCG(), EndColor.ToCG(), scale, wrap).ToList();
					lastScale = scale;
					Gradient = new CGGradient(CGColorSpace.CreateDeviceRGB(), stops.Select(r => r.Item2).ToArray(), stops.Select(r => (nfloat)r.Item1).ToArray());
				}
				else
				{
					scale = lastScale;
				}
				
				var scaledRect = new RectangleF(GradientOrigin - (GradientOrigin - Center + Radius) * scale, GradientOrigin + (Center + Radius - GradientOrigin) * scale);
				center = scaledRect.Center;
				outerRadius *= scale;

				// adjust center based on ellipse scale from gradient origin
				center.Y = origin.Y - (origin.Y - center.Y) / yscale;

				// scale to draw elliptical gradient
				var t = new CGAffineTransform(1, 0f, 0f, yscale, 0, origin.Y - origin.Y * yscale);
				t.Multiply(transform);

				graphics.Control.SaveState();
				graphics.Control.ConcatCTM(t);
				graphics.Control.DrawRadialGradient(Gradient, origin.ToNS(), 0, center.ToNS(), outerRadius, CGGradientDrawingOptions.DrawsAfterEndLocation | CGGradientDrawingOptions.DrawsBeforeStartLocation);
				graphics.Control.RestoreState();
			}
开发者ID:picoe,项目名称:Eto,代码行数:44,代码来源:RadialGradientBrushHandler.cs

示例2: Matrix

        public Matrix(RectangleF rect, PointF[] plgpts)
        {
            if (plgpts == null)
                throw new ArgumentNullException ("plgpts");
            if (plgpts.Length != 3)
                throw new ArgumentException ("plgpts");

            PointF p0 = plgpts [0];
            PointF p1 = plgpts [1];
            PointF p2 = plgpts [2];

            float m11 = (p1.X - p0.X) / rect.Width;
            float m12 = (p1.Y - p0.Y) / rect.Width;
            float m21 = (p2.X - p0.X) / rect.Height;
            float m22 = (p2.Y - p0.Y) / rect.Height;

            transform = CGAffineTransform.MakeTranslation(-rect.X, -rect.Y);
            transform.Multiply(new CGAffineTransform (m11, m12, m21, m22, p0.X, p0.Y));
        }
开发者ID:ronaldli,项目名称:sysdrawing-coregraphics,代码行数:19,代码来源:Matrix.cs

示例3: DrawImage

        /// <summary>
        /// Draws the specified portion of the specified Image at the specified location and with the specified size.
        /// 
        /// The destPoints specifies a parallelogram with the first point specifying the upper left corner, 
        /// second point specifying the upper right corner and the third point specifying the lower left corner.
        /// 
        /// The srcRect parameter specifies a rectangular portion of the image object to draw. This portion is scaled 
        /// up or down (in the case where source rectangle overruns the bounds of the image) to fit inside the rectangle 
        /// specified by the destRect parameter.  
        /// </summary>
        /// <param name="image">Image.</param>
        /// <param name="destPoints">Destination points.</param>
        /// <param name="srcRect">Source rect.</param>
        /// <param name="srcUnit">Source unit.</param>
        public void DrawImage(Image image, PointF [] destPoints, RectangleF srcRect, GraphicsUnit srcUnit)
        {
            if (image == null)
                throw new ArgumentNullException ("image");
            if (destPoints == null)
                throw new ArgumentNullException ("destPoints");

            if (destPoints.Length < 3)
                throw new ArgumentException ("Destination points must be an array with a length of 3 or 4. " +
                                             "A length of 3 defines a parallelogram with the upper-left, upper-right, " +
                                             "and lower-left corners. A length of 4 defines a quadrilateral with the " +
                                             "fourth element of the array specifying the lower-right coordinate.");

            // Windows throws a Not Implemented error if the points are more than 3
            if (destPoints.Length > 3)
                throw new NotImplementedException ();

            var srcRect1 = srcRect;

            // If the source units are not the same we need to convert them
            // The reason we check for Pixel here is that our graphics already has the Pixel's baked into the model view transform
            if (srcUnit != graphicsUnit && srcUnit != GraphicsUnit.Pixel)
            {
                ConversionHelpers.GraphicsUnitConversion (srcUnit, graphicsUnit, image.HorizontalResolution, image.VerticalResolution,  ref srcRect1);
            }

            // Obtain the subImage
            var subImage = image.NativeCGImage.WithImageInRect (srcRect1);

            // If we do not have anything to draw then we exit here
            if (subImage.Width == 0 || subImage.Height == 0)
                return;

            // create our rectangle.  Offset is 0 because the CreateGeometricTransform bakes our x,y offset in there.
            var rect = new RectangleF (0,0, destPoints [1].X - destPoints [0].X, destPoints [2].Y - destPoints [0].Y);

            // We need to flip our Y axis so the image appears right side up
            var geoTransform = new CGAffineTransform (1, 0, 0, -1, 0, rect.Height);

            // Make sure we scale the image in case the source rectangle
            // overruns our subimage bounds (width and/or height)
            float scaleX = subImage.Width/srcRect1.Width;
            float scaleY = subImage.Height/srcRect1.Height;
            geoTransform.Scale (scaleX, scaleY);

            //var geott = GeomUtilities.CreateGeometricTransform (rect, destPoints);
            geoTransform.Multiply (GeomUtilities.CreateGeometricTransform (rect, destPoints));

            // Apply our transform to the context
            context.ConcatCTM (geoTransform);

            // now we draw our image.
            context.DrawImage(rect, subImage);

            // Now we revert our image transform from the context
            var revert = CGAffineTransform.CGAffineTransformInvert (geoTransform);
            context.ConcatCTM (revert);
        }
开发者ID:asfungithub,项目名称:sysdrawing-coregraphics,代码行数:72,代码来源:Graphics-DrawImage.cs

示例4: Shear

 public void Shear(float shearX, float shearY, MatrixOrder order)
 {
     var affine = new CGAffineTransform (1, shearY, shearX, 1, 0, 0);
     if (order == MatrixOrder.Append)
         transform.Multiply (affine);
     else {
         affine.Multiply (transform);
         transform = affine;
     }
 }
开发者ID:ronaldli,项目名称:sysdrawing-coregraphics,代码行数:10,代码来源:Matrix.cs


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