Jump to content
  • Advertisement
Sign in to follow this  
Ksingh30

C#

This topic is 4696 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

is there a way I can dynamically draw pictures in C#, for example I have a program its does some stuff, and based on the result I wanna draw a box or a sphere. what would be the best method to draw this.

Share this post


Link to post
Share on other sites
Advertisement
The System.Drawing namespace (GDI+) has a buttload of stuff that allows all sorts of flexible drawing. To use this stuff, you need to get a Graphics object, which is most easily obtained from a System.Windows.Forms.Control object using the CreateGraphics() method. Using the Graphics object, you can call various Draw* methods to draw lines, curves, filled shapes, and images. The documentation should contain a wealth of information for you to browse.

Share this post


Link to post
Share on other sites
You can use the Graphics class in the .NET framework to draw boxes and stuff. You could even use the GDI extensions. SDL.NET uses SDL_gfx for primitive drawing.

Share this post


Link to post
Share on other sites
ok I need to convert double to float, how do I do that.
theres not Convert.Tofloat(value)

is it possible to do that?

Share this post


Link to post
Share on other sites
Quote:
Original post by Ksingh30
ok I need to convert double to float, how do I do that.
theres not Convert.Tofloat(value)

is it possible to do that?


Yes, it's an explicit conversion:

double val1 = 5;
float val2 = (float)val1;

I tried it in C# to make sure it works before hand [wink] That should do it. For more information on that nonsense in C#, look at this MSDN page. It can get quite confusing at times when you need a function to go between types or just a typecast.

[edit]Explicit conversions page. The other link is for the implicit ones.

[Edited by - Drew_Benton on October 8, 2005 3:21:45 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Ksingh30
ok I need to convert double to float, how do I do that.
theres not Convert.Tofloat(value)

You're looking for Convert.ToSingle(value). A float is a "single precision floating point" variable. But it just gives you the same result as what Drew_Benton posted, so you should really use that instead.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!