4 Replies - 2982 Views - Last Post: 03 December 2009 - 10:29 PM Rate Topic: -----

#1 mikeymike  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 30-November 09

Easy way to draw pictures with code?

Posted 03 December 2009 - 09:14 PM

Hi guys,
I am wondering if anyone has a better idea for how to draw little pictures with code? Currently I draw it with code and keep checking on it until I get it right, it takes alot of guess work to begin with, and takes a while to complete. Any ideas?

Oh, and to show i'm not just after someone else to do it for me, here is my smiley face code (Which draws a smiley face on the mouse up event).

				b = Brushes.Yellow;

				Rectangle rect = new Rectangle(e.X - 17, e.Y - 15, 25, 20);

				g.FillEllipse(b, (e.X - 20), (e.Y - 20), 30, 30);
				b = Brushes.Black;
				g.FillEllipse(b, e.X - 13, e.Y - 13, 5, 10);
				g.FillEllipse(b, e.X, e.Y - 13, 5, 10);
				g.DrawArc(p, rect, 20, 145);


This post has been edited by mikeymike: 03 December 2009 - 09:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Easy way to draw pictures with code?

#2 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Easy way to draw pictures with code?

Posted 03 December 2009 - 09:31 PM

Try drawing the image in a paint program or on graph paper to get an idea of what coordinates to use for the image. With the paint program you would probably want to zoom in and make sure that the grid was visible to have a good idea of where the pixels are. Other than that I would say to it is pretty much trial and error and you would have to do what you are doing. Draw the image and then make it look the way you want it to.
Was This Post Helpful? 0
  • +
  • -

#3 mikeymike  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 30-November 09

Re: Easy way to draw pictures with code?

Posted 03 December 2009 - 09:43 PM

OK, thanks, that might help. I got a feeling it's going to take a long time though, I want to create about 100 little pictures :)

This post has been edited by mikeymike: 03 December 2009 - 09:44 PM

Was This Post Helpful? 0
  • +
  • -

#4 SixOfEleven  Icon User is offline

  • using Caffeine;
  • member icon

Reputation: 945
  • View blog
  • Posts: 6,342
  • Joined: 18-October 08

Re: Easy way to draw pictures with code?

Posted 03 December 2009 - 10:01 PM

View Postmikeymike, on 3 Dec, 2009 - 10:43 PM, said:

OK, thanks, that might help. I got a feeling it's going to take a long time though, I want to create about 100 little pictures :)


Creating pictures usually does take a far bit of time. You might want to consider creating a class of reusable methods that will draw similar pictures.

If you just want images to appear on the screen where the mouse was clicked, that is what the code you posted looks like, you could also create your images with a paint program, add them as resources to your project or load them in at run time, and use the DrawImage method of the Graphics class to draw the image at the appropriate place. That would save you considerable time and effort.
Was This Post Helpful? 1
  • +
  • -

#5 mikeymike  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 14
  • Joined: 30-November 09

Re: Easy way to draw pictures with code?

Posted 03 December 2009 - 10:29 PM

View PostSixOfEleven, on 4 Dec, 2009 - 01:31 PM, said:

If you just want images to appear on the screen where the mouse was clicked, that is what the code you posted looks like, you could also create your images with a paint program, add them as resources to your project or load them in at run time, and use the DrawImage method of the Graphics class to draw the image at the appropriate place. That would save you considerable time and effort.


Thankyou! So obvious yet I didn't think of it :blush:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1