manim.mobject.types.image_mobject.ImageMobject

class ImageMobject(filename_or_array, scale_to_resolution=1080, invert=False, image_mode='RGBA', **kwargs)[source]

Bases: manim.mobject.types.image_mobject.AbstractImageMobject

Displays an Image from a numpy array or a file.

Parameters

scale_to_resolution (int) – At this resolution the image is placed pixel by pixel onto the screen, so it will look the sharpest and best. This is a custom parameter of ImageMobject so that rendering a scene with e.g. the --quality low or --quality medium flag for faster rendering won’t effect the position of the image on the screen.

Example

../_images/ImageFromArray-1.png
ImageFromArray
class ImageFromArray(Scene):
    def construct(self):
        image = ImageMobject(np.uint8([[0, 100, 30, 200],
                                       [255, 0, 5, 33]]))
        image.height = 7
        self.add(image)

Methods

change_to_rgba_array

Converts an RGB array into RGBA with the alpha value opacity maxed.

fade

Sets the image’s opacity using a 1 - alpha relationship.

get_pixel_array

A simple getter method.

get_style

interpolate_color

Interpolates an array of pixel color values into another array of equal size.

set_color

Condition is function which takes in one arguments, (x, y, z).

set_opacity

Sets the image’s opacity.

Attributes

animate

Used to animate the application of a method.

depth

The depth of the mobject.

height

The height of the mobject.

width

The width of the mobject.

change_to_rgba_array()[source]

Converts an RGB array into RGBA with the alpha value opacity maxed.

fade(darkness=0.5, family=True)[source]

Sets the image’s opacity using a 1 - alpha relationship.

Parameters
  • darkness (float) – The alpha value of the object, 1 being transparent and 0 being opaque.

  • family (Boolean) – Whether the submobjects of the ImageMobject should be affected.

get_pixel_array()[source]

A simple getter method.

interpolate_color(mobject1, mobject2, alpha)[source]

Interpolates an array of pixel color values into another array of equal size.

Parameters
  • mobject1 (ImageMobject) – The ImageMobject to transform from.

  • mobject1 – The ImageMobject to transform into.

  • alpha (float) – Used to track the lerp relationship. Not opacity related.

set_color(color, alpha=None, family=True)[source]

Condition is function which takes in one arguments, (x, y, z). Here it just recurses to submobjects, but in subclasses this should be further implemented based on the the inner workings of color

set_opacity(alpha)[source]

Sets the image’s opacity.

Parameters

alpha (float) – The alpha value of the object, 1 being opaque and 0 being transparent.