|
-
Oct 27th, 2002, 09:12 AM
#1
Thread Starter
Frenzied Member
Filled circle with exact pixel count
hi!
i've got a code for drawing a circle:
VB Code:
For Angle = 0 To 360 Step 1 / 100
SetPixelV Picture1.hdc, Round(CenterX + Cos((Angle * (3.1415926 / 180))) * Radius), Round(CenterY + Sin((Angle * (3.1415926 / 180))) * Radius), RGB(0, 255, 0)
Next Angle
but now i want to fill it using setpixelv but how?
if i do for i = 0 to radius, it draws too many or too few times at each pixel...so i have to change the step.
is there any way to know exactly how many pixels that will be used, or do i have to do this another way?
-
Oct 27th, 2002, 12:25 PM
#2
Good Ol' Platypus
It's easy. Create a reverse of the angle (360 - Angle) and use Cos() on both of them. Then, you have the left position and right position. Set your pixels from the left to the right (I think its AngRev to Angle) and use Sin(Angle) as the Y value.
It should work.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Oct 27th, 2002, 07:10 PM
#3
Thread Starter
Frenzied Member
-
Oct 27th, 2002, 07:22 PM
#4
Thread Starter
Frenzied Member
heres the new code:
VB Code:
For X = Round(CenterX + Cos(((360 - Angle) * (3.1415926 / 180))) * Radius) To Round(CenterX + Cos((Angle * (3.1415926 / 180))) * Radius)
For Y = Round(CenterY + Sin(((360 - Angle) * (3.1415926 / 180))) * Radius) To Round(CenterY + Sin((Angle * (3.1415926 / 180))) * Radius)
SetPixelV Picture1.hdc, X, Y, vbRed
Next Y
Next X
theres only one thing wrong with this....it draws a line across each time, and that makes is draw over some pixels alredy drawn...
the main reason i wanted to do this was to take the average color of every pixel and the paint color, so the new color was half transparent...
but if it draws too many times on some pixels, so the new color is not the average...
-
Oct 27th, 2002, 07:54 PM
#5
Thread Starter
Frenzied Member
oh!
i used the same x value for every pixel and it looked ok!
-
Oct 27th, 2002, 07:56 PM
#6
Thread Starter
Frenzied Member
oh....i missed some things...
it was not right!
-
Oct 27th, 2002, 08:07 PM
#7
Thread Starter
Frenzied Member
fixed some things!
works perfect now!
thanks for your help!
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
|