Aspose.Slides FOSS for Python lets you apply professional-quality visual effects to PowerPoint shapes entirely in Python, with no Microsoft Office and no API keys. This post demonstrates the fill system, 2D effects, and 3D formatting available in the library.


채우기 시스템

모든 도형은 fill_format 그 내부가 어떻게 채워지는지를 제어합니다. 다섯 가지 채우기 유형은 PowerPoint 디자인 팔레트의 전체 범위를 포괄합니다.

단색 채우기

가장 간단한 채우기로, 선택적 투명성을 가진 평면 색상입니다:

from aspose.slides_foss import ShapeType, FillType
from aspose.slides_foss.drawing import Color
import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    shape = prs.slides[0].shapes.add_auto_shape(
        ShapeType.ROUND_CORNER_RECTANGLE, 100, 100, 400, 150
    )
    shape.add_text_frame("Solid Fill")

    shape.fill_format.fill_type = FillType.SOLID
    shape.fill_format.solid_fill_color.color = Color.from_argb(255, 30, 80, 180)

    prs.save("solid.pptx", SaveFormat.PPTX)

선형 그라디언트 채우기

그라디언트 스톱을 사용하면 도형 전체에 걸쳐 한 색상에서 다른 색상으로 혼합할 수 있습니다:

from aspose.slides_foss import ShapeType, FillType, GradientShape
from aspose.slides_foss.drawing import Color
import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    shape = prs.slides[0].shapes.add_auto_shape(
        ShapeType.RECTANGLE, 100, 100, 400, 150
    )

    ff = shape.fill_format
    ff.fill_type = FillType.GRADIENT
    gf = ff.gradient_format
    gf.gradient_shape = GradientShape.LINEAR
    gf.linear_gradient_angle = 90   # top-to-bottom

    gf.gradient_stops.add(0.0, Color.from_argb(255, 30, 80, 180))   # top: blue
    gf.gradient_stops.add(1.0, Color.from_argb(255, 0, 200, 160))   # bottom: teal

    prs.save("gradient.pptx", SaveFormat.PPTX)

2D Visual Effects

외부 그림자

반투명 드롭 섀도우를 모든 도형에 적용합니다:

from aspose.slides_foss import ShapeType, FillType
from aspose.slides_foss.drawing import Color
import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    shape = prs.slides[0].shapes.add_auto_shape(
        ShapeType.ROUND_CORNER_RECTANGLE, 100, 100, 350, 150
    )
    shape.add_text_frame("Drop Shadow")

    shape.fill_format.fill_type = FillType.SOLID
    shape.fill_format.solid_fill_color.color = Color.white

    ef = shape.effect_format
    ef.enable_outer_shadow_effect()
    ef.outer_shadow_effect.blur_radius = 12
    ef.outer_shadow_effect.direction = 315   # upper-left
    ef.outer_shadow_effect.distance = 8
    ef.outer_shadow_effect.shadow_color.color = Color.from_argb(100, 0, 0, 0)

    prs.save("shadow.pptx", SaveFormat.PPTX)

글로우 효과

도형 가장자리 주변에 색상 광환을 추가합니다:

from aspose.slides_foss import ShapeType, FillType
from aspose.slides_foss.drawing import Color
import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    shape = prs.slides[0].shapes.add_auto_shape(
        ShapeType.ELLIPSE, 150, 100, 250, 250
    )
    shape.fill_format.fill_type = FillType.SOLID
    shape.fill_format.solid_fill_color.color = Color.from_argb(255, 20, 60, 140)

    ef = shape.effect_format
    ef.enable_glow_effect()
    ef.glow_effect.radius = 20
    ef.glow_effect.color.color = Color.from_argb(200, 0, 180, 255)

    prs.save("glow.pptx", SaveFormat.PPTX)

3D Formatting

베벨 및 재질

three_d_format 속성은 모든 평면 도형에 3차원적인 외관을 부여합니다. 베벨을 카메라 프리셋 및 재질과 결합하면 가장 풍부한 결과를 얻을 수 있습니다:

from aspose.slides_foss import (
    ShapeType, FillType,
    BevelPresetType, CameraPresetType,
    LightRigPresetType, LightingDirection,
    MaterialPresetType,
)
from aspose.slides_foss.drawing import Color
import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    shape = prs.slides[0].shapes.add_auto_shape(
        ShapeType.RECTANGLE, 150, 150, 300, 130
    )
    shape.add_text_frame("Metal Button")

    # Blue solid fill
    shape.fill_format.fill_type = FillType.SOLID
    shape.fill_format.solid_fill_color.color = Color.from_argb(255, 20, 70, 160)

    # 3D bevel + camera + light + material
    tdf = shape.three_d_format
    tdf.bevel_top.bevel_type = BevelPresetType.CIRCLE
    tdf.bevel_top.width = 10
    tdf.bevel_top.height = 5
    tdf.camera.camera_type = CameraPresetType.PERSPECTIVE_ABOVE
    tdf.light_rig.light_type = LightRigPresetType.BALANCED
    tdf.light_rig.direction = LightingDirection.TOP
    tdf.material = MaterialPresetType.METAL
    tdf.depth = 20

    prs.save("metal-button.pptx", SaveFormat.PPTX)

동일한 도형에 효과 결합

그림자와 3D 서식은 하나의 도형에서 동시에 사용할 수 있어 세련된 “카드” 디자인을 구현합니다:

from aspose.slides_foss import (
    ShapeType, FillType,
    BevelPresetType, CameraPresetType, MaterialPresetType,
)
from aspose.slides_foss.drawing import Color
import aspose.slides_foss as slides
from aspose.slides_foss.export import SaveFormat

with slides.Presentation() as prs:
    shape = prs.slides[0].shapes.add_auto_shape(
        ShapeType.ROUND_CORNER_RECTANGLE, 120, 120, 360, 150
    )
    shape.add_text_frame("Premium Card")

    # Fill
    shape.fill_format.fill_type = FillType.SOLID
    shape.fill_format.solid_fill_color.color = Color.from_argb(255, 30, 80, 180)

    # 3D bevel
    tdf = shape.three_d_format
    tdf.bevel_top.bevel_type = BevelPresetType.CIRCLE
    tdf.bevel_top.width = 8
    tdf.camera.camera_type = CameraPresetType.PERSPECTIVE_ABOVE
    tdf.material = MaterialPresetType.PLASTIC

    # Drop shadow
    ef = shape.effect_format
    ef.enable_outer_shadow_effect()
    ef.outer_shadow_effect.blur_radius = 14
    ef.outer_shadow_effect.direction = 270
    ef.outer_shadow_effect.distance = 8
    ef.outer_shadow_effect.shadow_color.color = Color.from_argb(70, 0, 0, 0)

    prs.save("premium-card.pptx", SaveFormat.PPTX)

설치

pip install aspose-slides-foss

Office 설치 없이, 라이선스 키 없이, 네트워크 호출 없이; 모든 처리는 로컬에서 수행됩니다.


관련 리소스