Files
limbach/adesso_style.py
marcus hinz 93bb19abf0 initial
2026-06-20 14:40:33 +02:00

77 lines
3.2 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""Gemeinsames adesso-Styling für die Workshop-Folien.
Teal->Blau-Verlauf, Fira Sans, weiße Shapes + Coral-Akzente,
Header (Pill + Titel) und schlanke Fußzeile (Seitenzahl + adesso)."""
from pptx.util import Inches, Pt
from pptx.dml.color import RGBColor
from pptx.enum.text import PP_ALIGN, MSO_ANCHOR
from pptx.enum.shapes import MSO_SHAPE
from pptx.oxml.ns import qn
# ---- adesso Palette --------------------------------------------------------
WHITE = RGBColor(0xFF, 0xFF, 0xFF)
INK = RGBColor(0x0E, 0x2A, 0x47) # tiefes Navy Text auf hellen Boxen / dunkle Füllungen
BLUE = RGBColor(0x00, 0x6E, 0xC7)
TEAL = RGBColor(0x28, 0xDC, 0xAA)
GREEN = RGBColor(0x76, 0xC8, 0x00)
CORAL = RGBColor(0xFF, 0x98, 0x68)
PINK = RGBColor(0xF5, 0x66, 0xBA)
TAUPE = RGBColor(0x88, 0x7D, 0x75)
LIGHT = RGBColor(0xD7, 0xE6, 0xF4) # helle, gedämpfte Schrift/Linien auf dem Verlauf
MUTE = RGBColor(0x6B, 0x77, 0x85) # mittleres Grau Text auf weißen Flächen
RECF = RGBColor(0xE6, 0xEF, 0xF8) # helle Kästchen in weißen Boxen
F = "Fira Sans"
FC = "Fira Sans Condensed"
def alpha(shape, opacity_pct):
"""Deckkraft (0-100) auf die Solid-Füllung setzen."""
srgb = shape._element.spPr.find(qn('a:solidFill')).find(qn('a:srgbClr'))
srgb.append(srgb.makeelement(qn('a:alpha'), {'val': str(int(opacity_pct * 1000))}))
def line_alpha(shape, opacity_pct):
ln = shape._element.spPr.find(qn('a:ln'))
srgb = ln.find(qn('a:solidFill')).find(qn('a:srgbClr'))
srgb.append(srgb.makeelement(qn('a:alpha'), {'val': str(int(opacity_pct * 1000))}))
def paint_background(s, width, height):
"""Teal->Blau-Verlauf als Folienhintergrund."""
bgr = s.shapes.add_shape(MSO_SHAPE.RECTANGLE, 0, 0, width, height)
bgr.line.fill.background(); bgr.shadow.inherit = False
bgr.fill.gradient()
try:
bgr.fill.gradient_angle = 90.0
except Exception:
pass
st = bgr.fill.gradient_stops
st[0].position = 0.0; st[0].color.rgb = TEAL
st[1].position = 1.0; st[1].color.rgb = BLUE
return bgr
def chrome(s, title, page):
"""Header (Pill + Titel) + schlanke Fußzeile (Seitenzahl + adesso)."""
pill = s.shapes.add_shape(MSO_SHAPE.ROUNDED_RECTANGLE,
Inches(0.55), Inches(0.46), Inches(0.5), Inches(0.26))
pill.fill.background(); pill.line.color.rgb = WHITE; pill.line.width = Pt(1.5)
pill.shadow.inherit = False
try: pill.adjustments[0] = 0.5
except Exception: pass
def _t(x, y, w, h, t, size, color, bold=False, align=PP_ALIGN.LEFT, font=FC):
tb = s.shapes.add_textbox(x, y, w, h); tf = tb.text_frame
tf.word_wrap = True; tf.margin_left = tf.margin_right = Pt(0)
tf.margin_top = tf.margin_bottom = Pt(0)
p = tf.paragraphs[0]; p.alignment = align
r = p.add_run(); r.text = t
r.font.size = Pt(size); r.font.bold = bold; r.font.name = font; r.font.color.rgb = color
_t(Inches(1.25), Inches(0.34), Inches(11), Inches(0.7), title, 30, WHITE, bold=True)
_t(Inches(0.55), Inches(7.06), Inches(1.0), Inches(0.3), str(page), 11, LIGHT)
_t(Inches(10.95), Inches(6.99), Inches(1.85), Inches(0.4), "adesso", 17, WHITE,
bold=True, align=PP_ALIGN.RIGHT)