Autoit en español
Aplicaciones con Autoit - Juan Antonio Villalpando
-- Tutorial de iniciación a Autoit --
Volver al índice del tutorial
____________________________
22.- Deslizable. (Slider). Suma de colores RVA.
suma_colores.exe
- Esta aplicación se base en la que vimos en App Inventor 20mezclacolores.htm, se aconseja que veas ese tutorial
- Tenemos 3 Deslizadores (Slider) que pueden dar un número entre 0 y 255, según el Deslizador movido, una Etiqueta (Label) cambiará su color de fondo.
- El fondo la Etiqueta7 será la suma de los tres valores RVA.
---------------------------------------------------------------------------------------------------------------------------
- Koda.
__________________________
- Código completo.
suma_colores.au3 |
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Suma de colores - Juan A. Villalpando", 792, 425, 569, 159)
$Slider1 = GUICtrlCreateSlider(192, 56, 337, 49, BitOR($TBS_TOOLTIPS, $TBS_BOTH, $TBS_ENABLESELRANGE))
GUICtrlSetLimit(-1, 255, 0)
$Slider2 = GUICtrlCreateSlider(192, 136, 337, 49, BitOR($TBS_TOOLTIPS, $TBS_BOTH, $TBS_ENABLESELRANGE))
GUICtrlSetLimit(-1, 255, 0)
$Slider3 = GUICtrlCreateSlider(192, 208, 337, 49, BitOR($TBS_TOOLTIPS, $TBS_BOTH, $TBS_ENABLESELRANGE))
GUICtrlSetLimit(-1, 255, 0)
$Label1 = GUICtrlCreateLabel("Rojo: ", 24, 64, 119, 20)
$Label2 = GUICtrlCreateLabel("Verde: ", 24, 136, 119, 20)
$Label3 = GUICtrlCreateLabel("Azul: ", 24, 208, 119, 20)
$Label4 = GUICtrlCreateLabel("Label4", 600, 16, 141, 68)
$Label5 = GUICtrlCreateLabel("Label5", 600, 101, 141, 68)
$Label6 = GUICtrlCreateLabel("Label6", 600, 192, 141, 68)
$Label7 = GUICtrlCreateLabel("Label7", 208, 272, 317, 132)
GUISetState(@SW_SHOW)
; Juan A. Villalpando - KIO4.COM
#EndRegion ### END Koda GUI section ###
$rojo = 0
$verde = 0
$azul = 0
$r_v_a = 0
While 1
$msg = GuiGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
ExitLoop
Case Else
$rojo = GUICtrlRead($Slider1)
$verde = GUICtrlRead($Slider2)
$azul = GUICtrlRead($Slider3)
GUICtrlSetData($Label1, "Rojo: " & $rojo)
GUICtrlSetData($Label2, "Verde: " & $verde)
GUICtrlSetData($Label3, "Azul: " & $azul)
GUICtrlSetBkColor($Label4, $rojo * 256 * 256)
GUICtrlSetBkColor($Label5, $verde * 256)
GUICtrlSetBkColor($Label6, $azul)
$r_v_a = ($rojo * 256 * 256) + ($verde * 256) + ($azul)
GUICtrlSetBkColor($Label7, $r_v_a)
Sleep(40)
EndSelect
Wend
Exit
|
________________________________________________
- Comentarios.
- Observa que el cálculo está en Case Else
- Observa que las operaciones de senos, se realizan en radianes, hemos tenido que convertir de grados a radianes.
- Hay funciones para pasar de radianes a grados y viceversa:
_Radian _Degree
- Esto es para que salga el numerito sobre el Deslizador:
$Slider1 = GUICtrlCreateSlider(192, 56, 337, 49, BitOR($TBS_TOOLTIPS, $TBS_BOTH, $TBS_ENABLESELRANGE))
- Cuando ponemos un -1 se refiere al componente anterior:
GUICtrlSetLimit(-1, 255, 0)
- También se podría haber puesto:
GUICtrlSetLimit($Slider1, 255, 0)
_________________
- Propuesta.
-
|