Applicare effetti di forma nelle presentazioni usando Python tramite Java

Introduzione

Mentre gli effetti in PowerPoint possono essere usati per far risaltare una forma, differiscono da riempimenti o contorni. Utilizzando gli effetti di PowerPoint, è possibile creare riflessi convincenti su una forma, diffondere il bagliore di una forma, ecc.

effetto-forma

  • PowerPoint fornisce sei effetti che possono essere applicati alle forme. È possibile applicare uno o più effetti a una forma.

  • Alcune combinazioni di effetti appaiono migliori di altre. Per questo motivo, PowerPoint fornisce opzioni sotto Preset. Le opzioni Preset sono essenzialmente combinazioni di due o più effetti noti per avere un buon aspetto. In questo modo, selezionando un preset, non dovrai perdere tempo a testare o combinare effetti diversi per trovare una buona combinazione.

Aspose.Slides fornisce proprietà e metodi nella classe EffectFormat che consentono di applicare gli stessi effetti alle forme nelle presentazioni PowerPoint.

Applicare un effetto ombra

Questo codice Python mostra come applicare l’effetto ombra esterna (EffectFormat.getOuterShadowEffect) a un rettangolo:

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpype.startJVM()

from asposeslides.api import Presentation, SaveFormat, ShapeType
from java.awt import Color

presentation = Presentation()
try:
    shape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.RoundCornerRectangle, 20, 20, 200, 150)

    shape.getEffectFormat().enableOuterShadowEffect()
    shape.getEffectFormat().getOuterShadowEffect().getShadowColor().setColor(Color.DARK_GRAY)
    shape.getEffectFormat().getOuterShadowEffect().setDistance(10)
    shape.getEffectFormat().getOuterShadowEffect().setDirection(45)

    presentation.save("output.pptx", SaveFormat.Pptx)
finally:
    presentation.dispose()

Applicare un effetto riflesso

Questo codice Python mostra come applicare l’effetto riflesso a una forma:

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpype.startJVM()

from asposeslides.api import Presentation, RectangleAlignment, SaveFormat, ShapeType

presentation = Presentation()
try:
    shape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.RoundCornerRectangle, 20, 20, 200, 150)

    shape.getEffectFormat().enableReflectionEffect()
    shape.getEffectFormat().getReflectionEffect().setRectangleAlign(RectangleAlignment.Bottom)
    shape.getEffectFormat().getReflectionEffect().setDirection(90)
    shape.getEffectFormat().getReflectionEffect().setDistance(55)
    shape.getEffectFormat().getReflectionEffect().setBlurRadius(4)

    presentation.save("reflection.pptx", SaveFormat.Pptx)
finally:
    presentation.dispose()

Applicare un effetto bagliore

Questo codice Python mostra come applicare l’effetto bagliore a una forma:

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpype.startJVM()

from asposeslides.api import Presentation, SaveFormat, ShapeType
from java.awt import Color

presentation = Presentation()
try:
    shape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.RoundCornerRectangle, 20, 20, 200, 150)

    shape.getEffectFormat().enableGlowEffect()
    shape.getEffectFormat().getGlowEffect().getColor().setColor(Color.MAGENTA)
    shape.getEffectFormat().getGlowEffect().setRadius(15)

    presentation.save("glow.pptx", SaveFormat.Pptx)
finally:
    presentation.dispose()

Applicare un effetto bordi morbidi

Questo codice Python mostra come applicare un effetto bordi morbidi a una forma:

import jpype
import asposeslides

if not jpype.isJVMStarted():
    jpype.startJVM()

from asposeslides.api import Presentation, SaveFormat, ShapeType

presentation = Presentation()
try:
    shape = presentation.getSlides().get_Item(0).getShapes().addAutoShape(ShapeType.RoundCornerRectangle, 20, 20, 200, 150)

    shape.getEffectFormat().enableSoftEdgeEffect()
    shape.getEffectFormat().getSoftEdgeEffect().setRadius(15)

    presentation.save("softEdges.pptx", SaveFormat.Pptx)
finally:
    presentation.dispose()

FAQ

Posso applicare più effetti alla stessa forma?

Sì, è possibile combinare diversi effetti, come ombra, riflesso e bagliore, su un’unica forma per creare un aspetto più dinamico.

A quali forme posso applicare gli effetti?

È possibile applicare gli effetti a varie forme, incluse forme predefinite, grafici, tabelle, immagini, oggetti SmartArt, oggetti OLE e altro.

Posso applicare gli effetti a forme raggruppate?

Sì, è possibile applicare gli effetti a forme raggruppate. L’effetto verrà applicato all’intero gruppo.