Sign in Join
Wiki copytemporary

BGRABitmap tutorial 12/es: what changed

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

OldNewLine
11Esta tutoría muestra como usar funciones de texto.
22
33### Crear un nuevo proyecto
44
55Crea un nuevo proyecto y añade referencia a [[BGRABitmap]], de la misma forma que en[[BGRABitmap tutorial/es|la primer tutoríal]].
66
77### Texto simple
88
99Puedes dibujar un texto simple como este :
1010
1111``` pascal
1212procedure TForm1.FormPaint(Sender: TObject);
1313var
1414 image: TBGRABitmap;
1515 c: TBGRAPixel;
1616begin
1717 image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
1818 c := ColorToBGRA(ColorToRGB(clBtnText)); //devuelve el color de texto predeterminado
1919
2020 image.FontHeight := 30;
2121 image.FontAntialias := true;
2222 image.FontStyle := [fsBold];
2323 image.TextOut(ClientWidth-5,5,'Hello world',c,);
2424 image.SetPixel(5,5,c);
2525
2626 image.Draw(Canvas,0,0,True);
2727 image.free;
2828end;
2929```
3030
3131Aquí el tamaño de la fuente está establecido a 30 píxeles, con antiafilado. Usar antiafilado de fuentes es mas lento pero es mas hermoso.
3232
3333La esquina superior izquierda del texto está en (5,5). Este origen es mostrado con SetPixel.
3434
35-<figure>
36-<img src="BGRATutorial12a.png" title="BGRATutorial12a.png" />
37-<figcaption>BGRATutorial12a.png</figcaption>
38-</figure>
35+![](/wiki-images/4/40/BGRATutorial12a.png)
3936
4037#### Usar alineamiento
4138
4239Simplemente reemplaza las lineas TextOut y SetPixel con :
4340
4441``` pascal
4542 image.TextOut(ClientWidth-5,5,'Hello world',c,taRightJustify);
4643 image.SetPixel(ClientWidth-5,5,c);
4744```
4845
4946Ahora el origen está en el lado derecho de la forma, y el texto está alineado a la derecha.
5047
51-<figure>
52-<img src="BGRATutorial12b.png" title="BGRATutorial12b.png" />
53-<figcaption>BGRATutorial12b.png</figcaption>
54-</figure>
48+![](/wiki-images/6/61/BGRATutorial12b.png)
5549
5650### Texto rotado
5751
5852Es también simple dibujar texto rotado. Para hacer esto usa TextOutAngle o determina la propiedad FontOrientation :
5953
6054``` pascal
6155 image.TextOutAngle(30,5,-450,'Hello world',c, taLeftJustify);
6256 image.SetPixel(30,5,c);
6357```
6458
6559El ángulo se expresa en décimas de grados y el valor positivo significa que va en sentido antihorario.
6660
67-<figure>
68-<img src="BGRATutorial12c.png" title="BGRATutorial12c.png" />
69-<figcaption>BGRATutorial12c.png</figcaption>
70-</figure>
61+![](/wiki-images/b/b5/BGRATutorial12c.png)
7162
7263Fíjate donde está el origen del texto (en el píxel agregado).
7364
7465### Texto ajustado
7566
7667Esta es una forma fácil para usar TextRect :
7768
7869``` pascal
7970 image.TextRect(rect(5,5,ClientWidth-5,ClientHeight-5),'This is a text that should be word wrapped',taCenter,tlCenter,c);
8071 image.Rectangle(rect(5,5,ClientWidth-5,ClientHeight-5),c,dmSet);
8172```
8273
8374Los parámetros son :
8475
8576- el rectángulo delimitador
8677- el texto
8778- alineación horizontal
8879- alineación vertical
8980- color
9081
91-<figure>
92-<img src="BGRATutorial12d.png" title="BGRATutorial12d.png" />
93-<figcaption>BGRATutorial12d.png</figcaption>
94-</figure>
82+![](/wiki-images/c/ce/BGRATutorial12d.png)
9583
9684### Texto con sombra
9785
9886Puedes hacer un texto sombreado con un efecto de desenfoque :
9987
10088``` pascal
10189var
10290 image,txt: TBGRABitmap;
10391 grad: TBGRAGradientScanner;
10492 c: TBGRAPixel;
10593begin
10694 image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
10795 c := ColorToBGRA(ColorToRGB(clBtnText));
10896
10997 txt := TextShadow(ClientWidth,ClientHeight,'Hello world',30,c,BGRABlack,5,5,5);
11098 image.PutImage(0,0,txt,dmDrawWithTransparency);
11199 txt.Free;
112100
113101 image.Draw(Canvas,0,0,True);
114102 image.free;
115103end;
116104```
117105
118106El procedimiento TextShadow crea un bitmap que contiene el texto con una sombra. Los parámetros son :
119107
120108- El tamaño del bitmap
121109- El texto
122110- Alto de la Fuente
123111- Color de la Fuente
124112- Color de la sombra
125113- Desplazamiento de la sombra y tamaño del desenfoque
126114
127115No olvides liberar el bitmap luego de utilizarlo.
128116
129-<figure>
130-<img src="BGRATutorial12e.png" title="BGRATutorial12e.png" />
131-<figcaption>BGRATutorial12e.png</figcaption>
132-</figure>
117+![](/wiki-images/b/b7/BGRATutorial12e.png)
133118
134119### Texto con gradiente
135120
136121Como otras funciones de dibujo, puedes proveer de un gradiente o textura para rellenar el texto con el. Aquí hay un ejemplo :
137122
138123``` pascal
139124uses BGRAGradientScanner;
140125
141126var
142127 image: TBGRABitmap;
143128 grad: TBGRAGradientScanner;
144129begin
145130 image := TBGRABitmap.Create(ClientWidth,ClientHeight, ColorToBGRA(ColorToRGB(clBtnFace)) );
146131
147132 grad := TBGRAGradientScanner.Create(BGRA(255,255,0),BGRA(255,0,0),gtLinear,PointF(0,0),PointF(0,35),True,True);
148133 image.FontHeight := 30;
149134 image.FontAntialias := true;
150135 image.FontStyle := [fsBold];
151136 image.TextOut(6,6,'Hello world',BGRABlack); //dibuja un borde negro
152137 image.TextOut(5,5,'Hello world',grad); //dibuja texto degradado
153138 grad.free;
154139
155140 image.Draw(Canvas,0,0,True);
156141 image.free;
157142end;
158143```
159144
160145Primero se crea un gradiente horizontal, con color amarillo y rojo. Este se usa como textura.
161146
162-<figure>
163-<img src="BGRATutorial12f.png" title="BGRATutorial12f.png" />
164-<figcaption>BGRATutorial12f.png</figcaption>
165-</figure>
147+![](/wiki-images/7/7e/BGRATutorial12f.png)
166148
167149[[BGRABitmap tutorial 11/es|Tutoría anterior (combinando transformaciones)]]
168150
169151---
170152*From the Free Pascal wiki, page "BGRABitmap tutorial 12/es", 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).*
171153Category: Castellano
172154Category: Español

Back to history