如何為文字添加反射效果

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

添加反射效果

要為文本指定反射效果,請創建TextStyle物件並使用Reflection物件填充ReflectionEffect屬性。最後,通過將TextStyle物件分配給TextEffect屬性,以所需樣式添加新文本。

:path=/static-assets/word/content-code-examples/how-to/text-effect-reflection-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()
{
    ReflectionEffect = new Reflection(),
};

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

// Export new Word document
doc.SaveAs("reflectionEffect.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 {.ReflectionEffect = New Reflection()}

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

' Export new Word document
doc.SaveAs("reflectionEffect.docx")
VB   C#
添加反射效果

反射效果屬性

反射效果提供了一系列可調整的屬性,以滿足多樣的設計需求。請參閱以下列表,了解各屬性的詳細描述:

  • SchemeColor: 獲取或設置反射效果的方案顏色。
  • HorizontalSkewAngle: 獲取或設置反射效果的水平傾斜角度。傾斜角度以度為單位指定。
  • HorizontalScalingFactor: 獲取或設置反射效果的水平縮放因子。
  • DistanceFromText: 獲取或設置反射效果與文字或物件的距離。距離以點為單位指定。 (1/72英寸).
  • DirectionAngle: 獲取或設定反射效果的方向角。方向角以度為單位指定。
  • FadeDirectionAngle: 獲取或設定反射效果的漸變方向。
  • EndPosition: 獲取或設定反射效果的結束位置。
  • StartPosition: 獲取或設定反射效果的起始位置。
  • EndingOpacity: 獲取或設定反射效果的結束不透明度。
  • VerticalScalingFactor: 獲取或設定反射效果的垂直縮放係數。
  • StartingOpacity: 獲取或設定反射效果的起始不透明度。
  • Alignment: 獲取或設定反射效果的對齊方式。
  • BlurRadius: 獲取或設定反射效果的模糊半徑。模糊半徑以點為單位指定。 (1/72英寸).
  • VerticalSkewAngle:取得或設定反射效果的垂直傾斜角度。傾斜角度以度數指定。
:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-reflection-effect.cs
using IronWord;
using IronWord.Models;
using IronWord.Models.Enums;

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

// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
    ReflectionEffect = new Reflection()
    {
        Alignment = RectangleAlignmentValues.BottomLeft,
        BlurRadius = 5,
        DirectionAngle = 90,
        DistanceFromText = 5,
        EndingOpacity = 100,
        EndPosition = 10,
        FadeDirectionAngle = 90,
        HorizontalScalingFactor = 100,
        HorizontalSkewAngle = 0,
        SchemeColor = IronWord.Models.Color.Gold,
        StartingOpacity = 0,
        StartPosition = 0,
        VerticalScalingFactor = -100,
        VerticalSkewAngle = 0,
    },
};

// Add text with style
doc.AddText("Customized reflection").Style = textStyle;

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

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

' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {
	.ReflectionEffect = New Reflection() With {
		.Alignment = RectangleAlignmentValues.BottomLeft,
		.BlurRadius = 5,
		.DirectionAngle = 90,
		.DistanceFromText = 5,
		.EndingOpacity = 100,
		.EndPosition = 10,
		.FadeDirectionAngle = 90,
		.HorizontalScalingFactor = 100,
		.HorizontalSkewAngle = 0,
		.SchemeColor = IronWord.Models.Color.Gold,
		.StartingOpacity = 0,
		.StartPosition = 0,
		.VerticalScalingFactor = -100,
		.VerticalSkewAngle = 0
	}
}

' Add text with style
doc.AddText("Customized reflection").Style = textStyle

' Export new Word document
doc.SaveAs("customizedReflectionEffect.docx")
VB   C#
自訂反射效果