如何为文本添加光晕效果

This article was translated from English: Does it need improvement?
Translated
View the article in English

文字的辉光效果是一种视觉效果,能在字符周围营造出一种发光的光环。这种效果可使文字看起来像在发光,形成柔和、发光的轮廓,从而增强可读性并吸引注意力。

适用于的C# NuGet库

安装使用 NuGet

Install-Package IronWord
适用于的C# NuGet库

安装使用 NuGet

Install-Package IronWord
Java PDF JAR

下载 DLL

下载DLL

手动安装到你的项目中

开始在您的项目中使用IronPDF,并立即获取免费试用。

第一步:
green arrow pointer

查看 IronWordNuget 用于快速安装和部署。它有超过800万次下载,正在使用C#改变。

适用于的C# NuGet库 nuget.org/packages/IronWord/
Install-Package IronWord

Add Glow Effect

要指定文字的辉光效果,可以先创建并配置Glow对象。然后,从该 Glow 对象创建TextEffect对象。最后,将 TextEffect 赋值给文本的 TextEffect 属性。

:path=/static-assets/word/content-code-examples/how-to/text-effect-glow-effect.cs
using IronWord;
using IronWord.Models;

// Create new Word document
WordDocument doc = new WordDocument();

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    GlowEffect = new Glow()
    {
        GlowColor = IronWord.Models.Color.Aqua,
        GlowRadius = 10,
    },
};

// Add text with style
doc.AddText("Hello World").Style = textStyle;

// Export new Word document
doc.SaveAs("glowEffect.docx");
Imports IronWord
Imports IronWord.Models

' Create new Word document
Private doc As New WordDocument()

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {
	.GlowEffect = New Glow() With {
		.GlowColor = IronWord.Models.Color.Aqua,
		.GlowRadius = 10
	}
}

' Add text with style
doc.AddText("Hello World").Style = textStyle

' Export new Word document
doc.SaveAs("glowEffect.docx")
VB   C#
添加发光效果

闪光效果属性

以下是所有辉光效果属性及其说明:

  • GlowRadius :获取或设置辉光效果的半径。发光半径的单位是点 (1/72 英寸).
  • GlowColor :获取或设置发光效果的颜色。

辉光效果示例

让我们来看看更多的辉光效果示例。辉光效果的颜色也可以接受 ARGB 值。第一个值是 alpha 值,用于描述颜色的不透明程度。

发光效果示例