テキストにグラデーション効果を追加する方法

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(ジャバPDF JAR)

ダウンロード DLL (ディーエルエル)

DLLをダウンロード

プロジェクトに手動でインストールする

今日からプロジェクトでIronPDFを使い始めましょう。無料のトライアルをお試しください。

最初のステップ:
green arrow pointer

チェックアウト IronWord オン Nuget 迅速なインストールと展開のために。8百万以上のダウンロード数により、をC#で変革しています。

 用 C# NuGet ライブラリ nuget.org/packages/IronWord/
Install-Package IronWord

グラデーション効果の追加

テキストのグラデーション効果を指定するには、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")
VB   C#
グラデーション効果の追加

グラデーション効果のプロパティ

グラデーション・エフェクトは、多様なデザイン要件を満たすために調整可能な属性を提供します。 各物件の詳細については、以下のリストを参照のこと:

**グラデーションストップ

  • 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")
VB   C#
カスタマイズされたグラデーション効果