moviepy.video.tools.drawing.color_split#

moviepy.video.tools.drawing.color_split(size, x=None, y=None, p1=None, p2=None, vector=None, color_1=0, color_2=1.0, gradient_width=0)[source]#

Make an image split in 2 colored regions.

Returns an array of size size divided in two regions called 1 and 2 in what follows, and which will have colors color_1 and color_2 respectively.

Parameters:
  • x (int, optional) -- If provided, the image is split horizontally in x, the left region being region 1.

  • y (int, optional) -- If provided, the image is split vertically in y, the top region being region 1.

  • p1 (tuple or list, optional) -- Positions (x1, y1), (x2, y2) in pixels, where the numbers can be floats. Region 1 is defined as the whole region on the left when going from p1 to p2.

  • p2 (tuple or list, optional) -- Positions (x1, y1), (x2, y2) in pixels, where the numbers can be floats. Region 1 is defined as the whole region on the left when going from p1 to p2.

  • p1 -- p1 is (x1,y1) and vector (v1,v2), where the numbers can be floats. Region 1 is then the region on the left when starting in position p1 and going in the direction given by vector.

  • vector (tuple or list, optional) -- p1 is (x1,y1) and vector (v1,v2), where the numbers can be floats. Region 1 is then the region on the left when starting in position p1 and going in the direction given by vector.

  • gradient_width (float, optional) -- If not zero, the split is not sharp, but gradual over a region of width gradient_width (in pixels). This is preferable in many situations (for instance for antialiasing).

Examples

size = [200, 200]

# an image with all pixels with x<50 =0, the others =1
color_split(size, x=50, color_1=0, color_2=1)

# an image with all pixels with y<50 red, the others green
color_split(size, x=50, color_1=[255, 0, 0], color_2=[0, 255, 0])

# An image split along an arbitrary line (see below)
color_split(size, p1=[20, 50], p2=[25, 70], color_1=0, color_2=1)