¿ Como harías para que la letra dentro de un DrawingArea ocupase todo el alto ?.
En este caso el ancho y el alto es el mismo y es par.No se si el problema es de alineación.
Sin rejilla.
Con rejilla.
Aquí tenéis el código:
Private caracter As Boolean
Private rejilla As Boolean
Public Sub _new()
End
Public Sub Form_Open()
Me.Center
Me.Title = "Letra"
End
Public Sub DibujaCaracter()
With Paint
.Brush = Paint.Color(Color.Blue)
.Font.Name = "Lucida"
.Font.Size = Pizarra.Width
.Text("A", 0, 0, Pizarra.Width, Pizarra.Height, Align.Center)
.Stroke 'Cambiar por .Fill y vereis el cambio
End With
End
Public Sub DibujaRejilla()
Dim tamcelda As Integer
Dim x As Integer
Dim y As Integer
tamcelda = Pizarra.Width / 16 'Ancho y alto son iguales
With Paint
.LineWidth = 1
.Brush = Paint.Color(Color.Black)
For y = 0 To Pizarra.Height Step tamcelda
.MoveTo(0, y)
.LineTo(Pizarra.Width, y)
Next
For x = 0 To Pizarra.Width Step tamcelda
.MoveTo(x, 0)
.LineTo(x, Pizarra.Height)
Next
.Stroke
End With
End
Public Sub Pizarra_Draw()
Paint.Reset
If caracter Then DibujaCaracter
If rejilla Then DibujaRejilla
End
Public Sub btnDibujar_Click()
caracter = Not caracter
Pizarra.Refresh
End
Public Sub btnDibujaRejilla_Click()
rejilla = Not rejilla
Pizarra.Refresh
End
Private rejilla As Boolean
Public Sub _new()
End
Public Sub Form_Open()
Me.Center
Me.Title = "Letra"
End
Public Sub DibujaCaracter()
With Paint
.Brush = Paint.Color(Color.Blue)
.Font.Name = "Lucida"
.Font.Size = Pizarra.Width
.Text("A", 0, 0, Pizarra.Width, Pizarra.Height, Align.Center)
.Stroke 'Cambiar por .Fill y vereis el cambio
End With
End
Public Sub DibujaRejilla()
Dim tamcelda As Integer
Dim x As Integer
Dim y As Integer
tamcelda = Pizarra.Width / 16 'Ancho y alto son iguales
With Paint
.LineWidth = 1
.Brush = Paint.Color(Color.Black)
For y = 0 To Pizarra.Height Step tamcelda
.MoveTo(0, y)
.LineTo(Pizarra.Width, y)
Next
For x = 0 To Pizarra.Width Step tamcelda
.MoveTo(x, 0)
.LineTo(x, Pizarra.Height)
Next
.Stroke
End With
End
Public Sub Pizarra_Draw()
Paint.Reset
If caracter Then DibujaCaracter
If rejilla Then DibujaRejilla
End
Public Sub btnDibujar_Click()
caracter = Not caracter
Pizarra.Refresh
End
Public Sub btnDibujaRejilla_Click()
rejilla = Not rejilla
Pizarra.Refresh
End
Y aquí el ejemplo para bajar. Se supone que donde dibuja la letra lo hace dentro de un recuadro.
http://gambasdoc.org/help/comp/gb.qt4/paint/text?v3
Aunque es de qt, estoy usando gtk. Cambia mucho de uno a otro luego.
Saludos
DibujandoLetra.tar.gz | ||
Descripción: | Descargar |
|
Nombre del archivo: | DibujandoLetra.tar.gz | |
Tamaño: | 6.07 KB | |
Descargado: | 27 veces |
DibujandoLetra.tar.gz | ||
Descripción: | Descargar |
|
Nombre del archivo: | DibujandoLetra.tar.gz | |
Tamaño: | 6.07 KB | |
Descargado: | 27 veces |
DibujandoLetra.tar.gz | ||
Descripción: | Descargar |
|
Nombre del archivo: | DibujandoLetra.tar.gz | |
Tamaño: | 6.07 KB | |
Descargado: | 27 veces |