-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshapeColor.py
55 lines (52 loc) · 2.48 KB
/
shapeColor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from utils import *
def change_shape_color(slide,NewThemeColor,
_gradient_angle,
_transparency,
_change_shape_color):
'''
change fill color of each shape (not including picture)
'''
if _change_shape_color:
for shape in slide.shapes:
# print(shape.shape_type)
if shape.shape_type in [MSO_SHAPE_TYPE.AUTO_SHAPE,\
MSO_SHAPE_TYPE.FREEFORM, \
]:
fill = shape.fill
# change SOLID color
if fill.type in [MSO_FILL.SOLID]:
set_fill_solid_color(fill,NewThemeColor,_transparency)
# change GRADIENT color
elif fill.type in [MSO_FILL.GRADIENT]:
set_fill_gradient_color(fill,NewThemeColor,2,_gradient_angle)
# change BACKGROUND color
elif fill.type in [MSO_FILL.BACKGROUND]:
# _transparency = 1
set_fill_solid_color(fill,NewThemeColor,_transparency)
# set Nonecolor type to transparent
# else:
# set_fill_solid_color(fill,NewThemeColor,_transparency)
group_shapes = [
shp for shp in slide.shapes
if shp.shape_type == MSO_SHAPE_TYPE.GROUP
]
for group_shape in group_shapes:
for shape in group_shape.shapes:
if shape.shape_type in [MSO_SHAPE_TYPE.AUTO_SHAPE,\
MSO_SHAPE_TYPE.FREEFORM, \
]:
fill = shape.fill
# change SOLID color
if fill.type in [MSO_FILL.SOLID]:
set_fill_solid_color(fill,NewThemeColor,_transparency)
# change GRADIENT color
elif fill.type in [MSO_FILL.GRADIENT]:
set_fill_gradient_color(fill,NewThemeColor,2,_gradient_angle)
# change BACKGROUND color
elif fill.type in [MSO_FILL.BACKGROUND]:
set_fill_solid_color(fill,NewThemeColor,_transparency)
# set Nonecolor type to transparent
# else:
# set_fill_solid_color(fill,NewThemeColor,_transparency)
else:
pass