def generate_rgba_array(self, color, opacity):
     """
     First arg can be either a color, or a tuple/list of colors.
     Likewise, opacity can either be a float, or a tuple of floats.
     """
     colors = listify(color)
     opacities = listify(opacity)
     return np.array([
         color_to_rgba(c, o) for c, o in zip(*make_even(colors, opacities))
     ])
예제 #2
0
 def match_style(self, vmobject, recurse=True):
     self.set_style(**vmobject.get_style(), recurse=False)
     if recurse:
         # Does its best to match up submobject lists, and
         # match styles accordingly
         submobs1, submobs2 = self.submobjects, vmobject.submobjects
         if len(submobs1) == 0:
             return self
         elif len(submobs2) == 0:
             submobs2 = [vmobject]
         for sm1, sm2 in zip(*make_even(submobs1, submobs2)):
             sm1.match_style(sm2)
     return self
예제 #3
0
    def match_style(self, vmobject, family=True):
        self.set_style(**vmobject.get_style(), family=False)

        if family:
            # Does its best to match up submobject lists, and
            # match styles accordingly
            submobs1, submobs2 = self.submobjects, vmobject.submobjects
            if len(submobs1) == 0:
                return self
            elif len(submobs2) == 0:
                submobs2 = [vmobject]
            for sm1, sm2 in zip(*make_even(submobs1, submobs2)):
                sm1.match_style(sm2)
        return self
예제 #4
0
    def generate_rgbas_array(self, color, opacity):
        """
        First arg can be either a color, or a tuple/list of colors.
        Likewise, opacity can either be a float, or a tuple of floats.
        If self.sheen_factor is not zero, and only
        one color was passed in, a second slightly light color
        will automatically be added for the gradient
        """
        colors = list(tuplify(color))
        opacities = list(tuplify(opacity))
        rgbas = np.array([
            color_to_rgba(c, o) for c, o in zip(*make_even(colors, opacities))
        ])

        sheen_factor = self.get_sheen_factor()
        if sheen_factor != 0 and len(rgbas) == 1:
            light_rgbas = np.array(rgbas)
            light_rgbas[:, :3] += sheen_factor
            clip_in_place(light_rgbas, 0, 1)
            rgbas = np.append(rgbas, light_rgbas, axis=0)
        return rgbas
예제 #5
0
    def generate_rgbas_array(self, color, opacity):
        """
        First arg can be either a color, or a tuple/list of colors.
        Likewise, opacity can either be a float, or a tuple of floats.
        If self.sheen_factor is not zero, and only
        one color was passed in, a second slightly light color
        will automatically be added for the gradient
        """
        colors = list(tuplify(color))
        opacities = list(tuplify(opacity))
        rgbas = np.array([
            color_to_rgba(c, o)
            for c, o in zip(*make_even(colors, opacities))
        ])

        sheen_factor = self.get_sheen_factor()
        if sheen_factor != 0 and len(rgbas) == 1:
            light_rgbas = np.array(rgbas)
            light_rgbas[:, :3] += sheen_factor
            clip_in_place(light_rgbas, 0, 1)
            rgbas = np.append(rgbas, light_rgbas, axis=0)
        return rgbas