Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / how to draw a filled circle

Author
Message
freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 8th Jun 2003 19:57
I tried this:

for t=1 to radius
circle x,y,t
next t


but not all pixels are colored, some aren't so this doesn't result in a nice filled circle

anyone who knows a better method?
[href]www.bernardfrancois.com[/href]
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 8th Jun 2003 19:58
I draw my stuff in msPaint

---Mattman
"Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done." Andy Rooney
freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 8th Jun 2003 20:00
lol
but I want to code it

[href]www.bernardfrancois.com[/href]
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 8th Jun 2003 20:15
I don't do that stuff 2 hard and mathmatical, though I'm a straight A Student in P.A. and excel Math

---Mattman
"Computers make it easier to do a lot of things, but most of the things they make it easier to do don't need to be done." Andy Rooney
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 9th Jun 2003 07:03
One pixel at a time. Here's for drawing to the center of the screen; I'm sure you can figure out how to do offsets.

for x=-radius to radius
for y=-radius to radius
if x^2+y^2 <= radius^2 then dot x,y
next x
next y

freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 9th Jun 2003 12:21
ok I see, that must work
yeh for the offsset I just have to use dot x+xoffset,y+yoffset (where negatige offsets move it to the left and up, and positive offsets can move it down and right)

thanks!

[href]www.bernardfrancois.com[/href]
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 9th Jun 2003 12:31 Edited at: 9th Jun 2003 12:31
Might want to implement pixel rounding also, otherwise the edges of the circle may look jagged, especially with small circles.

To implement rounding, change to:
int(x + xoffset + .5)^2 + int(y + yoffset + .5)^2 <= radius^2

freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 9th Jun 2003 12:35
you could first draw a circle with the average color of the foreground and background, and then draw a circle over it which is slightly smaller, and in the original foreground color
like that it should be a bit anti-aliased
I haven't tried it yet, I'll do after I've continued studying a bit...

[href]www.bernardfrancois.com[/href]
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 9th Jun 2003 12:39 Edited at: 9th Jun 2003 12:40
<psuedo-german accent>

Was-ever flötens das Boot...

</psuedo-german accent>

freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 9th Jun 2003 15:10
To implement rounding, change to:
int(x + xoffset + .5)^2 + int(y + yoffset + .5)^2 <= radius^2

what do I have to change to this?

anyway if you change if x^2+y^2 <= radius^2 then dot x,y to if x^2+y^2 < radius^2 then dot x,y it's also better

I also added an antialiasing effect... I have put it in a function but it doesnt respond on the ink command used before the function... In order to change this I should be able to find out what's the current foreground and background color values are...
Is there some command to return those?

here's the code:



[href]www.bernardfrancois.com[/href]
freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 9th Jun 2003 15:42
hmm it doesn't matter... this method isn't good to make something antialiased, coz the antialiased pixels are just the average color between foreground and background color
they should be the average between the foreground color and the pixels outside the circle... coz when you draw a circle above other 2d things you'll just have a border around it

[href]www.bernardfrancois.com[/href]
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 9th Jun 2003 17:22
You could also use SIN to find the angle and stuff then draw the circle

RPGamer

Current Project: Eternal Destiny
Questions? Comments? Suggestions? Go to the Eternal Destiny Forum!
freak
22
Years of Service
User Offline
Joined: 20th Jan 2003
Location:
Posted: 9th Jun 2003 18:00
I think that's what the normal circle command does
I would still have some points not colored I think

[href]www.bernardfrancois.com[/href]
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 9th Jun 2003 18:08
I don't know if this is any faster (written in DBP but should imagine would work in DBC):
Wiggett
21
Years of Service
User Offline
Joined: 31st May 2003
Location: Australia
Posted: 9th Jun 2003 18:09
ahh too much maths, too little brain

i need a copy of the 1.03 exe or i cant work on my game anymore

Login to post a reply

Server time is: 2025-05-19 22:50:46
Your offset time is: 2025-05-19 22:50:46