Youtube RSS Feed
Learn with Vikas Suhag
Design an application that uses the concept of Graphics in C#.Net.
Nov 16, 2021   Vikas Suhag
graphics in dotnet programs

AIM :  Design an application that uses the concept of Graphics in C#.Net.

Source Code :

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

 

namespace GraphicsApp

{

    public partial class Form1 : Form

    {

        Graphics g;

        int count;

        Random rand = new Random();

        int rr, gg, bb;

        public Form1()

        {

            InitializeComponent();

        }

        private void Form1_MouseClick(object sender, MouseEventArgs e)

        {

            rr = rand.Next(255);

            gg = rand.Next(255);

            bb = rand.Next(255);

            Pen p = new Pen(Color.FromArgb(rr,gg,bb));

            if (count < 20)

            {

                g.DrawEllipse(p, e.X - 40, e.Y - 40, 100, 100);

                count++;

            }

            else

            {

                MessageBox.Show("No more Circles");

            }

        }

        private void Form1_Load(object sender, EventArgs e)

        {

            g = CreateGraphics();

        }

    }

}

 

Output


Leave a Comment

* Email will not be published.
All comments are only visible after approval.
Most Viewed articles
Search
Subscribe to Email Updates
Vikas Suhag

I am Engineer, Developer, Teacher, Blogger, Vlogger, Traveller, Photographer...

I have been developing websites, writing blogs and recording videos during my travel while being a full tim ...

Youtube Channel
Podcast
Subscribe to Email Updates
Connect With Us
Youtube RSS Feed
© 2021 Learn with Vikas Suhag. All Rights Reserved.