Notifications
Clear all

[Closed] colorpicker.color.value issues

ok so I’m losing my mind here …

I’m trying to change one colorpickers value based on another colorpickers value
which for some obscure reason is not working the way I suspect it should …


try (destroyDialog test)catch ()
rollout test "test" 
(  		
	colorpicker	cp_baseColor "" color:[150,150,150] width:75 across:2
	colorpicker	cp_02 "" width:75 offset:[0,0]
	button btn_01	"test" width:150 height:25

	on test open do
	(
		cp_02.color.r = (cp_baseColor.color.r - 30)
		cp_02.color.g = cp_02.color.r
		cp_02.color.b = cp_02.color.r 
	)

	on btn_01 pressed do
	(
		cp_02.color.value = cp_baseColor.color.value
	)
)
createDialog test width:175

why is it that the green line does nothing while

cp_02.color = cp_baseColor.color

does exactly what you expect it to do …

5 Replies

You must have lost your mind indeed

.color IS the value of the colorpicker (as documented).

.color.value is the HSV Value of the RGB color, which is a derived property of the MAXScript Color Value (also as documented). In the picker, you can control the Hue, Saturation and the Value of a color. It is the grayscale bar in the bottom right corner of the picker’s dialog.

a = color 200 128 15
(color 200 128 15)
a.hue
25.9595
a.saturation
235.875
a.value
200.0

I haven’t lost my mind THAT much lol …
getting the value (as in hsv) is exactly what I’m trying to accomplish
but for some reason it just doesn’t want to set the cp_02.color.value (hsv) to that of the cp_baseColor.color.value (hsv) after I changed it and pressed btn_01

say I change the color of cp_baseColor to rgb [210,111,111] (hsv [255,120,210])
I want the hsv v value (210) to be copied over to the hsv v value of cp_02

what am I doing wrong 🙁

Good to know you are still sane!

The value is a derived property and it appears that it cannot be set inline in the property of the color picker. You have to store the color in an intermediate variable, modify it there and assign back. This also applies to some .items array property manipulations of comboboxes like insertItem()…

	on btn_01 pressed do
 	(
 		theColor = cp_02.color
 		theColor.value = cp_baseColor.color.value
 		cp_02.color = theColor
 	)
1 Reply
(@drdubosc)
Joined: 11 months ago

Posts: 0

The weird thing is, though, that the value of the property appears to be behaving well. If you alter v, the rgb component values look to update correctly, if you have a peek at them. It’s just not displaying? It’s as if there’s no side-effect to cause a repaint, or something like that.

ah ok, I get that … that’s what I get for having to wait for the mail to finally deliver your CGAcademy dvd’s …

in the meanwhile, say Hi to Martijn van Herk for me

thanks for helping me out here.