MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / from_shape

Method from_shape

utils/src/presentation.py:575–617  ·  view source on GitHub ↗

Captures relevant geometry information (e.g., point sets) from the existing freeform shape. In python-pptx, retrieving detailed vertex information from the shape can be tricky, so you might rely on custom extension attributes, or simply store bounding-box and minima

(
        cls,
        slide_idx: int,
        shape_idx: int,
        shape,  # This will be the pptx.shapes.autoshape.Shape whose type is FREEFORM
        style: dict,
        text_frame: TextFrame,
        config: Config,
        slide_area: float,
        level: int,
    )

Source from the content-addressed store, hash-verified

573
574 @classmethod
575 def from_shape(
576 cls,
577 slide_idx: int,
578 shape_idx: int,
579 shape, # This will be the pptx.shapes.autoshape.Shape whose type is FREEFORM
580 style: dict,
581 text_frame: TextFrame,
582 config: Config,
583 slide_area: float,
584 level: int,
585 ):
586 """
587 Captures relevant geometry information (e.g., point sets) from the existing
588 freeform shape. In python-pptx, retrieving detailed vertex information from
589 the shape can be tricky, so you might rely on custom extension attributes, or
590 simply store bounding-box and minimal details. The 'data' dict is for your use.
591
592 For demonstration, we assume we have some way to extract or store
593 basic vertex info from `shape`. Not all details of a FREEFORM
594 can easily be retrieved from python-pptx, so you may have to
595 maintain that data separately as you create them.
596 """
597 # Hypothetical way to store some geometry or bounding box:
598 data = {
599 "name": shape.name,
600 "width": shape.width,
601 "height": shape.height,
602 "left": shape.left,
603 "top": shape.top,
604 # Possibly store a list of points if you have them:
605 "points": [], # If you have a way to retrieve them
606 "closed": True, # Whether to close the path
607 }
608
609 return cls(
610 slide_idx,
611 shape_idx,
612 style,
613 data,
614 text_frame,
615 slide_area,
616 level=level,
617 )
618
619 def build(self, slide: PPTXSlide):
620 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected