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


C# System.Drawing.RectangleF.GetMidY方法代码示例

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


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

示例1: DrawArc

		public void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle)
		{
			SetOffset(false);
			StartDrawing();

			var rect = new CGRect(x, y, width, height);
			pen.Apply(this);
			var yscale = rect.Height / rect.Width;
			var centerY = rect.GetMidY();
			var centerX = rect.GetMidX();
			Control.ConcatCTM(new CGAffineTransform(1.0f, 0, 0, yscale, 0, centerY - centerY * yscale));
			Control.AddArc(centerX, centerY, rect.Width / 2, CGConversions.DegreesToRadians(startAngle), CGConversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
			Control.StrokePath();
			EndDrawing();
		}
开发者ID:picoe,项目名称:Eto,代码行数:15,代码来源:GraphicsHandler.cs

示例2: FillPie

		public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle)
		{
			SetOffset(true);
			StartDrawing();

			var rect = new CGRect(x, y, width, height);
			Control.SaveState();
			var yscale = rect.Height / rect.Width;
			var centerY = rect.GetMidY();
			var centerX = rect.GetMidX();
			Control.ConcatCTM(new CGAffineTransform(1.0f, 0, 0, yscale, 0, centerY - centerY * yscale));
			Control.MoveTo(centerX, centerY);
			Control.AddArc(centerX, centerY, rect.Width / 2, CGConversions.DegreesToRadians(startAngle), CGConversions.DegreesToRadians(startAngle + sweepAngle), sweepAngle < 0);
			Control.AddLineToPoint(centerX, centerY);
			Control.ClosePath();
			Control.RestoreState();
			Control.Clip();
			brush.Draw(this, rect.ToEto());
			EndDrawing();
		}
开发者ID:picoe,项目名称:Eto,代码行数:20,代码来源:GraphicsHandler.cs

示例3: CreateLayers

        private void CreateLayers(UIImage image)
        {
            if (image == null)
                return;

            Layer.Sublayers = new CALayer[0];

            var imageFrame = new CGRect(
                Frame.Width / 2f - Frame.Width / 4f,
                Frame.Height / 2f - Frame.Height / 4f,
                Frame.Width / 2f,
                Frame.Height / 2f);
            var imgCenterPoint = new CGPoint(imageFrame.GetMidX(), imageFrame.GetMidY());
            var lineFrame = new CGRect(
                imageFrame.X - imageFrame.Width / 4f,
                imageFrame.Y - imageFrame.Height / 4f,
                imageFrame.Width * 1.5f,
                imageFrame.Height * 1.5f);

            //===============
            // circle layer
            //===============
            circleShape = new CAShapeLayer();
            circleShape.Bounds = imageFrame;
            circleShape.Position = imgCenterPoint;
            circleShape.Path = UIBezierPath.FromOval(imageFrame).CGPath;
            circleShape.FillColor = circleColor.CGColor;
            circleShape.Transform = CATransform3D.MakeScale(0.0f, 0.0f, 1.0f);
            Layer.AddSublayer(circleShape);

            circleMaskShape = new CAShapeLayer();
            circleMaskShape.Bounds = imageFrame;
            circleMaskShape.Position = imgCenterPoint;
            circleMaskShape.FillRule = CAShapeLayer.FillRuleEvenOdd;
            circleShape.Mask = circleMaskShape;

            var maskPath = UIBezierPath.FromRect(imageFrame);
            maskPath.AddArc(imgCenterPoint, 0.1f, 0.0f, fPI * 2f, true);
            circleMaskShape.Path = maskPath.CGPath;

            //===============
            // line layer
            //===============
            lineShapes = new CAShapeLayer[5];
            for (int i = 0; i < 5; i++)
            {
                var line = new CAShapeLayer();
                line.Bounds = lineFrame;
                line.Position = imgCenterPoint;
                line.MasksToBounds = true;
                line.Actions = NSDictionary.FromObjectsAndKeys(
                    new[] { NSNull.Null, NSNull.Null },
                    new[] { (NSString)"strokeStart", (NSString)"strokeEnd" });
                line.StrokeColor = linesColor.CGColor;
                line.LineWidth = 1.25f;
                line.MiterLimit = 1.25f;
                var path = new CGPath();
                path.MoveToPoint(lineFrame.GetMidX(), lineFrame.GetMidY());
                path.AddLineToPoint(lineFrame.X + lineFrame.Width / 2f, lineFrame.Y);
                line.Path = path;
                line.LineCap = CAShapeLayer.CapRound;
                line.LineJoin = CAShapeLayer.JoinRound;
                line.StrokeStart = 0.0f;
                line.StrokeEnd = 0.0f;
                line.Opacity = 0.0f;
                line.Transform = CATransform3D.MakeRotation(fPI / 5f * (i * 2f + 1f), 0.0f, 0.0f, 1.0f);
                Layer.AddSublayer(line);
                lineShapes[i] = line;
            }

            //===============
            // image layer
            //===============
            imageShape = new CAShapeLayer();
            imageShape.Bounds = imageFrame;
            imageShape.Position = imgCenterPoint;
            imageShape.Path = UIBezierPath.FromRect(imageFrame).CGPath;
            imageShape.FillColor = Checked ? Color.CGColor : SkeletonColor.CGColor;
            imageShape.Actions = NSDictionary.FromObjectAndKey(NSNull.Null, (NSString)"fillColor");
            Layer.AddSublayer(imageShape);

            imageShape.Mask = new CALayer();
            imageShape.Mask.Contents = image.CGImage;
            imageShape.Mask.Bounds = imageFrame;
            imageShape.Mask.Position = imgCenterPoint;

            //==============================
            // circle transform animation
            //==============================
            circleTransform.Values = new[]
            {
                NSValue.FromCATransform3D(CATransform3D.MakeScale(0.0f,  0.0f,  1.0f)),    //  0/10
                NSValue.FromCATransform3D(CATransform3D.MakeScale(0.5f,  0.5f,  1.0f)),    //  1/10
                NSValue.FromCATransform3D(CATransform3D.MakeScale(1.0f,  1.0f,  1.0f)),    //  2/10
                NSValue.FromCATransform3D(CATransform3D.MakeScale(1.2f,  1.2f,  1.0f)),    //  3/10
                NSValue.FromCATransform3D(CATransform3D.MakeScale(1.3f,  1.3f,  1.0f)),    //  4/10
                NSValue.FromCATransform3D(CATransform3D.MakeScale(1.37f, 1.37f, 1.0f)),    //  5/10
                NSValue.FromCATransform3D(CATransform3D.MakeScale(1.4f,  1.4f,  1.0f)),    //  6/10
                NSValue.FromCATransform3D(CATransform3D.MakeScale(1.4f,  1.4f,  1.0f))     // 10/10
            };
//.........这里部分代码省略.........
开发者ID:cyecp,项目名称:XamarinComponents,代码行数:101,代码来源:AnimatedShapeButton.cs


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