Sign in Join
Wiki copytemporary

BGRABitmap tutorial 12/fr: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
1-[[BGRABitmap tutorial/fr|**Accueil**]] | [[BGRABitmap tutorial 1/fr|**Tutoriel 1**]] | [[BGRABitmap tutorial 2/fr|**Tutoriel 2**]] | [[BGRABitmap tutorial 3/fr|**Tutoriel 3**]] | [[BGRABitmap tutorial 4/fr|**Tutoriel 4**]] | [[BGRABitmap tutorial 5/fr|**Tutoriel 5**]] | [[BGRABitmap tutorial 6/fr|**Tutoriel 6**]] | [[BGRABitmap tutorial 7/fr|**Tutoriel 7**]] | [[BGRABitmap tutorial 8/fr|**Tutoriel 8**]] | [[BGRABitmap tutorial 9/fr|**Tutoriel 9**]] | [[BGRABitmap tutorial 10/fr|**Tutoriel 10**]] | [[BGRABitmap tutorial 11/fr|**Tutoriel 11**]] | **Tutoriel 12** | [Edit](<http://wiki.lazarus.freepascal.org/index.php?title=Template:BGRABitmap_tutorial_index/fr&action=edit>)
1+Ce tutoriel montre comment utiliser les fonctions texte par défaut. Pour les fonctions avancées, voir les [[BGRABitmap tutorial Font rendering/fr|moteurs de rendu]].
22
3-Ce tutoriel montre comment utiliser les fonctions texte par défaut. Pour les fonctions avancées, voir les [[BGRABitmap tutorial Font rendering/fr|moteurs de rendu]].
3+### Texte simple
44
5-## Contents
5+Vous pouvez dessiner un texte simple comme cela :
66
7- * 1 Texte simple
8- * 1.1 Utiliser l'alignement
9- * 2 Rotation de texte
10- * 3 Texte avec retour à la ligne
11- * 4 Texte avec une ombre
12- * 5 Texte avec dégradé
7+``` pascal
8+procedure TForm1.FormPaint(Sender: TObject);
9+var
10+ image: TBGRABitmap;
11+ c: TBGRAPixel;
12+begin
13+ image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
14+ c := ColorToBGRA(ColorToRGB(clBtnText)); //retrieve default text color
1315
14-### Texte simple
16+ image.FontHeight := 30;
17+ image.FontAntialias := true;
18+ image.FontStyle := [fsBold];
19+ image.TextOut(ClientWidth-5,5,'Hello world',c,);
20+ image.SetPixel(5,5,c);
1521
16-Vous pouvez dessiner un texte simple comme cela :
17-```
18-procedure TForm1.FormPaint(Sender: TObject);
19- var
20- image: TBGRABitmap;
21- c: TBGRAPixel;
22- begin
23- image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
24- c := ColorToBGRA(ColorToRGB(clBtnText)); //retrieve default text color
25-
26- image.FontHeight := 30;
27- image.FontAntialias := true;
28- image.FontStyle := [fsBold];
29- image.TextOut(ClientWidth-5,5,'Hello world',c,);
30- image.SetPixel(5,5,c);
31-
32- image.Draw(Canvas,0,0,True);
33- image.free;
34- end;
22+ image.Draw(Canvas,0,0,True);
23+ image.free;
24+end;
3525```
3626
37-Ici, la taille de police est de 30 pixels, avec anticrénelage. Utiliser l'anticrénelage pour le texte est plus lent mais plus joli.
27+Ici, la taille de police est de 30 pixels, avec anticrénelage. Utiliser l'anticrénelage pour le texte est plus lent mais plus joli.
3828
39-Le coin en haut à gauche du texte est aux coordonnées (5,5). Cette origine est montrée avec un _SetPixel_.
29+Le coin en haut à gauche du texte est aux coordonnées (5,5). Cette origine est montrée avec un *SetPixel*.
4030
41-[![BGRATutorial12a.png](/wiki-images/4/40/BGRATutorial12a.png)](</File:BGRATutorial12a.png>)
31+![](/wiki-images/4/40/BGRATutorial12a.png)
4232
4333#### Utiliser l'alignement
4434
45-Remplacez les _TextOut_ et _SetPixel_ par :
46-```
47-image.TextOut(ClientWidth-5,5,'Hello world',c,taRightJustify);
48- image.SetPixel(ClientWidth-5,5,c);
35+Remplacez les *TextOut* et *SetPixel* par :
36+
37+``` pascal
38+ image.TextOut(ClientWidth-5,5,'Hello world',c,taRightJustify);
39+ image.SetPixel(ClientWidth-5,5,c);
4940```
5041
51-Maintenant, l'origine est sur le côté droit de la fenêtre, et le texte est aligné sur la droite.
42+Maintenant, l'origine est sur le côté droit de la fenêtre, et le texte est aligné sur la droite.
5243
53-[![BGRATutorial12b.png](/wiki-images/6/61/BGRATutorial12b.png)](</File:BGRATutorial12b.png>)
44+![](/wiki-images/6/61/BGRATutorial12b.png)
5445
5546### Rotation de texte
5647
57-Il est aussi facile de dessiner du texte en rotation. Pour cela, utilisez _TextOutAngle_ ou bien la propriété _FontOrientation_ :
58-```
59-image.TextOutAngle(30,5,-450,'Hello world',c, taLeftJustify);
60- image.SetPixel(30,5,c);
48+Il est aussi facile de dessiner du texte en rotation. Pour cela, utilisez *TextOutAngle* ou bien la propriété *FontOrientation* :
49+
50+``` pascal
51+ image.TextOutAngle(30,5,-450,'Hello world',c, taLeftJustify);
52+ image.SetPixel(30,5,c);
6153```
6254
63-L'angle est en dixièmes de degrés et les valeurs positives sont dans le sens inverse des aiguilles d'une montre. Ceci est une convention pour être compatible avec la propriété _Orientation_ de l'objet _Font_ du canevas standard.
55+L'angle est en dixièmes de degrés et les valeurs positives sont dans le sens inverse des aiguilles d'une montre. Ceci est une convention pour être compatible avec la propriété *Orientation* de l'objet *Font* du canevas standard.
6456
65-[![BGRATutorial12c.png](/wiki-images/b/b5/BGRATutorial12c.png)](</File:BGRATutorial12c.png>)
57+![](/wiki-images/b/b5/BGRATutorial12c.png)
6658
67-Remarquez à présent où est l'origine du texte (le pixel ajouté).
59+Remarquez à présent où est l'origine du texte (le pixel ajouté).
6860
6961### Texte avec retour à la ligne
7062
71-Il y a une version facile à utiliser de _TextRect_ :
72-```
73-image.TextRect(rect(5,5,ClientWidth-5,ClientHeight-5),'This is a text that should be word wrapped',taCenter,tlCenter,c);
74- image.Rectangle(rect(5,5,ClientWidth-5,ClientHeight-5),c,dmSet);
63+Il y a une version facile à utiliser de *TextRect* :
64+
65+``` pascal
66+ image.TextRect(rect(5,5,ClientWidth-5,ClientHeight-5),'This is a text that should be word wrapped',taCenter,tlCenter,c);
67+ image.Rectangle(rect(5,5,ClientWidth-5,ClientHeight-5),c,dmSet);
7568```
7669
77-Les paramètres sont :
70+Les paramètres sont :
7871
79- * le rectangle englobant (il y a un clipping) ;
80- * le texte ;
81- * l'alignement horizontal ;
82- * l'alignement vertical ;
83- * la couleur.
72+- le rectangle englobant (il y a un clipping) ;
73+- le texte ;
74+- l'alignement horizontal ;
75+- l'alignement vertical ;
76+- la couleur.
8477
85-[![BGRATutorial12d.png](/wiki-images/c/ce/BGRATutorial12d.png)](</File:BGRATutorial12d.png>)
78+![](/wiki-images/c/ce/BGRATutorial12d.png)
8679
8780### Texte avec une ombre
8881
89-Vous pouvez dessiner un texte avec une ombre floue avec _TextShadow_ de l'unité _BGRAGradients_ :
90-```
82+Vous pouvez dessiner un texte avec une ombre floue avec *TextShadow* de l'unité *BGRAGradients* :
83+
84+``` pascal
9185var
92- image,txt: TBGRABitmap;
93- grad: TBGRAGradientScanner;
94- c: TBGRAPixel;
95- begin
96- image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
97- c := ColorToBGRA(ColorToRGB(clBtnText));
98-
99- txt := TextShadow(ClientWidth,ClientHeight,'Hello world',30,c,BGRABlack,5,5,5);
100- image.PutImage(0,0,txt,dmDrawWithTransparency);
101- txt.Free;
102-
103- image.Draw(Canvas,0,0,True);
104- image.free;
105- end;
86+ image,txt: TBGRABitmap;
87+ grad: TBGRAGradientScanner;
88+ c: TBGRAPixel;
89+begin
90+ image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
91+ c := ColorToBGRA(ColorToRGB(clBtnText));
92+
93+ txt := TextShadow(ClientWidth,ClientHeight,'Hello world',30,c,BGRABlack,5,5,5);
94+ image.PutImage(0,0,txt,dmDrawWithTransparency);
95+ txt.Free;
96+
97+ image.Draw(Canvas,0,0,True);
98+ image.free;
99+end;
106100```
107101
108-La procédure _TextShadow_ crée une image qui contient le texte avec une ombre. Les paramètres sont :
102+La procédure *TextShadow* crée une image qui contient le texte avec une ombre. Les paramètres sont :
109103
110- * la taille de l'image ;
111- * le texte ;
112- * la hauteur de la police ;
113- * la couleur ;
114- * la couleur de l'ombre ;
115- * le décalage et le rayon de flou de l'ombre.
104+- la taille de l'image ;
105+- le texte ;
106+- la hauteur de la police ;
107+- la couleur ;
108+- la couleur de l'ombre ;
109+- le décalage et le rayon de flou de l'ombre.
116110
117-N'oubliez pas de libérer l'image après utilisation.
111+N'oubliez pas de libérer l'image après utilisation.
118112
119-[![BGRATutorial12e.png](/wiki-images/b/b7/BGRATutorial12e.png)](</File:BGRATutorial12e.png>)
113+![](/wiki-images/b/b7/BGRATutorial12e.png)
120114
121115### Texte avec dégradé
122116
123-Comme les autres fonctions, vous pouvez passer en paramètre un dégradé ou une texture pour remplir le texte. Voici un exemple :
124-```
117+Comme les autres fonctions, vous pouvez passer en paramètre un dégradé ou une texture pour remplir le texte. Voici un exemple :
118+
119+``` pascal
125120uses BGRAGradientScanner;
126-
127- var
128- image: TBGRABitmap;
129- grad: TBGRAGradientScanner;
130- begin
131- image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
132-
133- grad := TBGRAGradientScanner.Create(BGRA(255,255,0),BGRA(255,0,0),gtLinear,PointF(0,0),PointF(0,35),True,True);
134- image.FontHeight := 30;
135- image.FontAntialias := true;
136- image.FontStyle := [fsBold];
137- image.TextOut(6,6,'Hello world',BGRABlack); //draw a black border
138- image.TextOut(5,5,'Hello world',grad); //draw gradient text
139- grad.free;
140-
141- image.Draw(Canvas,0,0,True);
142- image.free;
143- end;
121+
122+var
123+ image: TBGRABitmap;
124+ grad: TBGRAGradientScanner;
125+begin
126+ image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
127+
128+ grad := TBGRAGradientScanner.Create(BGRA(255,255,0),BGRA(255,0,0),gtLinear,PointF(0,0),PointF(0,35),True,True);
129+ image.FontHeight := 30;
130+ image.FontAntialias := true;
131+ image.FontStyle := [fsBold];
132+ image.TextOut(6,6,'Hello world',BGRABlack); //draw a black border
133+ image.TextOut(5,5,'Hello world',grad); //draw gradient text
134+ grad.free;
135+
136+ image.Draw(Canvas,0,0,True);
137+ image.free;
138+end;
144139```
145140
146-En premier lieu, un dégradé sinusoïdal horizontal est créé, de couleurs jaune et rouge. Il est ensuite utilisé comme texture.
141+En premier lieu, un dégradé sinusoïdal horizontal est créé, de couleurs jaune et rouge. Il est ensuite utilisé comme texture.
147142
148-[![BGRATutorial12f.png](/wiki-images/7/7e/BGRATutorial12f.png)](</File:BGRATutorial12f.png>)
143+![](/wiki-images/7/7e/BGRATutorial12f.png)
149144
150145[[BGRABitmap tutorial 11/fr|Tutoriel précédent (combiner les transformations)]]
151146
152147---
153-*From the Free Pascal wiki, page "BGRABitmap tutorial 12/fr", as the Internet Archive kept it on 2025-03-20. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
148+*From the Free Pascal wiki, page "BGRABitmap tutorial 12/fr", as it stood on 2020-02-09 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history