|
-
Feb 11th, 2001, 12:27 PM
#1
Thread Starter
Lively Member
Hi!
How can I fill out a polygon with a color.
When I know the outline or the corner points of a polygon, so how can I get all pixels that are inside the shape.
I tried to move along the outline till I reach the center of the shape but I had a lot of problems.
Thank you for any help.
Using VB 6.0
-
Feb 11th, 2001, 01:05 PM
#2
PowerPoster
A simple way is drawing the polygon using the API...
Code:
'Open a new VB project and add this code
'to the general section:
'Types
Private Type tCoord2D
x As Long
y As Long
End Type
'Declares
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As tCoord2D, ByVal nCount As Long) As Long
'Now add this to the Form_MouseDown event:
Dim Points(2) As tCoord2D
'Setup form (You can put this in
'Form_Load or directly edit the props)
With Me
.ScaleMode = 3
.BackColor = 0
.ForeColor = RGB(128, 0, 255)
.FillColor = RGB(128, 0, 255)
.FillStyle = 0
.Cls
End With
'Setup poylgon with 3 corners
Points(0).X = X
Points(0).Y = Y
Points(1).X = X + 100
Points(1).Y = Y + 50
Points(2).X = X + 50
Points(2).Y = Y + 100
'Draw the polygon
Polygon Me.hdc, Points(0), 3
-
Feb 11th, 2001, 01:09 PM
#3
Thread Starter
Lively Member
Texture
Thanks!
But how can I fill the shape with a texture(from a Bitmap) or with a gradient fill?
-
Feb 11th, 2001, 02:27 PM
#4
PowerPoster
Thus you should use D3D... look at the D3D demo on my website which shows you how to draw a gradient-colored triangle (and rotate it )
-
Feb 11th, 2001, 05:04 PM
#5
Addicted Member
Or, you can create a region, select it into device context and then fill it with anything you want...
If you want (or if you are not familiar with the Windows API), I can make a sample app to demonstrate this.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|