Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Get the fourth hex value
Message
De
10/10/2012 09:56:17
 
 
À
10/10/2012 09:06:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01554642
Message ID:
01554646
Vues:
59
This message has been marked as a message which has helped to the initial question of the thread.
>>What is the relationship between the first pair and the second ? or in the above example, what is a correct second value for the second pair ?
>
>The goal here is to obtain the same degree of difference between both pairs. I do not have the correct value of the second pair. The first pair is a shade of green. The second pair is a shade of blue. From the first blue color, I would like to obtain the exact same degree of difference by calculating the second value. This is to offer themes to a Web site. By default, I would like to propose a set of colors when the main color is being changed. Then, this should do. However, the user still has the chance of adjusting the rest manually if needed. But, at first, this should do for most of the themes we are creating.


> >The goal here is to obtain the same degree of difference between both pairs


I'm not a graphics designer, just an attempt


Maybe by splitting each color into red, green and blue
Let's call the first value of the first pair  pair1X
Let's call the second value of the first pair  pair1Y

Let's call the first value of the second pair  pair2X
Let's call the second value of the second pair  pair2Y

So, we have
(pair1X, pair1Y) and (pair2X, pair2Y)

known values are pair1X, pair1Y, and pair2X


if we take the difference in red between pair1X and pair1Y, add that to red of pair2X, and mod 256 ?
same for green and blue
and then make pair2Y by rgb( red, green, blue ) from the above
function do_it()


	local pair1X, pair1Y, pair2X, pair2Y
	
	pair1X = 0x185A39
	pair1Y = 0xA5BDB5
	
	pair2X = 0x31ABE1
	
	= GetPair2Y(@m.pair2Y, m.pair2X, m.pair1X, m.pair1Y)
	?transf(pair2Y, '@0')
	
endfunc
*_______________________________________________________________________________
function GetPair2Y(pair2Y, pair2X, pair1X, pair1Y)
	
	local pair1Xred, pair1Xgreen, pair1Xblue
	local pair1Yred, pair1Ygreen, pair1Yblue
	
	local pair2Xred, pair2Xgreen, pair2Xblue
	local pair2Yred, pair2Ygreen, pair2Yblue
	
	=FromRgb(m.pair1X, @m.pair1Xred, @m.pair1Xgreen, @m.pair1Xblue)
	=FromRgb(m.pair1Y, @m.pair1Yred, @m.pair1Ygreen, @m.pair1Yblue)
	
	=FromRgb(m.pair2X, @m.pair2Xred, @m.pair2Xgreen, @m.pair2Xblue)
	
	pair2Yred = mod(m.pair2Xred + (pair1Xred - pair1Yred), 256)
	pair2Ygreen = mod(m.pair2Xgreen + (pair1Xgreen - pair1Ygreen), 256)
	pair2Yblue = mod(m.pair2Xblue + (pair1Xblue - pair1Yblue), 256)
	
	pair2Y = rgb(pair2Xred, pair2Ygreen , pair2Yblue )

endfunc
*_______________________________________________________________________________
function FromRgb(value, red, green, blue)

	red = bitand(m.value, 0xff)
	green = bitand(bitrShift(m.value, 8), 0xff)
	blue = bitand(bitrShift(m.value,16), 0xff)
endfunc
*_______________________________________________________________________________
Gregory
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform