Aspose.Slides FOSS for .NET ให้คุณใช้เอฟเฟกต์ภาพคุณภาพระดับมืออาชีพกับรูปร่าง PowerPoint ทั้งหมดใน C# โดยไม่ต้องใช้ Microsoft Office และไม่ต้องใช้ API keys. โพสต์นี้แสดงระบบ fill, เอฟเฟกต์ 2D, และการจัดรูปแบบ 3D ที่มีในไลบรารี.


ระบบเติม

แต่ละรูปทรงมี FillFormat ที่ควบคุมการทาสีภายในของมัน. ห้าชนิดการเติมสีครอบคลุมช่วงเต็มของพาเลตการออกแบบของ PowerPoint.

เติมสีทึบ

การเติมสีที่ง่ายที่สุด, สีเรียบพร้อมความโปร่งใสตามต้องการ:

using Aspose.Slides.Foss;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.RoundCornerRectangle, 100, 100, 400, 150
);
shape.AddTextFrame("Solid Fill");

shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 30, 80, 180);

prs.Save("solid.pptx", SaveFormat.Pptx);

การเติมไลเนียร์เกรเดียนท์

จุดหยุดไล่ระดับสีทำให้คุณสามารถผสมสีจากสีหนึ่งไปยังอีกสีหนึ่งทั่วทั้งรูปทรง:

using Aspose.Slides.Foss;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Rectangle, 100, 100, 400, 150
);

var ff = shape.FillFormat;
ff.FillType = FillType.Gradient;
var gf = ff.GradientFormat;
gf.GradientShape = GradientShape.Linear;
gf.LinearGradientAngle = 90;   // top-to-bottom

gf.GradientStops.Add(0.0f, Color.FromArgb(255, 30, 80, 180));   // top: blue
gf.GradientStops.Add(1.0f, Color.FromArgb(255, 0, 200, 160));   // bottom: teal

prs.Save("gradient.pptx", SaveFormat.Pptx);

เอฟเฟกต์ภาพ 2 มิติ

เงาตกด้านนอก

แนบเงาตกแบบกึ่งโปร่งใสให้กับรูปร่างใดก็ได้:

using Aspose.Slides.Foss;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.RoundCornerRectangle, 100, 100, 350, 150
);
shape.AddTextFrame("Drop Shadow");

shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.White;

var ef = shape.EffectFormat;
ef.EnableOuterShadowEffect();
ef.OuterShadowEffect.BlurRadius = 12;
ef.OuterShadowEffect.Direction = 315;   // upper-left
ef.OuterShadowEffect.Distance = 8;
ef.OuterShadowEffect.ShadowColor.Color = Color.FromArgb(100, 0, 0, 0);

prs.Save("shadow.pptx", SaveFormat.Pptx);

เอฟเฟกต์เรืองแสง

วงแหวนสีรอบขอบรูปทรง:

using Aspose.Slides.Foss;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Ellipse, 150, 100, 250, 250
);
shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 20, 60, 140);

var ef = shape.EffectFormat;
ef.EnableGlowEffect();
ef.GlowEffect.Radius = 20;
ef.GlowEffect.Color.Color = Color.FromArgb(200, 0, 180, 255);

prs.Save("glow.pptx", SaveFormat.Pptx);

การจัดรูปแบบ 3D

มุมตัดและวัสดุ

คุณสมบัติ ThreeDFormat ทำให้รูปทรงแบนใด ๆ มีลักษณะสามมิติ ผสานการทำ bevel กับการตั้งค่ากล้องและวัสดุเพื่อผลลัพธ์ที่ดีที่สุด:

using Aspose.Slides.Foss;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.Rectangle, 150, 150, 300, 130
);
shape.AddTextFrame("Metal Button");

// Blue solid fill
shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 20, 70, 160);

// 3D bevel + camera + light + material
var tdf = shape.ThreeDFormat;
tdf.BevelTop.BevelType = BevelPresetType.Circle;
tdf.BevelTop.Width = 10;
tdf.BevelTop.Height = 5;
tdf.Camera.CameraType = CameraPresetType.PerspectiveAbove;
tdf.LightRig.LightType = LightRigPresetType.Balanced;
tdf.LightRig.Direction = LightingDirection.Top;
tdf.Material = MaterialPresetType.Metal;
tdf.Depth = 20;

prs.Save("metal-button.pptx", SaveFormat.Pptx);

การรวมเอฟเฟกต์บนรูปร่างเดียวกัน

เงาและการจัดรูปแบบ 3D สามารถอยู่ร่วมกันบนรูปทรงเดียวได้ ทำให้สามารถออกแบบ “การ์ด” ที่เรียบหรูได้:

using Aspose.Slides.Foss;

using var prs = new Presentation();
var shape = prs.Slides[0].Shapes.AddAutoShape(
    ShapeType.RoundCornerRectangle, 120, 120, 360, 150
);
shape.AddTextFrame("Premium Card");

// Fill
shape.FillFormat.FillType = FillType.Solid;
shape.FillFormat.SolidFillColor.Color = Color.FromArgb(255, 30, 80, 180);

// 3D bevel
var tdf = shape.ThreeDFormat;
tdf.BevelTop.BevelType = BevelPresetType.Circle;
tdf.BevelTop.Width = 8;
tdf.Camera.CameraType = CameraPresetType.PerspectiveAbove;
tdf.Material = MaterialPresetType.Plastic;

// Drop shadow
var ef = shape.EffectFormat;
ef.EnableOuterShadowEffect();
ef.OuterShadowEffect.BlurRadius = 14;
ef.OuterShadowEffect.Direction = 270;
ef.OuterShadowEffect.Distance = 8;
ef.OuterShadowEffect.ShadowColor.Color = Color.FromArgb(70, 0, 0, 0);

prs.Save("premium-card.pptx", SaveFormat.Pptx);

การติดตั้ง

dotnet add package Aspose.Slides.Foss

ไม่มีการติดตั้ง Office, ไม่มีคีย์ใบอนุญาต, ไม่มีการเรียกเครือข่าย; การประมวลผลทั้งหมดเกิดขึ้นในเครื่อง


แหล่งข้อมูลที่เกี่ยวข้อง