ScriptSpot

Forum topic · General Scripting

Hello. how make a color complementary in two color pickers at same time, please

By juanb · 2013-04-11

Description

Hello to every body. i have this script

 

-------------------------------------//----------------------------------------

Rollout twocolor "complementary " 

(

Group "complimentary color:"

(

colorpicker theColor_ct  color:[0,0,255] modal:false  across:2  

colorpicker theColorb  color:[255,156,0] modal:false  

   on theColor_ct changed new_colct do theColorb.color = new_colct 

   on theColorb changed new_colb do theColor_ct.color = new_colb

 

)

)

createDialog twocolor 280 50

-------------------------------------//----------------------------------------

I could connect the two color picker, but as you can see gives the same color, please how should be the code so when i select a color in "theColor_ct", the color in the "theColorb" it will be the complementary and  backwards?

Thnaks for you time.😉

 

Comments (3)

themaxxer · 2013-05-01

works like a charm... thanks.
could you make it as macro script? I can't do it.

thanks
themaxxer

barigazy · 2013-05-01


macroScript complementary category:"le1setreter" toolTip:"complementary in two color"
(
try(destroyDialog ::twocolor)catch()
Rollout twocolor "complementary "
(
fn getComplColor baseColor =
(
origR = baseColor.r
origG = baseColor.g
origB = baseColor.b

minRGB = amin origR origG origB
maxRGB = amax origR origG origB
minPlusMax = minRGB + maxRGB

complColor = color (minPlusMax-origR) (minPlusMax-origG) (minPlusMax-origB)
)
Group "complimentary color:"
(
colorpicker theColor_ct color:[0,0,255] modal:false across:2
colorpicker theColorb color:[255,156,0] modal:false

on theColor_ct changed new_colct do theColorb.color = getComplColor new_colct
on theColorb changed new_colb do theColor_ct.color = getComplColor new_colb
)
)
createDialog twocolor 280 50 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
)

le1setreter · 2013-04-13

try with this function:


Rollout twocolor "complementary " 
(

	fn getComplColor baseColor =
	(
		origR = baseColor.r
		origG = baseColor.g
		origB = baseColor.b
			
		minRGB = amin origR origG origB
		maxRGB = amax origR origG origB
		minPlusMax = minRGB + maxRGB
			
		complColor = color (minPlusMax-origR) (minPlusMax-origG) (minPlusMax-origB)
	)	


	Group "complimentary color:"
	(

	colorpicker theColor_ct  color:[0,0,255] modal:false  across:2  
	colorpicker theColorb  color:[255,156,0] modal:false  

	on theColor_ct changed new_colct do theColorb.color = getComplColor new_colct
	on theColorb changed new_colb do theColor_ct.color = getComplColor new_colb

	)

)

createDialog twocolor 280 50

i am not sure if the values are 100% exact. i took the formula from here:
http://forum.processing.org/topic/the-opposite-of-a-color