コード例 #1
0
ファイル: IconGraphics.cs プロジェクト: Occur/TextStyle
        //// Drawing Methods
        public static void DrawRefreshIcon(UIColor strokeColor)
        {
            //// Group 2
            {
                //// Bezier Drawing
                UIBezierPath bezierPath = new UIBezierPath();
                bezierPath.MoveTo(new CGPoint(22.65f, 2.0f));
                bezierPath.AddCurveToPoint(new CGPoint(36.33f, 7.67f), new CGPoint(27.6f, 2.0f), new CGPoint(32.55f, 3.89f));
                bezierPath.AddCurveToPoint(new CGPoint(38.13f, 32.97f), new CGPoint(43.23f, 14.57f), new CGPoint(43.83f, 25.39f));
                bezierPath.AddLineTo(new CGPoint(34.26f, 36.84f));
                strokeColor.SetStroke();
                bezierPath.LineWidth = 1.0f;
                bezierPath.Stroke();

                //// Bezier 2 Drawing
                UIBezierPath bezier2Path = new UIBezierPath();
                bezier2Path.MoveTo(new CGPoint(21.35f, 42.0f));
                bezier2Path.AddCurveToPoint(new CGPoint(7.67f, 36.33f), new CGPoint(16.4f, 42.0f), new CGPoint(11.45f, 40.11f));
                bezier2Path.AddCurveToPoint(new CGPoint(5.87f, 11.03f), new CGPoint(0.77f, 29.43f), new CGPoint(0.17f, 18.61f));
                bezier2Path.AddLineTo(new CGPoint(9.74f, 7.16f));
                strokeColor.SetStroke();
                bezier2Path.LineWidth = 1.0f;
                bezier2Path.Stroke();

                //// Bezier 3 Drawing
                UIBezierPath bezier3Path = new UIBezierPath();
                bezier3Path.MoveTo(new CGPoint(34.26f, 29.74f));
                bezier3Path.AddLineTo(new CGPoint(34.26f, 36.84f));
                bezier3Path.AddLineTo(new CGPoint(41.35f, 36.84f));
                bezier3Path.LineJoinStyle = CGLineJoin.Bevel;

                strokeColor.SetStroke();
                bezier3Path.LineWidth = 1.0f;
                bezier3Path.Stroke();

                //// Bezier 4 Drawing
                UIBezierPath bezier4Path = new UIBezierPath();
                bezier4Path.MoveTo(new CGPoint(9.74f, 14.26f));
                bezier4Path.AddLineTo(new CGPoint(9.74f, 7.16f));
                bezier4Path.AddLineTo(new CGPoint(2.65f, 7.16f));
                bezier4Path.LineJoinStyle = CGLineJoin.Bevel;

                strokeColor.SetStroke();
                bezier4Path.LineWidth = 1.0f;
                bezier4Path.Stroke();
            }
        }
コード例 #2
0
ファイル: IconGraphics.cs プロジェクト: Occur/TextStyle
        public static void DrawArrowIcon(UIColor strokeColor)
        {
            //// Group
            {
                //// Oval Drawing
                var ovalPath = UIBezierPath.FromOval(new CGRect(2.0f, 2.0f, 40.0f, 40.0f));
                strokeColor.SetStroke();
                ovalPath.LineWidth = 1.0f;
                ovalPath.Stroke();

                //// Bezier Drawing
                UIBezierPath bezierPath = new UIBezierPath();
                bezierPath.MoveTo(new CGPoint(18.77f, 11.03f));
                bezierPath.AddLineTo(new CGPoint(29.74f, 22.0f));
                bezierPath.AddLineTo(new CGPoint(18.77f, 32.97f));
                bezierPath.LineJoinStyle = CGLineJoin.Bevel;

                strokeColor.SetStroke();
                bezierPath.LineWidth = 1.0f;
                bezierPath.Stroke();
            }
        }
コード例 #3
0
ファイル: Line.cs プロジェクト: yingfangdu/BNR
        public void draw(CGContext context)
        {
            context.SetLineWidth(lineWidth);
            context.MoveTo(this.begin.X, this.begin.Y);
            context.AddLineToPoint(this.end.X, this.end.Y);

            UIColor clr = new UIColor(red, green, blue, alpha);
            clr.SetStroke();

            context.StrokePath();
        }
コード例 #4
0
ファイル: Line.cs プロジェクト: yingfangdu/BNR
        public void drawWithColor(CGContext context, UIColor clr)
        {
            context.SetLineWidth(lineWidth);
            context.MoveTo(this.begin.X, this.begin.Y);
            context.AddLineToPoint(this.end.X, this.end.Y);

            clr.SetStroke();

            context.StrokePath();
        }
コード例 #5
0
ファイル: HypnosisView.cs プロジェクト: yingfangdu/BNR
        public override void Draw(CGRect rect)
        {
            base.Draw(rect);

            // Get current drawing context
            CGContext ctx = UIGraphics.GetCurrentContext();
            // Get bounds of view
            CGRect bounds = this.Bounds;

            // Figure out the center of the bounds rectangle
            CGPoint center = new CGPoint();
            center.X = (float)(bounds.Location.X + bounds.Size.Width / 2.0);
            center.Y = (float)(bounds.Location.Y + bounds.Size.Height / 2.0);

            // The radius of the circle shiuld be nearly as big as the View.
            float maxRadius = (float)Math.Sqrt(Math.Pow(bounds.Size.Width,2) + Math.Pow(bounds.Size.Height,2)) / 2.0f;

            // The thickness of the line should be 10 points wide
            ctx.SetLineWidth(10);

            // The color of the line should be grey
            //ctx.SetRGBStrokeColor(0.6f, 0.6f, 0.6f, 1.0f);
            //UIColor.FromRGB(0.6f, 0.6f, 0.6f).SetStroke();
            //UIColor.FromRGBA(0.6f, 0.6f, 0.6f, 1.0f).SetStroke();
            circleColor.SetStroke();

            // Add a shape to the context
            //ctx.AddArc(center.X, center.Y, maxRadius, 0, (float)(Math.PI * 2), true);

            // Perform the drawing operation - draw current shape with current state
            //ctx.DrawPath(CGPathDrawingMode.Stroke);

            float r = 1;
            float g = 0;
            float b = 0;

            // Draw concentric circles from the outside in
            for (float currentRadius = maxRadius; currentRadius > 0; currentRadius -= 20) {
                ctx.AddArc(center.X, center.Y, currentRadius, 0, (float)(Math.PI * 2), true);
                ctx.SetStrokeColor(r ,g, b, 1);
                if (r > 0) {
                    r -= 0.15f;
                    g += 0.15f;
                }
                else if (g > 0) {
                    g -= 0.15f;
                    b += 0.15f;
                }
                ctx.DrawPath(CGPathDrawingMode.Stroke);
            }

            // Create a string
            NSString text = new NSString("You are getting sleepy");

            // Get a font to draw it in
            UIFont font = UIFont.BoldSystemFontOfSize(28);

            CGRect textRect = new CGRect();

            // How big is the string when drawn in this font?
            //textRect.Size = text.StringSize(font);
            UIStringAttributes attribs = new UIStringAttributes {Font = font};
            textRect.Size = text.GetSizeUsingAttributes(attribs);

            // Put the string in the center
            textRect.X = (float)(center.X - textRect.Size.Width / 2.0);
            textRect.Y = (float)(center.Y - textRect.Size.Height / 2.0);

            // Set the fill color of the current context to black
            UIColor.Black.SetFill();

            // Shadow
            CGSize offset = new CGSize(4, 3);
            CGColor color = new CGColor(0.2f, 0.2f, 0.2f, 1f);

            ctx.SetShadow(offset, 2.0f, color);

            // Draw the string
            text.DrawString(textRect, font);

            // Crosshair
            ctx.SaveState();
            CGSize offset2 = new CGSize(0, 0);
            CGColor color2 = new CGColor(UIColor.Clear.CGColor.Handle);
            crossHairColor = UIColor.Green;
            crossHairColor.SetStroke();

            ctx.SetShadow(offset2, 0, color2);
            ctx.SetLineWidth(7);
            ctx.MoveTo(center.X -20, center.Y);
            ctx.AddLineToPoint(center.X + 20, center.Y);
            ctx.DrawPath(CGPathDrawingMode.Stroke);
            ctx.MoveTo(center.X, center.Y-20);
            ctx.AddLineToPoint(center.X, center.Y + 20);
            ctx.DrawPath(CGPathDrawingMode.Stroke);
            ctx.RestoreState();
        }