Even if you spot a problem with the math or have some advice please help. Been working on this all night. It almost works, just a few lines out of place.
Either way, sorry about that. I am trying to draw a line. My point.draw function places a pixel on the screen. This function is reading two points and drawing every point in between them. It almost works but certain specific angles do not draw correctly. I am guessing there is something wrong with the math. If Anyone who has done something like this before i would greatly appreciate the help.
If Anyone who has done something like this before i would greatly appreciate the help.
I haven't ever done that myself (at least not successfully... ), but eventually there never has been a real need to do it anyway, and I'm quite happy about it...
At any rate, and since you neither posted code nor the problematic angles are really clear from your screen shot, perhaps the commonly used Bresenham line algorithm is helpful for you, either as a reference to spot what's wrong with your function, or as a basis to re-implement your function from scratch.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
The problem is i am not sure of the exact angle that does not work. So i cant show a single line. Here is my fill function.
You notice the dotted lines that appear. It may be a problem with my fill function though i had a similar problem with my lines earlier so i am pretty certain this is the issue. Any help would be great. Thanks.
I didnt post it, becouse i dont believe the problem is there. Also then i would need to include a lot of other classes etc. The actual project is huge.
If this is not enough information to solve the problem i understand.
Looking at the image you provided, it is clear that the way you are drawing the filled triangles is by drawing a lot of lines radiating from one of the triangle corners. This is not a good way to draw filled triangles for the following reasons:
1) If you don't draw enough lines you get missing pixels - as you are seeing
2) Pixels near the corner you are drawing from are overwritten (drawn more than once) - this is inefficient.
So it is your fill algorithm which is wrong.
To draw filled triangles you should use a scan-line fill algorithm, such as that shown here (http://www-users.mat.uni.torun.pl/~w...i_fillers.html). NB: I just found that on a quick google - I can't vouch for it's correctness.
Looking at the image you provided, it is clear that the way you are drawing the filled triangles is by drawing a lot of lines radiating from one of the triangle corners. This is not a good way to draw filled triangles for the following reasons:
1) If you don't draw enough lines you get missing pixels - as you are seeing
2) Pixels near the corner you are drawing from are overwritten (drawn more than once) - this is inefficient.
So it is your fill algorithm which is wrong.
To draw filled triangles you should use a scan-line fill algorithm, such as that shown here (http://www-users.mat.uni.torun.pl/~w...i_fillers.html). NB: I just found that on a quick google - I can't vouch for it's correctness.
Ah, thanks. I will check out that link. Sorry for my ignorance.
Bookmarks