テキストにグラデーション効果を追加する方法
テキストにグラデーションをかけると、文字や背景の色がなめらかに変化し、ある色から別の色、あるいは複数の色にブレンドされます。 この効果により、テキストに深み、視覚的な面白さ、ダイナミックな外観が加わり、テキストが際立ち、美的外観が向上する。 勾配効果は直線的な場合もある(直線的な色の変化)またはラジアル(中心点から外側への色の変化)
IronWordの使用を開始する
今日から無料トライアルでIronWordをあなたのプロジェクトで使い始めましょう。
テキストにグラデーション効果を追加する方法
- テキストにグラデーションをつけるC#(シーシャープ)ライブラリのダウンロード
- 新規作成または既存のテキストにテキスト効果を適用します。
- の静的な名前付きインスタンスを使用して、プリセットのグラデーション効果を使用します。 グラデーション クラス
- 構成する グラデーション効果 プロパティでテキストのアウトラインをカスタマイズ
- 編集したWord文書を新規ファイルとして書き出す
グラデーション効果の追加
テキストのグラデーション効果を指定するには、TextStyle オブジェクトを作成し、GradientEffect プロパティに Gradient オブジェクトを設定します。 最後に、TextEffectプロパティにTextStyleオブジェクトを代入して、スタイルを持つ新しいテキストを追加します。
:path=/static-assets/word/content-code-examples/how-to/text-effect-gradient-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()
{
GradientEffect = Gradient.DefaultGray,
};
// Add text with style
doc.AddText("Hello World").Style = textStyle;
// Export new Word document
doc.SaveAs("gradientEffect.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 {.GradientEffect = Gradient.DefaultGray}
' Add text with style
doc.AddText("Hello World").Style = textStyle
' Export new Word document
doc.SaveAs("gradientEffect.docx")
グラデーション効果のプロパティ
グラデーション・エフェクトは、多様なデザイン要件を満たすために調整可能な属性を提供します。 各物件の詳細については、以下のリストを参照のこと:
**グラデーションストップ
- Color:グラデーションストップのスキームカラーを取得または設定します。
-
StopPoint:グラデーションストップの位置を取得または設定します。
グラデーションストップとは、グラデーション内で特定の色が定義される点のことです。
**グラデーション
- StopPoints:グラデーションの塗りつぶしを定義するグラデーションストップのリストを取得または設定します。
- LinearShadeScaled:リニアシェードがスケーリングされるかどうかを示す値を取得または設定します。
- LinearShadeAngle:リニアシェードの角度を取得または設定します。
:path=/static-assets/word/content-code-examples/how-to/text-effect-customized-gradient-effect.cs
using IronWord;
using IronWord.Models;
using System.Collections.Generic;
// Create new Word document
WordDocument doc = new WordDocument();
// Create gradient stops
GradientStop firstGradientStop = new GradientStop()
{
Color = IronWord.Models.Color.Aqua,
StopPoint = 1
};
GradientStop secondGradientStop = new GradientStop()
{
Color = IronWord.Models.Color.OrangeRed,
StopPoint = 10
};
// Create and configure text style
TextStyle textStyle = new TextStyle();
textStyle.TextEffect = new TextEffect()
{
GradientEffect = new Gradient()
{
StopPoints = new List<GradientStop> { firstGradientStop, secondGradientStop },
LinearShadeAngle = 45,
LinearShadeScaled = true,
}
};
// Add text with style
doc.AddText("Hello World").Style = textStyle;
// Export new Word document
doc.SaveAs("customizedGradientEffect.docx");
Imports IronWord
Imports IronWord.Models
Imports System.Collections.Generic
' Create new Word document
Private doc As New WordDocument()
' Create gradient stops
Private firstGradientStop As New GradientStop() With {
.Color = IronWord.Models.Color.Aqua,
.StopPoint = 1
}
Private secondGradientStop As New GradientStop() With {
.Color = IronWord.Models.Color.OrangeRed,
.StopPoint = 10
}
' Create and configure text style
Private textStyle As New TextStyle()
textStyle.TextEffect = New TextEffect() With {
.GradientEffect = New Gradient() With {
.StopPoints = New List(Of GradientStop) From {firstGradientStop, secondGradientStop},
.LinearShadeAngle = 45, .LinearShadeScaled = True
}
}
' Add text with style
doc.AddText("Hello World").Style = textStyle
' Export new Word document
doc.SaveAs("customizedGradientEffect.docx")