meerk40t / svgelements

SVG Parsing for Elements, Paths, and other SVG Objects.
MIT License
127 stars 28 forks source link

Fix Angle.as_radians #167

Closed Sophist-UK closed 2 years ago

Sophist-UK commented 2 years ago

Should return a float not an Angle. Other similar properties return a result of a float calculation which is by default float.

Sophist-UK commented 2 years ago

No - self is an Angle. Hence the need to float it to get a float.

tatarize commented 2 years ago
class Angle(float):
    """CSS Angle defines as used in SVG/CSS"""

Yes, it returns Angle but Angle is a float.

Sophist-UK commented 2 years ago

No - Angle is an Angle. print(Angle is float) gives False. And str(Angle(1.0).as_radians) returns Angle(1.00000000) rather than1.0`. Just because it is a subclass doesn't make it the same.

Jens transformation PR highlighted this BUG. If it hadn't shown up as a bug, I wouldn't have submitted this PR.

tatarize commented 2 years ago

You certainly have a point. I'll check the others and make sure they return a proper float but really you can cast a float type to just a float type without any issue. But, it does seem a bit more consistent to do things this way if the other angles also do things that way.

tatarize commented 2 years ago

Yeah, for the sake of consistency you shouldn't need to cast that as a float.