AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
fix(gradients): constrain radial focus to the native circle
hugohe3872177726b58
diff --git a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.pyindex 81152543..760af4a4 100644--- a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py@@ -43,6 +43,7 @@ _OOXML_PERCENT_LITERAL_RE = re.compile(_OOXML_FULL_CIRCLE = 360 * ANGLE_UNIT_OOXML_PERCENTAGE_MIN = Decimal(-(2**31)) / Decimal(PERCENT_UNIT)_OOXML_PERCENTAGE_MAX = Decimal(2**31 - 1) / Decimal(PERCENT_UNIT)+_SVG_RADIAL_FOCUS_TOLERANCE = Decimal(1) / Decimal(PERCENT_UNIT)_DRAWINGML_FILL_NAMES = ("noFill","solidFill",@@ -270,6 +271,11 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,and focus_y + focus["b"] == Decimal(1)and Decimal(0) <= focus_x <= Decimal(1)and Decimal(0) <= focus_y <= Decimal(1)+ and (+ (focus_x - Decimal("0.5")) ** 2+ + (focus_y - Decimal("0.5")) ** 2+ <= Decimal("0.25") + _SVG_RADIAL_FOCUS_TOLERANCE+ ))if (point_focus@@ -286,7 +292,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,palette._diagnose("path-gradient-focus-normalized","DrawingML path gradient focus is not one point within "- "the SVG 0..1 focus range",+ "the canonical SVG radial circle","center the radial gradient while preserving its stops",)# Treat as radial regardless of path="circle" / "rect" / "shape" — SVGdiff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/styles.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/styles.pyindex bf2aeb76..6f9d5784 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/styles.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/styles.py@@ -14,6 +14,7 @@ from .utils import (px_to_emu, _f, _get_attr, parse_svg_length,combine_opacity, parse_inline_style, parse_opacity, parse_stop_style,classify_project_marker_shape,+ is_project_radial_focus_point,matrix_multiply, parse_svg_color, parse_transform_matrix, resolve_url_id,parse_project_filter_params, project_filter_drawingml_coordinates,parse_project_gradient_ratio, parse_project_linear_gradient_coordinate,@@ -125,6 +126,11 @@ def build_gradient_fill(focus_y = parse_project_gradient_ratio(grad_elem.get('fy', grad_elem.get('cy', '0.5')))+ if not is_project_radial_focus_point(focus_x, focus_y):+ raise ValueError(+ 'Radial gradient effective focus must lie within the '+ 'canonical circle centered at 0.5,0.5 with radius 0.5'+ )focus_l = quantize_ooxml_unit_ratio(focus_x)focus_t = quantize_ooxml_unit_ratio(focus_y)focus_r = 100000 - focus_ldiff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.pyindex ade00da8..dd44fbe5 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/utils.py@@ -230,6 +230,7 @@ PROJECT_GRADIENT_TAGS = frozenset({'linearGradient', 'radialGradient'})# PPTX angle projection can overshoot a unit box by at most ~0.1036.PROJECT_LINEAR_GRADIENT_COORDINATE_MIN = -0.105PROJECT_LINEAR_GRADIENT_COORDINATE_MAX = 1.105+PROJECT_RADIAL_FOCUS_TOLERANCE = 0.00001PROJECT_FILTER_PRIMITIVES = frozenset({'feDropShadow','feGaussianBlur',@@ -2313,6 +2314,16 @@ def parse_project_linear_gradient_coordinate(raw: str) -> float:return number+def is_project_radial_focus_point(focus_x: float, focus_y: float) -> bool:+ """Return whether a focus lies inside the canonical SVG radial circle."""+ if not math.isfinite(focus_x) or not math.isfinite(focus_y):+ return False+ return (+ (focus_x - 0.5) ** 2 + (focus_y - 0.5) ** 2+ <= 0.25 + PROJECT_RADIAL_FOCUS_TOLERANCE+ )++def project_gradient_errors(root: ET.Element) -> list[str]:"""Validate the normalized native gradient authoring interface."""errors: set[str] = set()@@ -2382,6 +2393,7 @@ def project_gradient_errors(root: ET.Element) -> list[str]:'point; use different x1/y1 and x2/y2 coordinates')else:+ radial_coordinates: dict[str, float] = {}for coordinate_name in ('cx', 'cy', 'r', 'fx', 'fy'):raw_coordinate = gradient.get(coordinate_name)if raw_coordinate is None:@@ -2395,8 +2407,34 @@ def project_gradient_errors(root: ET.Element) -> list[str]:f'got {raw_coordinate!r}')continue+ radial_coordinates[coordinate_name] = coordinateif coordinate_name == 'r' and coordinate <= 0:errors.add(f'{label} r must be greater than 0')+ focus_x_name = (+ 'fx' if gradient.get('fx') is not None else 'cx'+ )+ focus_y_name = (+ 'fy' if gradient.get('fy') is not None else 'cy'+ )+ focus_is_valid = (+ (+ gradient.get(focus_x_name) is None+ or focus_x_name in radial_coordinates+ )+ and (+ gradient.get(focus_y_name) is None+ or focus_y_name in radial_coordinates+ )+ )+ if focus_is_valid:+ focus_x = radial_coordinates.get(focus_x_name, 0.5)+ focus_y = radial_coordinates.get(focus_y_name, 0.5)+ if not is_project_radial_focus_point(focus_x, focus_y):+ errors.add(+ f'{label} effective focus (fx/fy, otherwise cx/cy) '+ 'must lie within the canonical circle centered at '+ f'0.5,0.5 with radius 0.5; got ({focus_x}, {focus_y})'+ )stops: list[ET.Element] = []for child in list(gradient):