Brush etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Brush etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

11 Şubat 2014 Salı

C Sharp Uygulamalar Graphics Nesnesini Kullanarak Rastgele Şekiller Çizdirme



KONU : C Sharp Uygulamalar - C Sharp ( C# ) graphics nesnesini kullanarak rastgele şekillerde grafikler çizdirme
ETİKETLER: c sharp çizgi çizme| c sharp elips çizme | c sharp grafik çizme | c sharp dikdörtgen çizme | c sharp rastgele şekil çizme | c sharp resim yapma | c sharp form üzerinde grafik çizdirme | c# grafik | c sharp grafik nesnesinin kullanımı | c sharp draw pie - c sharp draw pie filling - c sharp içi dolu pasta dilimi çizme - c sharp random sınıfı kullanımı | c sharp random | c# random sınıfı





UYGULAMAYI İNDİR



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;
using System.Drawing.Imaging;

namespace C_Sharp_GDI_Kullanımı
{

    public partial class Form1 : Form
    {
        List< Pen >  pens;
        List< Brush > brushes;
        Random random;

        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            pens = new List< Pen >();
            brushes = new List< Brush >();
            random = new Random();

            pens.Add(new Pen(Color.Blue));
            pens.Add(new Pen(Color.Red));
            pens.Add(new Pen(Color.Green));
            pens.Add(new Pen(Color.Black));
            pens.Add(new Pen(Color.White));

            brushes.Add(Brushes.Blue);
            brushes.Add(Brushes.Red);
            brushes.Add(Brushes.Green);
            brushes.Add(Brushes.Black);
            brushes.Add(Brushes.White);

        }



        private void drawEllipse(Graphics graphic)
        {
            graphic.DrawEllipse(pens[random.Next(0, 5)], random.Next(0, 100), random.Next(0, 100), random.Next(0, 100), random.Next(0, 100));
            bmp = new Bitmap(panel1.Width, panel1.Height, graphic);
        }

        private void drawPie(Graphics graphic)
        {
            try
            {
                graphic.DrawPie(pens[random.Next(0, 5)], random.Next(0, 100), random.Next(0, 100), random.Next(0, 100), random.Next(0, 100), 0, 60);
            }
            catch (Exception)
            {
            }
            
        }

        private void DrawRandomFigure(Graphics graphic)
        {
            Point[] ps = {
                                 new Point(0,random.Next(0, 100)),
                                 new Point(100,random.Next(0, 100)),
                                 new Point(100,random.Next(100, 200)),
                                 new Point(0,random.Next(100, 200))
                               };

            graphic.FillClosedCurve(brushes[random.Next(0, 5)], ps);
        }

        private void DrawFillPie(Graphics graphic)
        {
            int width = random.Next(100, 100);
            int height = width;
            graphic.FillPie(brushes[random.Next(0, 5)], random.Next(0, 100), random.Next(0, 100), width, height, random.Next(0, 360), random.Next(0, 360));
        }


        private void btnElippseDraw_Click(object sender, EventArgs e)
        {
            drawEllipse(panel1.CreateGraphics());
        }

        private void btnPieDraw_Click(object sender, EventArgs e)
        {
            drawPie(panel1.CreateGraphics());
        }

        private void btnSquareDraw_Click(object sender, EventArgs e)
        {
            int width = random.Next(10, panel1.Width-10);
            int height =random.Next(10, panel1.Height-10);

            Bitmap bitMap = new Bitmap(width, height);
            Rectangle rec = new Rectangle(5, 5, width, height);

            Graphics g = panel1.CreateGraphics();
            g.DrawRectangle(pens[random.Next(0, 5)], rec);

        }

        private void btnDrawFigure_Click(object sender, EventArgs e)
        {
            DrawRandomFigure(panel1.CreateGraphics());
        }

        private void btnFillPie_Click(object sender, EventArgs e)
        {
            DrawFillPie(panel1.CreateGraphics());
        }
    }
}

   




UYGULAMAYI İNDİR