Closed Cardosaum closed 1 year ago
@RobDavenport , could you please take a look in this new changes?
I made quite a few this time, trying to address your previous comments.
I think now it's impossible for us to have invalid XCord
and YCord
when creating them from validate_x
and validate_y
. It's also impossible to instantiate XCord
and YCord
manually, but it is technically possible to create invalid coordinates when multiplying or adding already existing ones. (I just figured out that it's actually the case. I may submit a new commit fixing it, and then it'll probably be possible to remove the checks in the draw_circle_points
)
Fix #4, drawing both
circle
andcircle_filled
correctly even when the circle would fall out of bounds (outside of screen).There might be room for optimizations.
Functions
set_pixel_safe
andx_y_cord_to_pixel_buffer_index
are admittedly ugly, I think it would be a good idea to create helper methods liketry_add(self, rhs) -> Result<Self, Error>
and variants in order to make the code cleaner. Probably adding a trait likeCoordinateMath
with such methods or something like that. If it's of interest, I can work on that later.