Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Write the a:xfrm element.
self._write_a_xfrm(col_absolute, row_absolute, width, height, shape)
# Write the a:prstGeom element.
self._write_a_prst_geom(shape)
if shape.fill:
if not shape.fill['defined']:
# Write the a:solidFill element.
self._write_a_solid_fill_scheme('lt1')
elif 'none' in shape.fill:
# Write the a:noFill element.
self._xml_empty_tag('a:noFill')
elif 'color' in shape.fill:
# Write the a:solidFill element.
self._write_a_solid_fill(get_rgb_color(shape.fill['color']))
if shape.gradient:
# Write the a:gradFill element.
self._write_a_grad_fill(shape.gradient)
# Write the a:ln element.
self._write_a_ln(shape.line)
self._xml_end_tag('xdr:spPr')
def _write_a_gs_lst(self, gradient):
# Write the element.
positions = gradient['positions']
colors = gradient['colors']
self._xml_start_tag('a:gsLst')
for i in range(len(colors)):
pos = int(positions[i] * 1000)
attributes = [('pos', pos)]
self._xml_start_tag('a:gs', attributes)
# Write the a:srgbClr element.
# TODO: Wait for a feature request to support transparency.
color = get_rgb_color(colors[i])
self._write_a_srgb_clr(color)
self._xml_end_tag('a:gs')
self._xml_end_tag('a:gsLst')
def _write_a_solid_fill(self, fill):
# Write the element.
self._xml_start_tag('a:solidFill')
if 'color' in fill:
color = get_rgb_color(fill['color'])
transparency = fill.get('transparency')
# Write the a:srgbClr element.
self._write_a_srgb_clr(color, transparency)
self._xml_end_tag('a:solidFill')
def _write_a_bg_clr(self, color):
# Write the element.
color = get_rgb_color(color)
self._xml_start_tag('a:bgClr')
# Write the a:srgbClr element.
self._write_a_srgb_clr(color)
self._xml_end_tag('a:bgClr')
def _write_a_fg_clr(self, color):
# Write the element.
color = get_rgb_color(color)
self._xml_start_tag('a:fgClr')
# Write the a:srgbClr element.
self._write_a_srgb_clr(color)
self._xml_end_tag('a:fgClr')
def _write_a_gs_lst(self, gradient):
# Write the element.
positions = gradient['positions']
colors = gradient['colors']
self._xml_start_tag('a:gsLst')
for i in range(len(colors)):
pos = int(positions[i] * 1000)
attributes = [('pos', pos)]
self._xml_start_tag('a:gs', attributes)
# Write the a:srgbClr element.
# TODO: Wait for a feature request to support transparency.
color = get_rgb_color(colors[i])
self._write_a_srgb_clr(color)
self._xml_end_tag('a:gs')
self._xml_end_tag('a:gsLst')