Batch file Mixing multiple colors

帅比萌擦擦* 提交于 2019-12-13 09:24:20

问题


I've been wondering if someone have made a batch file utility that can mix 2 batch colors into another color (for example: Red + Yellow to make Orange). I don't really know if its even possible or not to do such a thing, but if there is, I want to know.


回答1:


Well, if with "batch colors" you refer to color values of color command, then it is very easy to get some equivalences based on the original color table shown by color /? command:

0 = Black       8 = Gray
1 = Blue        9 = Light blue
2 = Green       A = Light green
3 = Aqua        B = Light aqua
4 = Red         C = Light red
5 = Magenta     D = Light magenta
6 = Brown       E = Yellow
7 = White       F = Bright white

(perhaps color names are not the same of color /? command, I am translating they from my Spanish Windows)

This way, we may see that Red+Yellow (4+E = 12 mod F = 2) gives Green!

@echo off
setlocal EnableDelayedExpansion
set hexa=0123456789ABCDEF
set /P "first=Enter first color (hexa digit): "
set /P "second=Enter second color (hexa digit): "
set /A sum= (0x%first% + 0x%second%) %% 16
set result=!hexa:~%sum%,1!
color %result%
echo The result is: %result%


来源:https://stackoverflow.com/questions/20534240/batch-file-mixing-multiple-colors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!