"""
Circle class

Medical Images 2022-2023- MUEI/MNUR ETSEIB
D. Tost
"""
from point import Point


class Circle:
    @classmethod
    def from_dict(cls, dic):
        center = Point.from_dict(dic["center"])
        radius = dic["radius"]
        color = tuple(dic["color"])
        return cls(center, radius, color)

    def __init__(self, center, radius, color):
        self.center = center
        self.radius = radius
        self.color = color

    def __str__(self):
        return "Circle center is {} and radius is {}".format(str(self.center), self.radius)


    def to_dict(self):
        return {
            "center": self.center.to_dict(),
            "radius": self.radius,
            "color": list(self.color),
        }

    def __eq__(self, other):
        """
        Returns True if 2 cercles ahve the same center, color and radius
        """
        return self.radius == other.radius and  self.center == other.center and   self.color == other.color
    

    def bounding_box(self):
        """
        To be implemented: it returns the bounding box of the circle
        """
        return None
    
    def rasterization(self, matx):
        """
        To be implemented: it returns the list of pixels corresponding to the
        rasterization of the circle having applied the window-to -viewport transformation matrix
        """
        return []
