|     Inicio    |   |         |  |   FOROS      |  |      |      
   Elastix - VoIP B4A (Basic4Android) App inventor 2 PHP - MySQL
  Estación meteorológica B4J (Basic4Java) ADB Shell - Android Arduino
  Raspberry Pi Visual Basic Script (VBS) FireBase (BD autoactualizable) NodeMCU como Arduino
  AutoIt (Programación) Visual Basic Cosas de Windows Webs interesantes
Translate:
Búsqueda en este sitio:


.

Autoit en español
Aplicaciones con Autoit - Juan Antonio Villalpando

-- Tutorial de iniciación a Autoit --

Volver al índice del tutorial

____________________________

55.- GUICtrlCreateGraphic. GUICtrlSetGraphic. Gráfico en pantalla.

- https://www.autoitscript.com/autoit3/docs/functions/GUICtrlCreate%20Management.htm

- https://www.autoitscript.com/autoit3/docs/functions/GUICtrlSetGraphic.htm

- Para dibujar gráficos de líneas, círculos, puntos, tarta,... se ha de crear una zona gráfica. (GUICtrlCreateGraphic).

- PIE significa tarta, es una circunferencia de área incompleta. Se utiliza en estadísticas.

- GUICtrlSetGraphic($zona_grafica, $GUI_GR_COLOR, 0x0000ff, 0x0000ff) el primer color es el de la arista, el segundo el de relleno.

- El tamaño del trazo (PENSIZE) se ha de poner ANTES de establecer el color.
GUICtrlSetGraphic($zona_grafica, $GUI_GR_PENSIZE, 4)
GUICtrlSetGraphic($zona_grafica, $GUI_GR_COLOR, 0x0000ff,0x0000ff)
GUICtrlSetGraphic($zona_grafica, $GUI_GR_DOT, 200, 100)

- Para comenzar a dibujar una línea en cierto punto, el punto inicial lo conseguimos mediante $GUI_GR_MOVE

- Círculo rojo:            GUICtrlSetGraphic($zona_grafica, $GUI_GR_ELLIPSE, 190, 450, 40, 40)

_______________________________________________
1.- Creación de una zona gráfica. Dibujos.

Gráficos en la pantalla.
				   
#include <ColorConstants.au3>
#include <GUIConstantsEx.au3>
     ; Juan A. Villalpando - KIO4.COM


    $Formulario = GUICreate("Gráficos", 600, 600)
    $zona_grafica = GUICtrlCreateGraphic(30, 70, 400, 400)
    GUICtrlSetBkColor($zona_grafica, $COLOR_YELLOW) ; Fondo amarillo.

    GUICtrlSetGraphic($zona_grafica, $GUI_GR_COLOR, 0xff0000, 0xff0000)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_PIE, 50, 50, 40, 30, 270) ; Tarta roja

    GUICtrlSetGraphic($zona_grafica, $GUI_GR_COLOR, 0x009900, 0x009900)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_PIE, 70, 150, 40, -60, 90) ; Tarta verde

    GUICtrlSetGraphic($zona_grafica, $GUI_GR_PENSIZE, 12)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_COLOR, 0x0000ff,0x0000ff)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_MOVE, 300, 300)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_LINE, 450, 450) ; Línea azul


    GUICtrlSetGraphic($zona_grafica, $GUI_GR_PENSIZE, 4)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_COLOR, 0x0000ff,0x0000ff)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_DOT, 200, 100) ; Punto azul

    GUICtrlSetGraphic($zona_grafica, $GUI_GR_PENSIZE, 6)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_COLOR, 0xff0000,0xff0000)
    GUICtrlSetGraphic($zona_grafica, $GUI_GR_ELLIPSE, 190, 450, 40, 40) ; Círculo rojo final


    Local $Etiqueta = GUICtrlCreateLabel("Texto sobre fondo rojo", 10, 10, 185, 17)
    Local $Boton1 = GUICtrlCreateButton("Cerrar el Formulario", 50, 500, 180, 40)

    ; Poner la Etiqueta con fondo ROJO y letras BLANCAS
    GUICtrlSetBkColor($Etiqueta, $COLOR_RED)
    GUICtrlSetColor($Etiqueta, $COLOR_WHITE)

    ; Muestra el Formulario
    GUISetState(@SW_SHOW, $Formulario)

    ; Bucle hasta que el usuario pulse el Boton1 para Salir.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $Boton1
                ExitLoop

        EndSwitch
    WEnd

    GUIDelete($Formulario) ; Borra el Formulario.

_______________________________________________
2.- Creación de una zona gráfica. Dibujos. Ejemplo de la documentación.

- Código de https://www.autoitscript.fr/autoit3/docs/functions/GUICtrlSetGraphic.htm

Gráficos en la pantalla.
				   
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

Global Const $g_MAXGr = 6
Global $g_aidGraphics[$g_MAXGr + 1] ; 0 et les entrées $g_MAXGr ne sont pas utilisés pour permettre GUICtrlDelete
Global $g_idDel, $g_hChild

Example()

Func Example()
    Local $idMsg, $iInc, $i

    GUICreate("My Main", -1, -1, 100, 100)
    Local $idDel1 = GUICtrlCreateButton("ReCreate", 50, 200, 50)
    GUISetState(@SW_SHOW)
    CreateChild()

    $i = 1
    $iInc = 1
    ;$i = 5 ; décommenter pour supprimer le démarrage à partir du dernier contrôle graphique défini
    ;$iInc = -1

    Do
        $idMsg = GUIGetMsg()
        If $idMsg = $idDel1 Then $i = Create($iInc)

        If $idMsg = $g_idDel Then
            GUICtrlDelete($g_aidGraphics[$i])
            $i = $i + $iInc
            If $i < 0 Or $i > $g_MAXGr Then Exit
        EndIf
    Until $idMsg = $GUI_EVENT_CLOSE
EndFunc   ;==> Example

Func Create($iInc)
    GUIDelete($g_hChild)
    CreateChild()
    If $iInc = -1 Then Return 5
    Return 1
EndFunc   ;== > Del

Func CreateChild()
    $g_hChild = GUICreate("My Draw")
    $g_idDel = GUICtrlCreateButton("Delete", 50, 165, 50)

    $g_aidGraphics[1] = GUICtrlCreateGraphic(20, 50, 100, 100)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetColor(-1, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)

    GUICtrlSetGraphic(-1, $GUI_GR_ELLIPSE, 100, 100, 50, 80)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xc0c0ff)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 350, 200, 50, 80)
    GUICtrlCreateLabel("label", 65, 100, 30)
    GUICtrlSetColor(-1, 0xff)

    $g_aidGraphics[2] = GUICtrlCreateGraphic(220, 10, 100, 100)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 50, 50, 40, 30, 270)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x00ff00, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_PIE, 58, 50, 40, -60, 90)

    $g_aidGraphics[3] = GUICtrlCreateGraphic(220, 110, 100, 100)
    GUICtrlSetBkColor(-1, 0xf08080)
    GUICtrlSetColor(-1, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_HINT, 1)

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
    GUICtrlSetGraphic(-1, $GUI_GR_RECT, 50, 50, 80, 80)

    $g_aidGraphics[4] = GUICtrlCreateGraphic(20, 200, 80, 80)
    GUICtrlSetBkColor(-1, 0xffffff)
    GUICtrlSetGraphic(-1, $GUI_GR_HINT, 1)

    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 10, 10)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 30, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff00)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 70, 70)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 50)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xffff00)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 10, 10)

    $g_aidGraphics[5] = GUICtrlCreateGraphic(150, 10, 50, 50)
    GUICtrlSetBkColor(-1, 0xa0ffa0)
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 20, 20) ;le point de départ
    ; il est préférable de tracer la ligne et après le point
    ; pour éviter de basculer la couleur à chaque dessin
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0x0000ff)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 30, 30)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 20, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0xff0000)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 25, 25)
    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 40, 40)
    GUICtrlSetGraphic(-1, $GUI_GR_DOT, 30, 40)

    $g_aidGraphics[6] = GUICtrlCreateGraphic(110, 260, 230, 130)
    GUICtrlSetColor(-1, 0) ; affiche une ligne de bordure noire
    GUICtrlSetBkColor(-1, 0xc0c0ff)
    GUICtrlSetGraphic(-1, $GUI_GR_HINT, 3) ; affiche les lignes du contrôle et les points d'extrémité

    GUICtrlSetGraphic(-1, $GUI_GR_COLOR, 0, 0xff); remplir en bleu
    GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 120, 20) ; le point de départ
    GUICtrlSetGraphic(-1, $GUI_GR_BEZIER, 120, 100, 200, 20, 200, 100)
    GUICtrlSetGraphic(-1, $GUI_GR_BEZIER + $GUI_GR_CLOSE, 100, 40, 40, 100, 40, 20)
    GUICtrlSetGraphic(-1, $GUI_GR_LINE, 60, 30) ;le point de départ

    GUISetState(@SW_SHOW)
EndFunc   ;== > CreateChild

_______________________________________________
- Números en forma de pantalla LCD.

https://www.autoitscript.com/forum/topic/122439-guictrllcdnumber/

_________________

- Mi correo:
juana1991@yahoo.com
- KIO4.COM - Política de cookies. Textos e imágenes propiedad del autor:
© Juan A. Villalpando
No se permite la copia de información ni imágenes.
Usamos cookies propias y de terceros que entre otras cosas recogen datos sobre sus hábitos de navegación y realizan análisis de uso de nuestro sitio.
Si continúa navegando consideramos que acepta su uso. Acepto    Más información