PPalette 7.50 (Mac/PC)

Kylerk
Posts: 47
Joined: 18 Jun 2011, 13:43

Re: PPalette 7.50 (Mac/PC)

Post by Kylerk »

Thanks so much for trying Lemec.

If the Devs are reading, please get Lemec an updated SDK. It would be greatly appreciated. I imagine other people would like to make plugins as well. I'd certainly be interesting in understanding how it is done.

I did end up creating a little george script that is an attempt at the weighted color picker.
All it does is find the color between the current APen and a pick that the user makes. You can change the 0.5 value to something like 0.2, to make the new pick have a lighter influence.

I've bound 2 weights of it to some hotkeys and can grab a bit, or a lot of a color, and quickly repeat the process. It doesn't have any of the "perceptual" color picking that I think was the secret sauce of the original plugin. It's certainly better than nothing.

Code: Select all

tv_getapen "rgb"
Parse result s1 r1 g1 b1 a1

tv_piccolor "rgb"
Parse result s2  r2 g2 b2 a2

rA = r1 +(r2-r1)*0.5
gA = g1+ (g2-g1)*0.5
bA = b1+(b2-b1)*0.5

tv_setapen "rgb" rA gA bA
Kylerk
Posts: 47
Joined: 18 Jun 2011, 13:43

Re: PPalette 7.50 (Mac/PC)

Post by Kylerk »

A wrote a much more elaborate george script that uses HSL and attempts to do a luminance correction.

It works decently I think.

Unfortunately I had to use the color pickers HSL and RGB powers to do that conversion. I couldn't find a better way to do it in George Script. This causes a brief pause in the tool.

Code: Select all

		
		
// Start of TVpaint Program	
		
//Color A (Existing Color)
tv_getapen "hsl"
Parse result AT AH AS AV AA

tv_getapen "rgb"
Parse result ARBGT AR AG AB AA2

ABrightness=PerceivedBrightnessF(AR, AG, AB)

//Color B

tv_piccolor 
Parse result b xBR xBG xBB xBA



//To get an RBG Value, I set and get the color.
tv_setapen "rgb" xBR xBG xBB
tv_getapen "hsl"
Parse result BT BH BS BV BA
tv_getapen "rgb"
Parse result BRBGT BR BG BB BA

BBrightness=PerceivedBrightnessF(BR, BG, BB)

//In the case of a pure grey, just take the hue of the new color.  As it defaults to red if not
IF (AS==0)
	AH = BH
END


t = 0.5
newH=0
hueOppositionMult = 0.3
targetBrightness = ABrightness + (BBrightness - ABrightness) * t

hueOpposition = 0

IF Abs(BH - AH) > 180
	newH = SimpleModulo( AH + (BH+360-AH) * t , 360)
	hueOpposition = SimpleModulo(180 - Abs(BH - AH), 180)
ELSE
	newH = SimpleModulo( AH + (BH - AH) * t , 360)
	hueOpposition = SimpleModulo(Abs(BH - AH) ,180)
END

//tv_warn "AH, BH, NewH" AH BH newHzz

newSTemp = SimpleModulo(AS + (BS - AS) * t , 255)
newS = Clamp255(newSTemp - hueOpposition * t * hueOppositionMult)


newV = Clamp255(AV + (BV - AV) * t)

valueShift = 0
perceivedBrightness = 0
i = 0
Upbool = 1
tv_lockdisplay 
DO
	
	i = i+1
	
	valueShift= valueShift+Upbool
	//tv_Warn "send to pen " newH newS newV+valueShift
	tv_setapen "hsl" newH newS newV+valueShift
	tv_getapen "rgb"
	Parse result XRBGT XR XG XB XA
	
	perceivedBrightness = PerceivedBrightnessF(XR, XG, XB)
	IF (valueShift>255)
	  Upbool = - 1
	  valueShift = -1
	END
UNTIL ((Abs(perceivedBrightness-targetBrightness)<2) || (i > 510))


if (i == 510)
	valueShift = 0
	
END
tv_unlockdisplay
tv_setapen "hsl" newH newS newV+valueShift


Function PerceivedBrightnessF(r,g,b)
LOCAL thing
thing = SQR(r * r * 0.241 + g * g * 0.691 + b * b * 0.068)
Return thing
End

Function SimpleModulo(input,divisor)
LOCAL xTHING 
xTHING = input
IF xTHING > divisor
 xTHING= xTHING-divisor
End
//tv_Warn "mod" input divisor xthing
Return xTHING
End

Function Clamp255(value)
IF value>255
	Return 255
ELSE
	IF value<0
		Return 0
		ELSE
		Return value
	End
End
End







Post Reply