Example #1
0
            def styles(keys):
                def clr_grad(color):
                    if color.startswith('rgba('):
                        r, g, b, a = rgba(color)
                        return '%d' % int(a * 100000)
                    elif 'opacity' in keys:
                        return '%d' % int(float(e.get('opacity')) * 100000)
                    else:
                        return '%d' % 100000

                # TODO: Optimize
                if 'fill' in keys:
                    if e.get('fill') == 'none':
                        shape.spPr.append(a.noFill())
                    else:
                        shape.spPr.append(
                            a.solidFill(
                                a.srgbClr(
                                    a.alpha(val=str(clr_grad(e.get('fill')))),
                                    val=str(msclr(e.get('fill'))))))
                elif not 'fill' in keys:
                    if tag not in ['line']:
                        shape.spPr.append(a.solidFill(color(srgbClr='000000')))

                if 'stroke' in keys and 'stroke-width' in keys:
                    shape.spPr.append(
                        a.ln(a.solidFill(
                            a.srgbClr(
                                a.alpha(val=str(clr_grad(e.get('stroke')))),
                                val=str(msclr(e.get('stroke'))))),
                             w=str(
                                 int(
                                     float(interpret_str(
                                         e.get('stroke-width'))) * 12700))))
                elif 'stroke' in keys:
                    if e.get('stroke') == 'none':
                        shape.spPr.append(a.ln(a.noFill()))
                    else:
                        shape.spPr.append(
                            a.ln(
                                a.solidFill(
                                    a.srgbClr(a.alpha(
                                        val=str(clr_grad(e.get('stroke')))),
                                              val=str(msclr(
                                                  e.get('stroke')))))))
                elif 'stroke' and 'fill' not in keys:
                    shape.spPr.append(
                        a.ln(a.solidFill(color(srgbClr='000000'))))
                elif not 'stroke' and 'fill' in keys:
                    if tag in ['rect']:
                        shape.spPr.append(a.ln(a.noFill()))
                    elif tag in ['circle', 'ellipse']:
                        shape.spPr.append(
                            a.ln(
                                a.solidFill(
                                    color(srgbClr=msclr(e.get('fill'))))))
                    elif tag in ['path', 'line']:
                        shape.spPr.append(
                            a.ln(a.solidFill(color(srgbClr='000000'))))
                return shape
Example #2
0
            def styles(keys):
                def clr_grad(color):
                    if color.startswith('rgba('):
                        r, g, b, a = rgba(color)
                        return  '%d' % int(a*100000)
                    elif 'opacity' in keys:
                        return '%d' % int(float(e.get('opacity')) * 100000)
                    else:
                        return '%d' % 100000


                # TODO: Optimize
                if 'fill' in keys:
                    if e.get('fill') == 'none':
                        shape.spPr.append(a.noFill())
                    else:
                        shape.spPr.append(a.solidFill(a.srgbClr(a.alpha(val=str(clr_grad(e.get('fill')))),
                            val=str(msclr(e.get('fill'))))))
                elif not 'fill' in keys:
                    if tag not in ['line']:
                        shape.spPr.append(a.solidFill(color(srgbClr='000000')))

                if 'stroke' in keys and 'stroke-width' in keys:
                    shape.spPr.append(a.ln(a.solidFill(a.srgbClr(a.alpha(val=str(clr_grad(e.get('stroke')))),
                        val=str(msclr(e.get('stroke'))))),
                        w=str(int(float(interpret_str(e.get('stroke-width')))*12700))))
                elif 'stroke' in keys:
                    if e.get('stroke') == 'none':
                        shape.spPr.append(a.ln(a.noFill()))
                    else:
                        shape.spPr.append(a.ln(a.solidFill(a.srgbClr(a.alpha(val=str(clr_grad(e.get('stroke')))), val=str(msclr(e.get('stroke')))))))
                elif 'stroke' and 'fill' not in keys:
                    shape.spPr.append(a.ln(a.solidFill(color(srgbClr='000000'))))
                elif not 'stroke' and 'fill' in keys:
                    if tag in ['rect']:
                        shape.spPr.append(a.ln(a.noFill()))
                    elif tag in ['circle','ellipse']:
                        shape.spPr.append(a.ln(a.solidFill(color(srgbClr=msclr(e.get('fill'))))))
                    elif tag in ['path', 'line']:
                        shape.spPr.append(a.ln(a.solidFill(color(srgbClr='000000'))))
                return shape
Example #3
0
shapes.append(shp)

# Fill with an RGB colour
shp.spPr.append(a.gradFill(
    a.gsLst(
        a.gs(color(schemeClr='accent2', tint= '0%'), pos="0"),
        a.gs(color(schemeClr='accent2', tint='20%'), pos="50000"),
        a.gs(color(schemeClr='accent2', tint='40%'), pos="100000"),
    ),
    a.lin(ang='2700000', scaled='1'), # out of 21600000 = 1/8 = 45 degrees
))

# Add a line
shp.spPr.append(a.ln(
    a.solidFill(color(        # Solid fill with
        schemeClr='accent2',  # 2nd theme colour
        shade='20%',          # 20% black mixed
        alpha='50%',          # 50% transparent
    )),
    w='3175',                 # 0.25pt stroke width
))

# Add text
shp.append(p.txBody(
    a.bodyPr(anchor='ctr'),   # vertically center the text
    a.p(
        a.pPr(algn='ctr'),     # horizontally center the text
        a.r(a.t('abc')),
)))
prs.save('sample.pptx')
Example #4
0
    a.gradFill(
        a.gsLst(
            a.gs(color(schemeClr='accent2', tint='0%'), pos="0"),
            a.gs(color(schemeClr='accent2', tint='20%'), pos="50000"),
            a.gs(color(schemeClr='accent2', tint='40%'), pos="100000"),
        ),
        a.lin(ang='2700000', scaled='1'),  # out of 21600000 = 1/8 = 45 degrees
    ))

# Add a line
shp.spPr.append(
    a.ln(
        a.solidFill(
            color(  # Solid fill with
                schemeClr='accent2',  # 2nd theme colour
                shade='20%',  # 20% black mixed
                alpha='50%',  # 50% transparent
            )),
        w='3175',  # 0.25pt stroke width
    ))

# Add text
shp.append(
    p.txBody(
        a.bodyPr(anchor='ctr'),  # vertically center the text
        a.p(
            a.pPr(algn='ctr'),  # horizontally center the text
            a.r(a.t('abc')),
        )))
prs.save('sample.pptx')