示例#1
0
 public static void DrawSharpCanvas(Canvas canvas, int fillColor, float width, float height)
 {
     SharpKit.DrawSharpCanvas(canvas, new RectF(0f, 0f, 100f, 100f), ResizingBehavior.AspectFit, fillColor, width, height);
 }
示例#2
0
        public static void DrawSharpCanvas(Canvas canvas, RectF targetFrame, ResizingBehavior resizing, int fillColor, float width, float height)
        {
            // General Declarations
            Paint paint = CacheForSharpCanvas.paint;

            // Resize to Target Frame
            canvas.Save();
            RectF resizedFrame = CacheForSharpCanvas.resizedFrame;

            SharpKit.resizingBehaviorApply(resizing, CacheForSharpCanvas.originalFrame, targetFrame, resizedFrame);
            canvas.Translate(resizedFrame.Left, resizedFrame.Top);
            canvas.Scale(resizedFrame.Width() / 100f, resizedFrame.Height() / 100f);

            // SharpFrame
            RectF sharpFrame = CacheForSharpCanvas.sharpFrame;

            sharpFrame.Set(0f, 0f, width, height);

            // SharpSymbol
            RectF sharpSymbolRect = CacheForSharpCanvas.sharpSymbolRect;

            sharpSymbolRect.Set(0f, 0f, 100f, 100f);
            Path sharpSymbolPath = CacheForSharpCanvas.sharpSymbolPath;

            sharpSymbolPath.Reset();
            sharpSymbolPath.MoveTo(sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.00002f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top, sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.08245f, sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.2f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width(), sharpFrame.Top + sharpFrame.Height() * 0.2f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width(), sharpFrame.Top + sharpFrame.Height() * 0.4f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.4f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.46586f, sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.53414f, sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.6f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width(), sharpFrame.Top + sharpFrame.Height() * 0.6f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width(), sharpFrame.Top + sharpFrame.Height() * 0.8f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.8f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.91755f, sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height(), sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height());
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height());
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height(), sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.91755f, sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.8f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height() * 0.8f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height() * 0.91755f, sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height(), sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height());
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height());
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height(), sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height() * 0.91755f, sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height() * 0.8f);
            sharpSymbolPath.LineTo(sharpFrame.Left, sharpFrame.Top + sharpFrame.Height() * 0.8f);
            sharpSymbolPath.LineTo(sharpFrame.Left, sharpFrame.Top + sharpFrame.Height() * 0.6f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height() * 0.6f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height() * 0.53414f, sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height() * 0.46586f, sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height() * 0.4f);
            sharpSymbolPath.LineTo(sharpFrame.Left, sharpFrame.Top + sharpFrame.Height() * 0.4f);
            sharpSymbolPath.LineTo(sharpFrame.Left, sharpFrame.Top + sharpFrame.Height() * 0.2f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height() * 0.2f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top + sharpFrame.Height() * 0.08245f, sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top, sharpFrame.Left + sharpFrame.Width() * 0.2f, sharpFrame.Top);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top, sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height() * 0.08245f, sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height() * 0.2f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.2f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.08245f, sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top, sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.8f, sharpFrame.Top + sharpFrame.Height() * 0.00002f);
            sharpSymbolPath.Close();
            sharpSymbolPath.MoveTo(sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.4f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height() * 0.4f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height() * 0.46586f, sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height() * 0.53414f, sharpFrame.Left + sharpFrame.Width() * 0.4f, sharpFrame.Top + sharpFrame.Height() * 0.6f);
            sharpSymbolPath.LineTo(sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.6f);
            sharpSymbolPath.CubicTo(sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.53414f, sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.46586f, sharpFrame.Left + sharpFrame.Width() * 0.6f, sharpFrame.Top + sharpFrame.Height() * 0.4f);
            sharpSymbolPath.Close();

            paint.Reset();
            paint.Flags = PaintFlags.AntiAlias;
            paint.SetStyle(Paint.Style.Fill);
            paint.Color = new Color(fillColor);
            canvas.DrawPath(sharpSymbolPath, paint);

            canvas.Restore();
        }
 protected override void OnDraw(Canvas canvas)
 {
     SharpKit.DrawSharpCanvas(canvas, _fillColor.ToArgb(), Width, Height);
 }