Hack Forums
[.NET] Graphics - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Graphics (/showthread.php?tid=817875)



Graphics - Pulser - Nov 13, 2010

Drawing


Hey Hackforums. I have been doing C# for quite some time now, but I never really messed with graphics. My first attempt with C# graphics lead me to this:

[IMG]http://img98.imageshack.us/img98/3080/96670599.gif[/IMG]

Its not much, but I mean common, its pretty cool :D.

The only reason I am posting this is for someone to see what it is like to draw in C#. I'm sure someone can come up with something cool to make. Anyway, I commented my source, so hopefully someone can put some use to it!

Source:
Code
Graphics surface; // sets up new graphics
            surface = this.CreateGraphics(); // creates graphic on the form
            Pen pen1 = new Pen(Color.Black, 1.0f); // new pen, color blac
            HatchBrush brushone = new HatchBrush(HatchStyle.DiagonalCross, Color.Black); // new brush
            Rectangle rec2 = new Rectangle(10, 10, 100, 100); // new rectangle, X/Y / Size
            Font drawfont = new Font("Arial", 20); // new font for my name



            surface.DrawString("Mr. Predictable", drawfont, brushone, 210.0f, 20.0f); // draws my name



            surface.DrawEllipse(pen1, 200, 100, 200, 200); // head
            surface.DrawEllipse(pen1, 230, 130, 50, 50); // eye 1
            surface.DrawEllipse(pen1, 310, 130, 50, 50); //eye 2
            surface.DrawArc(pen1, 275, 200, 40, 40, 180, -180); // mouth


I really hope someone finds this interesting!


* - Coder - Nov 13, 2010

Good work. ^^
Now make a frame of a box. Then try to use scrollbars to increase size of the box. Or something similar. :)


* - Pulser - Nov 14, 2010

(Nov 13, 2010 11:50 PM)Coder Wrote:  Good work. ^^
Now make a frame of a box. Then try to use scrollbars to increase size of the box. Or something similar. :)

Ooo sounds challenging (for me at least since I'm new to graphics)

I'll give it a shot!


* - Pulser - Nov 14, 2010

(Nov 13, 2010 11:50 PM)Coder Wrote:  Good work. ^^
Now make a frame of a box. Then try to use scrollbars to increase size of the box. Or something similar. :)

Hey, I got it! :D

[IMG]http://img607.imageshack.us/img607/6338/68395030.gif[/IMG]

Next.

Also, it doesn't actually lag like that. The GIF just distorted it a bit and added some lag.

My code:
Code
private void trackBar1_Scroll(object sender, EventArgs e)
  {
    this.Refresh();
    Graphics start = this.CreateGraphics();
    Pen pen1 = new Pen(Color.Black, 1.0f);
    Rectangle rect1 = new Rectangle(200, 100, trackBar1.Value, trackBar1.Value);
    start.DrawRectangle(pen1, rect1);
  }



* - Coder - Nov 14, 2010

Nice. :)
Now make a frame of cube and increase its size.
That was the last thing I did before I failed to rotate it like 3D, and starting gradients.


* - Pulser - Nov 14, 2010

(Nov 14, 2010 03:07 AM)Coder Wrote:  Nice. :)
Now make a frame of cube and increase its size.
That was the last thing I did before I failed to rotate it like 3D, and starting gradients.

I'll do it tomorrow. I'm really tired lol.


* - Joseph Ducreux - Nov 18, 2010

dude how do you make .gifs like that?
your .giffing skills are bomb


* - xSilent - Nov 18, 2010

(Nov 18, 2010 08:27 PM)Anonymous.Heuristic Wrote:  dude how do you make .gifs like that?
your .giffing skills are bomb

One word... Camtasia.

Or record an AVI then convert to gif which camtasia does it automatically.


* - Pulser - Nov 19, 2010

(Nov 18, 2010 08:27 PM)Anonymous.Heuristic Wrote:  dude how do you make .gifs like that?
your .giffing skills are bomb

I use Camtasia, then I convert it to a GIF.