It isn't that I don't want to help, but this is a topic that is older than I am and I'll be 40 in March. Doctoral thesis were written on this subject up through the '90s. I would recommend you break this down into parts and try to solve each part. How would you scan convert a triangle with a flat bottom vs. a flat top vs. a general triangle? What tests would you need to perform? How should your code change?
I found multiple examples on Google in seconds, but I strongly recommend you not go this route. It is simple math and you're already part way there.