C#でテキストに反射効果を追加する方法 | IronWord

How to Add Reflection Effect to Text

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

テキストの反射効果は、テキストの下にその元の形状の鏡のようなイメージを作成する視覚的な強化です。 この効果は、テキストの表面の反射をシミュレートし、デザインに深みとリアリズムを追加することがよくあります。

C#でテキストに反射効果を適用するクイックスタート

IronWordを使用してわずか1行のコードで、プリセットの反射効果を任意のテキストに適用できます。 開発者はすぐに作業を開始でき、複雑なセットアップやボイラープレートコードは必要ありません。

Nuget IconGet started making PDFs with NuGet now:

  1. Install IronWord with NuGet Package Manager

    PM > Install-Package IronWord

  2. Copy and run this code snippet.

    new IronWord.WordDocument().AddText("Quick Text").Style = new IronWord.Models.TextStyle(){ TextEffect = new IronWord.Models.TextEffect(){ ReflectionEffect = new IronWord.Models.Reflection() } };
  3. Deploy to test on your live environment

    Start using IronWord in your project today with a free trial
    arrow pointer
class="hsg-featured-snippet">

最小限のワークフロー (5ステップ)

  1. テキストに反射を追加するためのC#ライブラリをダウンロードします。
  2. 新しく作成されたテキストまたは既存のテキストにテキスト効果を適用します。
  3. Reflectionクラスをインスタンス化してプリセットの反射効果を適用します。
  4. カスタマイズされたテキストアウトラインを実現するためにReflectionプロパティを設定します。
  5. 編集されたWordドキュメントを新しいファイルとしてエクスポートします。

反射効果を追加する

テキストの反射効果を指定するには、TextStyleオブジェクトを作成し、ReflectionEffectプロパティにReflectionオブジェクトを含めます。 最後に、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")
$vbLabelText   $csharpLabel
class="content-img-align-center">
class="center-image-wrapper"> 反射効果を追加する

反射効果のプロパティ

反射効果は、多様なデザイン要件に対応する調整可能な属性の範囲を提供します。 各プロパティの詳細な説明は以下のリストを参照してください:

  • 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")
$vbLabelText   $csharpLabel
class="content-img-align-center">
class="center-image-wrapper"> カスタマイズされた反射効果

よくある質問

C#を使用してWordドキュメント内のテキストに反射効果を追加するにはどうすればいいですか?

IronWordライブラリをダウンロードすることで、C#を使用してWordドキュメント内のテキストに反射効果を追加できます。まず`TextStyle`オブジェクトを作成し、その`ReflectionEffect`プロパティに`Reflection`オブジェクトを設定し、好みに合わせてプロパティをカスタマイズします。最後に、反射効果を適用したWordドキュメントをエクスポートします。

IronWordで反射効果に調整可能なプロパティは何ですか?

IronWordでは、`SchemeColor`、`HorizontalSkewAngle`、`HorizontalScalingFactor`、`DistanceFromText`、`DirectionAngle`、`FadeDirectionAngle`、`EndPosition`、`StartPosition`、`EndingOpacity`、`VerticalScalingFactor`、`StartingOpacity`、`Alignment`、`BlurRadius`、および`VerticalSkewAngle`などのプロパティを調整して反射効果をカスタマイズできます。

IronWordでテキストからの反射効果の距離をどのようにカスタマイズしますか?

IronWordでは、`DistanceFromText`プロパティを使用してテキストからの反射効果の距離を設定します。この距離はポイント(1/72インチ)で指定され、反射が元のテキストからどのくらい離れているかを制御できます。

IronWordで反射効果の不透明度を調整できますか?

はい、IronWordでは反射効果の不透明度を`StartingOpacity`および`EndingOpacity`プロパティを使用してカスタマイズできます。これにより、反射がどのように透明に始まり終わるかを定義し、そのビジュアルの存在感を制御できます。

`HorizontalSkewAngle`の反射効果における目的は何ですか?

IronWordの`HorizontalSkewAngle`プロパティは、反射効果の水平スキュー角度を設定します。度数で指定され、このプロパティは反射を水平にスキューすることでその外観を変えます。

C#でテキストに反射効果を追加し始めるにはどうすればいいですか?

まずIronWordライブラリをダウンロードしてください。次に`TextStyle`オブジェクトを作成し、`ReflectionEffect`プロパティに`Reflection`オブジェクトを設定します。利用可能なプロパティを使用して効果をカスタマイズし、テキストに適用します。

IronWordで反射効果のぼかしを調整できますか?

はい、IronWordでは`BlurRadius`プロパティを設定することで反射効果のぼかしを調整できます。この値はポイント(1/72インチ)で指定され、反射の柔らかさを制御できます。

Curtis Chau
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はいいですか?
Nuget ダウンロード 25,807 | バージョン: 2025.11 ただ今リリースされました