Welcome to Dream.In.Code
Become a VB Expert!

Join 137,228 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,910 people online right now. Registration is fast and FREE... Join Now!




drawing commands

 
Reply to this topicStart new topic

drawing commands, need help with drawing commands

orangeslide8
18 Feb, 2007 - 05:27 AM
Post #1

D.I.C Head
Group Icon

Joined: 29 Dec, 2006
Posts: 190



Thanked: 1 times
Dream Kudos: 25
My Contributions
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.
thnx
john
User is offlineProfile CardPM
+Quote Post

NickDMax
RE: Drawing Commands
18 Feb, 2007 - 03:58 PM
Post #2

2B||!2B
Group Icon

Joined: 18 Feb, 2007
Posts: 2,859



Thanked: 50 times
Dream Kudos: 550
My Contributions
Visual Basic is not the best primative graphics environment. Each Form or PictureBox can be drawn on using the Line, Circle, or Pset meathods.
Example:
CODE

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.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 02:56PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month