Comment ajouter un effet de lueur au texte en C#

How to Add Glow Effect to Text

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

The glow effect on text is a visual effect that creates a glowing aura around the characters. This effect makes the text appear as if it is emitting light, creating a soft, luminous outline that can enhance readability and draw attention.

Quickstart: Apply Glow Effect to a Text Element Fast

Just instantiate a Glow object, set its radius and color, embed it in a TextEffect, and assign it to your text’s style. In one short line you’ll see glowing text in your Word document.

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.

    someTextElement.Style.TextEffect = new IronWord.Models.TextEffect { GlowEffect = new IronWord.Models.Glow { GlowRadius = 8, GlowColor = System.Drawing.Color.FromArgb(180, 0, 128, 255) } };
  3. Deploy to test on your live environment

    Start using IronWord in your project today with a free trial
    arrow pointer

Get Started with IronWord

Commencez à utiliser IronWord dans votre projet aujourd'hui avec un essai gratuit.

Première étape :
green arrow pointer

Add Glow Effect

To specify the glow effect for the text, you can start by creating and configuring the Glow object. Then, create the TextEffect object from this Glow object. Finally, assign the TextEffect to the TextEffect property of the text.

using IronWord; // Import the necessary library

public class TextGlowEffectExample
{
    public void ApplyGlowEffect()
    {
        // Initialize a new Glow object
        Glow glow = new Glow();

        // Set the properties for the glow effect
        glow.GlowRadius = 5; // Radius of the glow effect
        glow.GlowColor = System.Drawing.Color.FromArgb(128, 255, 0, 0); // ARGB value for the glow color

        // Create a TextEffect object and assign the glow effect to it
        TextEffect textEffect = new TextEffect();
        textEffect.Glow = glow;

        // Apply the TextEffect to the text
        // Example: someTextElement.TextEffect = textEffect;

        // Further code to export or display the document would go here
    }
}
using IronWord; // Import the necessary library

public class TextGlowEffectExample
{
    public void ApplyGlowEffect()
    {
        // Initialize a new Glow object
        Glow glow = new Glow();

        // Set the properties for the glow effect
        glow.GlowRadius = 5; // Radius of the glow effect
        glow.GlowColor = System.Drawing.Color.FromArgb(128, 255, 0, 0); // ARGB value for the glow color

        // Create a TextEffect object and assign the glow effect to it
        TextEffect textEffect = new TextEffect();
        textEffect.Glow = glow;

        // Apply the TextEffect to the text
        // Example: someTextElement.TextEffect = textEffect;

        // Further code to export or display the document would go here
    }
}
Imports IronWord ' Import the necessary library

Public Class TextGlowEffectExample
	Public Sub ApplyGlowEffect()
		' Initialize a new Glow object
		Dim glow As New Glow()

		' Set the properties for the glow effect
		glow.GlowRadius = 5 ' Radius of the glow effect
		glow.GlowColor = System.Drawing.Color.FromArgb(128, 255, 0, 0) ' ARGB value for the glow color

		' Create a TextEffect object and assign the glow effect to it
		Dim textEffect As New TextEffect()
		textEffect.Glow = glow

		' Apply the TextEffect to the text
		' Example: someTextElement.TextEffect = textEffect;

		' Further code to export or display the document would go here
	End Sub
End Class
$vbLabelText   $csharpLabel
Add glow effect

Glow Effect Properties

Below are all the glow effect properties and their descriptions:

  • GlowRadius: Gets or sets the radius of the glow effect. The glow radius is specified in points (1/72 inch).
  • GlowColor: Gets or sets the color of the glow effect.

Glow Effect Examples

Let's look at some more glow effect examples. The color of the glow effect can also accept ARGB values. The first value is alpha, which describes how opaque the color is.

Glow effect examples

Questions Fréquemment Posées

Comment puis-je ajouter un effet de lueur au texte dans un document Word ?

Pour ajouter un effet de lueur au texte dans un document Word, utilisez une bibliothèque C# conçue à cet effet. Initialisez un objet Glow, configurez ses propriétés telles que GlowRadius et GlowColor, puis attribuez-le à un objet TextEffect. Enfin, appliquez ce TextEffect à votre texte et exportez le document.

Quel code est nécessaire pour appliquer un effet de lueur au texte en utilisant C# ?

Vous pouvez appliquer un effet de lueur en important la bibliothèque nécessaire et en créant un objet Glow avec les propriétés souhaitées. Attribuez-le ensuite à un objet TextEffect et appliquez-le à votre texte.

Quelles sont les propriétés clés de l'effet de lueur dans l'édition de texte ?

Les propriétés clés de l'effet de lueur sont GlowRadius, qui définit le rayon de la lueur en points, et GlowColor, qui définit la couleur de la lueur. Ces propriétés peuvent être configurées pour personnaliser l'apparence de l'effet de lueur.

La couleur de la lueur peut-elle être personnalisée en utilisant les valeurs ARGB ?

Oui, la couleur de la lueur peut être personnalisée en utilisant les valeurs ARGB. La valeur alpha dans ARGB détermine l'opacité de la lueur, permettant une large gamme de personnalisation des couleurs.

Comment puis-je exporter un document Word après avoir appliqué un effet de lueur ?

Après avoir appliqué l'effet de lueur en utilisant la bibliothèque C#, exportez le document Word édité en appelant les méthodes appropriées fournies par la bibliothèque pour enregistrer ou afficher le document en tant que nouveau fichier.

Est-il possible d'appliquer un effet de lueur à la fois sur le texte nouveau et existant ?

Oui, vous pouvez appliquer l'effet de lueur à la fois sur le texte nouvellement créé et existant dans un document Word. Cette flexibilité permet d'améliorer tout élément de texte dans votre document.

Quel est l'objectif de la propriété GlowRadius ?

La propriété GlowRadius spécifie le rayon de l'effet de lueur en points, aidant à déterminer jusqu'où la lueur s'étend à partir du texte. Le rayon est défini en points, où 1 point équivaut à 1/72 de pouce.

Quelles étapes sont nécessaires pour configurer un effet de lueur en C# ?

Pour configurer un effet de lueur en C#, initialisez un objet Glow, définissez ses propriétés GlowRadius et GlowColor, et attribuez-le à un objet TextEffect. Appliquez le TextEffect à votre texte et exportez le document pour voir les changements.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Nuget Téléchargements 25,807 | Version : 2025.11 vient de sortir