drawing commands

need help with drawing commands

Page 1 of 1

1 Replies - 12768 Views - Last Post: 18 February 2007 - 04:58 PM Rate Topic: -----

#1 orangeslide8  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 203
  • Joined: 29-December 06

drawing commands

Posted 18 February 2007 - 06:27 AM

i need to draw a picture and have color and stuff but i don't know what the drawing commands are. could somone tell me them or atleast tell me how to make a picture box in the shape of a circle.
Is This A Good Question/Topic? 0
  • +

Replies To: drawing commands

#2 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2254
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: drawing commands

Posted 18 February 2007 - 04:58 PM

Visual Basic is not the best primative graphics environment. Each Form or PictureBox can be drawn on using the Line, Circle, or Pset meathods.
Option Explicit

Private Sub Form_Paint()
	Dim x As Long, y As Long, i As Single
	For i = 0 To 2 * 3.14159 Step 0.01
		x = 1000 + 900 * Cos(i)
		y = 1000 + 900 * Sin(i)
		Form1.PSet (x, y), RGB(255, 0, 0)
	Next i
	Form1.Circle (2000, 2000), 1000, RGB(0, 0, 255)
	Form1.Line (1000, 1000)-(2000, 2000), RGB(0, 255, 0)
	Form1.DrawWidth = 3
	Form1.Circle (2500, 1000), 800, RGB(0, 0, 0)
	Form1.Line (2500, 1000)-(2000, 2000), RGB(0, 255, 255)
	Form1.Line (1000, 1000)-(2500, 1000), RGB(255, 255, 0)
	Form1.DrawWidth = 10
	Form1.PSet (2000, 1250), RGB(255, 255, 255)
End Sub

These work in a pinch or for basic application graphics but are not very fast and not a lot of fun.

To really get down and dirty with graphics you will want to use Windows API calls or DirectX.

Since you mention a circular PictureBox there is a way to do this...

It involves makeing a "User Control," and adding a MaskPicture to its properties.

I am no expert in this but I will tell you what I know.

A mask is a Black and White picture that is used to mask out pixels in an image. Basicly wherever the mask is white the mask allows the picture behind it though, and wherever the mask is black it blocks the picture (making that part transparent).

So load up your image editor and create an image the same size as the one you want to display. Make the background black and add a white circle wherever you want the image to show.

Create a User Control and add the mask to the MaskPicture property. Then add the image to the Picture property. Then add the control to you Form...

I *Think* that this is not the best way... You can use the DrawMode and PaintPicture to mask I think... You can use API calls... You can Mask on a DirectX surface... These are probably better ways of doing it, but it'll work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1