Advertisement
LuizFelipe

Cor aleatória.

May 9th, 2015
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 0.84 KB | None | 0 0
  1. @echo off
  2. color 0F
  3. mode 35,10
  4. :i
  5. cls
  6. echo     **************************
  7. echo     *   Gerar cor aleatoria  *
  8. echo     **************************
  9. echo.
  10. echo.
  11. call :gerarC
  12. call :color "0%dC2%" "Texto de cor aleatoria..."
  13. echo.
  14. call :gerarC
  15. call :color "%corG%" "Texto e fundo de cor aleatoria."
  16. timeout 4 >nul
  17. goto i
  18.  
  19. :gerarC
  20. set dC1=%RANDOM:~-1%
  21. set dC2=%RANDOM:~-1%
  22. set t1=%RANDOM:~-3,1%
  23. set t2=%RANDOM:~-3,1%
  24. if /i %t1% GTR 5 (
  25.     if %t1%==4 set dC1=A
  26.     if %t1%==5 set dC1=B
  27.     if %t1%==6 set dC1=C
  28.     if %t1%==7 set dC1=D
  29.     if %t1%==8 set dC1=E
  30.     if %t1%==9 set dC1=F
  31. )
  32. if /i %t2% GTR 5 (
  33.     if %t2%==4 set dC2=A
  34.     if %t2%==5 set dC2=B
  35.     if %t2%==6 set dC2=C
  36.     if %t2%==7 set dC2=D
  37.     if %t2%==8 set dC2=E
  38.     if %t2%==9 set dC2=F
  39. )
  40. set corG=%dC1%%dC2%
  41. goto :EOF
  42.  
  43. :color
  44. echo   >"%~2F"
  45. findstr /a:%1 /R "^" "%~2F*"
  46. del %2F
  47.  
  48. goto :EOF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement