Open phinjensen opened 2 years ago
I am pretty sure that +1 is used to avoid div by 0. I was confused by that too when I was doing it. I think it's a hack. The triangle may look a little bit odd in a large image. By when you scale up the scene, the small error won't matter I guess.
I've been working through the code and ran into this issue trying to port it to Rust. Rendering a couple of the example triangles using the initial line sweeping approach resulted in odd flat edges (scaled 4x with problem highlighted):
I checked out the code at commit 024ad4619b824f9179c86dc144145e2b8b155f52 (the linked commit), replaced its version of
triangle()
with the first one given, and found that it was also giving the weird edges, so it isn't just a problem with my code:But comparing it with that working version, I also found the issue is just in the calculation of segment_height, which shouldn't have the +1 in both cases. Removing that fixed the line drawing. Can we get the tutorial code or images updated to match each other?