Was bored to decided to draw an image of a 3-D cube in VB.net. Heres the function I created. Was checking the internet on how to do it, but the code I found was really long and complicated.
Code:
Private Function DrawCube(ByVal Pen As Pen, ByVal Location As Point, ByVal Size As Integer) As Bitmap
Dim _Bitmap As New Bitmap(Me.Width, Me.Height)
Dim _Graphics As Graphics = Graphics.FromImage(_Bitmap)
_Graphics.DrawRectangle(Pen, New Rectangle(Location, New Size(Size, Size)))
_Graphics.DrawRectangle(Pen, New Rectangle(New Point(Size / 2, Size / 2), New Size(Size, Size)))
_Graphics.DrawLine(Pen, Location, New Point(Location.X + Size / 2 - Location.X, Location.Y + Size / 2 - Location.Y))
_Graphics.DrawLine(Pen, New Point(Location.X + Size, Location.Y), New Point(Size + Size / 2, Size / 2))
_Graphics.DrawLine(Pen, New Point(Location.X, Location.Y + Size), New Point(Location.X + Size / 2 - Location.X, Location.Y + Size + Size / 2 - Location.Y))
_Graphics.DrawLine(Pen, New Point(Location.X + Size, Location.Y + Size), New Point(Size + Size / 2, Size + Size / 2))
Return _Bitmap
End Function
Code:
'Example
PictureBox1.Image = DrawCube(Pens.Red, New Point(15, 15), 50)
However, it does have it's flaws. Which you'll eventually find after using the code.