How to fill color inside dots?

Shashank Sivakoti 1 Reputation point


Hi Team,

To to fill the Orange color inside dots, I am using this namespace Microsoft.Maui.Graphics


using System;  
using System.IO;  
// These packages are available on NuGet  
using Microsoft.Maui.Graphics;  
using Microsoft.Maui.Graphics.Skia;  
namespace ConsoleApp1  
    internal class Program  
        static void Main(string[] args)  
            // Create a bitmap in memory and draw on its Canvas  
            SkiaBitmapExportContext bmp = new(1000, 1000, 1.0f);  
            ICanvas canvas = bmp.Canvas;  
            // Draw a big blue rectangle with a dark border  
            Rect backgroundRectangle = new(0, 0, bmp.Width, bmp.Height);  
            //canvas.FillColor = Color.FromArgb("#e39e00");  
            canvas.StrokeColor = Colors.Black;  
            canvas.StrokeSize = 1;  
            IPattern pattern;  
            SolidPaint solidPaint = new SolidPaint(Colors.Red);  
            // Create a 10x10 template for the pattern  
            using (PictureCanvas picture = new PictureCanvas(0, 0, 100, 100))  
              picture.StrokeColor = Colors.Orange;  
                picture.FontColor = Color.FromRgba("#e39e00");  
                picture.DrawCircle(50, 50, 25);   
                picture.DisplayScale = 1;  
                picture.FillColor = Colors.Red;                  
                pattern = new PicturePattern(picture.Picture, 10, 10);  
            // Fill the rectangle with the 10x10 pattern  
            PatternPaint patternPaint = new PatternPaint  
                Pattern = pattern,ForegroundColor= Colors.Red,  
            canvas.SetFillPaint(patternPaint, RectF.Zero);  
            // Save the image as a PNG file  
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
1,385 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 16,386 Reputation points Microsoft Vendor


    You need to modify picture.DrawCircle(50, 50, 25); to picture.FillCircle(50, 50, 25); to fill color.

    Please refer to Draw graphical objects to get more details.

    Best Regards,

    Alec Liu.

    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.