Pen etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
Pen 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

6 Aralık 2013 Cuma

C Sharp Uygulamalar Grafik Olarak Çizilen Resimin Piksel Değerlerini Bulma

KONU : C Sharp Uygulamalar - C Sharp ( C# ) grafik olarak çizilen resmin piksel değerlerini bulma. Bitmap resminden çizilen grafiğin piksellerini bulma
ETİKETLER:c sharp bitmap - c sharp grafik - c sharp image - c sharp piksel - c sharp getpixel - c sharp form


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;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            Bitmap bmp = new Bitmap(360, 360);

            Graphics gr = Graphics.FromImage(bmp);

            Rectangle rect = new System.Drawing.Rectangle(0, 0, 360, 360);
            gr.FillRectangle(System.Drawing.Brushes.Blue, rect);

            // Create pens.
            Pen redPen = new Pen(Color.Red, 3);
            Pen greenPen = new Pen(Color.Green, 3);

            // Create points that define curve.
            Point point1 = new Point(50, 50);
            Point point2 = new Point(100, 25);
            Point point3 = new Point(200, 5);
            Point point4 = new Point(250, 50);
            Point point5 = new Point(300, 100);
            Point point6 = new Point(350, 200);
            Point point7 = new Point(250, 250);
            Point[] curvePoints = { point1, point2, point3, point4, point5, point6, point7 };

            // Draw lines between original points to screen.
            gr.DrawLines(redPen, curvePoints);

            List points = new List();

            for (int y = 0; y < bmp.Height; ++y)
            {
                for (int x = 0; x < bmp.Width; ++x)
                {
                    Color c = bmp.GetPixel(x, y);
                    if (c.ToArgb() == Color.Red.ToArgb())
                    {
                        points.Add(new Point(x, y));
                    }
                }
            }

            //  MessageBox.Show(points[0].ToString());

            pictureBox1.Image = bmp;
            //    bmp.Dispose();

            for (int i = 0; i < points.Count; i++)
            {
                listBox1.Items.Add(points[i].ToString());
            }
 
        }
 
    }
}

UYGULAMAYI İNDİR

9 Nisan 2013 Salı

C Sharp Uygulamalar Mouse ile Çizgi ve Nokta Çizme



KONU : C Sharp Uygulamalar - C Sharp ( C# ) Form Uygulamalar farenin sol butonu ile çizgi çizme veya nokta çizme





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.Drawing2D;

namespace MouseGrafikCizme
{
    public partial class Form1 : Form
    {

        Graphics graphic;
        private enum FormatEnum
        {
            Nokta = 0, Çizgi
        }

        FormatEnum lineFormat;

        bool draw = false;

        int pOldX = -1;
        int pOldY = -1;

        Bitmap drawing;

        public Form1()
        {
            InitializeComponent();
        }

        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (draw)
            {
                Graphics panel = Graphics.FromImage(drawing);

                Pen pen = new Pen(Color.Blue, 5);

                pen.EndCap = LineCap.Round;

                pen.StartCap = LineCap.Round;


                switch (lineFormat)
                {
                    case FormatEnum.Nokta:

                        panel.DrawLine(pen, e.X, e.Y, e.X+1, e.Y+1);

                        panel1.CreateGraphics().DrawImageUnscaled(drawing, new Point(0, 0));

                        break;

                    case FormatEnum.Çizgi:
                        
                        panel.DrawLine(pen, pOldX, pOldY, e.X, e.Y);

                        panel1.CreateGraphics().DrawImageUnscaled(drawing, new Point(0, 0));

                        break;
                    default:
                        break;
                }
            }

            pOldX = e.X;

            pOldY = e.Y;
        }

        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            // Eğer mouse sol butona basılmaya başlanmışsa çizmeye başla

            draw = true; 

            pOldX = e.X;

            pOldY = e.Y;
        }

        private void panel1_MouseUp(object sender, MouseEventArgs e)
        {
            draw = false;
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawImageUnscaled(drawing, new Point(0, 0));
        }

        private void btnNokta_Click(object sender, EventArgs e)
        {
            lineFormat = FormatEnum.Nokta;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            lineFormat = FormatEnum.Nokta;

            drawing = new Bitmap(panel1.Width, panel1.Height, panel1.CreateGraphics());

            Graphics.FromImage(drawing).Clear(Color.White);

        }

        private void btnCizgi_Click(object sender, EventArgs e)
        {
            lineFormat = FormatEnum.Çizgi;
        }

 
    }
}


UYGULAMAYI İNDİR