/// <summary>
 /// Creates a filled circle.
 /// </summary>
 /// <param name="image">The surface.</param>
 /// <param name="x">X.</param>
 /// <param name="y">Y.</param>
 /// <param name="radius">The radius.</param>
 /// <param name="color">The color.</param>
 public static void FillCircle(this BCGSurface image, int x, int y, int radius, SKColor color)
 {
     image.SKSurface.Canvas.DrawCircle(x, y, radius, new SKPaint()
     {
         Style = SKPaintStyle.Fill, Color = color
     });
 }
 /// <summary>
 /// Creates a filled rectangle.
 /// </summary>
 /// <param name="image">The surface.</param>
 /// <param name="x1">X1.</param>
 /// <param name="y1">Y1.</param>
 /// <param name="x2">X2.</param>
 /// <param name="y2">Y2.</param>
 /// <param name="color">The color.</param>
 public static void FillRectangle(this BCGSurface image, int x1, int y1, int x2, int y2, SKColor color)
 {
     image.SKSurface.Canvas.DrawRect(new SKRect(x1, y1, x2 + 1, y2 + 1), new SKPaint()
     {
         Style = SKPaintStyle.Fill, Color = color
     });
 }
        /// <summary>
        /// Draws all chars thanks to <paramref name="code"/>. If <paramref name="startBar"/> is true, the line begins by a space.
        /// If <paramref name="startBar"/> is false, the line begins by a bar.
        /// </summary>
        /// <param name="image">The surface.</param>
        /// <param name="code">The code.</param>
        /// <param name="startBar">True if we begin with a space.</param>
        protected virtual void DrawChar(BCGSurface image, string code, bool startBar)
        {
            var colors = new int[2] {
                BCGBarcode1D.COLOR_FG, BCGBarcode1D.COLOR_BG
            };
            var currentColor = startBar ? 0 : 1;

            for (var i = 0; i < code.Length; i++)
            {
                if (int.TryParse(code[i].ToString(), out var nValue))
                {
                    for (var j = 0; j < nValue + 1; j++)
                    {
                        this.DrawSingleBar(image, colors[currentColor]);
                        this.NextX();
                    }
                }

                currentColor = (currentColor + 1) % 2;
            }
        }
 /// <summary>
 /// Draws a Bar of <paramref name="color"/> depending of the resolution.
 /// </summary>
 /// <param name="image">The surface.</param>
 /// <param name="color">The color.</param>
 protected void DrawSingleBar(BCGSurface image, int color)
 {
     this.DrawFilledRectangle(image, this.positionX, 0, this.positionX, this.thickness - 1, color);
 }
 /// <summary>
 /// Draws all chars thanks to <paramref name="code"/>. This convenient method always begin with a space.
 /// </summary>
 /// <param name="image">The surface.</param>
 /// <param name="code">The code.</param>
 protected virtual void DrawChar(BCGSurface image, string code)
 {
     this.DrawChar(image, code, true);
 }