The basic concept is i have an image, and a detecting area with the same size as the image itself. The sizes here is important becouse we will use the pixels as the base of our calculations. Where we will click with the mouse, the relative x;y mouse position will return with values.

Code: Select all

```
[detectingArea]
Meter=Image
SolidColor=0,0,0,1
X=0
Y=0
W=200
H=85
LeftMouseDownAction=[!SetVariable "xx" "$MouseX$"][!SetVariable "yy" "$MouseY$"][!WriteKeyValue Variables "xi" "$MouseX$" "set.inc"][!WriteKeyValue Variables "yi" "$MouseY$" "set.inc"]
DynamicVariables=1
MouseActionCursor=0
```

As the image above is showing, i had to "split in half" with a calculation the area horizontally, so one measure can make the full brightness function. For this my idea was the following:

color = (#red#-#brightness#), (#green#-#brightness#), (#blue#-#brightness#)

So let's have an example: red=255, green=16, blue=113, brightness=-200 (upwards from the middle of the image's zero line)

The red will remain 255, because the script will allways reduce the max number to 255 for the final r, g, and b.

The green is 16, but we have a "-200" on brightness, so: (16-(-200)) will be 216.

The blue is 113 and -200 on brightness, so (113-(-200)) will be 313, but capped to 255.

The final result will be 255,216,255. It will be almost white.

Here is the code for the brightness measure:

Code: Select all

```
[CalcBrightness]
Measure=Calc
Formula=((#yy#*6)-255)
ifCondition=(CalcBrightness < -240)
ifTrueAction=[!SetVariable "brg" -255][!WriteKeyValue Variables "tbrg" "-255" "set.inc"]
ifCondition2=((CalcBrightness > -240) && (CalcBrightness < 240) && ((#brg#) <> CalcBrightness))
ifTrueAction2=[!SetVariable "brg" [CalcBrightness]][!WriteKeyValue Variables "tbrg" "[CalcBrightness]" "set.inc"]
ifCondition3=(CalcBrightness > 240)
ifTrueAction3=[!SetVariable "brg" 255][!WriteKeyValue Variables "tbrg" "255" "set.inc"]
DynamicVariables=1
```

I used here "Rdec" name, because it is "red decrease". decrease because the red is separated in two to fulfill the full range of rgb color shades.

Code: Select all

```
[CalcRdec]
Measure=Calc
Formula=(8*(62-#xx#))
ifCondition=((#xx# > 70) && (#xx# < 139))
ifTrueAction=[!SetVariable "xr" 0]
ifCondition2=(#xx# < 35)
ifTrueAction2=[!SetVariable "xr" 255]
ifCondition3=((#xx# > 35) && (#xx# < 70) && (#xr# <> [CalcRdec]))
ifTrueAction3=[!SetVariable "xr" [CalcRdec]]
DynamicVariables=1
```

Between 70 and 139 pixel will zeroing the value. But i needed a separate code for the increasing red at the end of the image:

Code: Select all

```
[CalcRinc]
Measure=Calc
Formula=8*((#xx#)-136)
ifCondition=((#xx# > 139) && (#xx# < 165) && (#xr# <> CalcRinc))
ifTrueAction=[!SetVariable "xr" [CalcRinc]]
ifCondition2=(#xx# > 165)
ifTrueAction2=[!SetVariable "xr" 255]
DynamicVariables=1
```

After calculated these normal red values, i needed to add the brightness control.

Code: Select all

```
[CalcRed]
Measure=Calc
Formula=(#xr# - #brg#)
ifCondition=((CalcRed > 0)&&(CalcRed < 255)&&(CalcRed <> #rr#))
ifTrueAction=[!SetVariable "rr" [CalcRed]]
ifCondition2=(CalcRed < 1)
ifTrueAction2=[!SetVariable "rr" 0]
ifCondition3=(CalcRed > 254)
ifTrueAction3=[!SetVariable "rr" 255]
DynamicVariables=1
```

I only mention the Green calculation, because the Blue is almost the same, just 70 pixel difference in X position.

Code: Select all

```
[CalcGi]
Measure=Calc
Formula=Abs((Abs(11*(#xx#-66)))-637)
ifCondition=((#xx# > 33)&&(#xx# < 101))
ifTrueAction=[!SetVariable "xg" 255]
ifCondition2=(((#xx# > 8)&&(#xx# < 33))&&(#xg# <> [CalcGi]))
ifTrueAction2=[!SetVariable "xg" [CalcGi]]
ifCondition3=(((#xx# > 101)&&(#xx# < 124))&&(#xg# <> [CalcGi]))
ifTrueAction3=[!SetVariable "xg" [CalcGi]]
ifCondition4=((#xx# < 8)||(#xx# > 124))
ifTrueAction4=[!SetVariable "xg" 0]
DynamicVariables=1
```

My basic idea was a strange range.

For example: there is a 100% wide image. Now i have to control the value like this:

0-30% = 0<->254

30-70% = 255

70-100% = 254<->0

I don't know if you get my technique. I hope it's clear.

So i had to be a little tricky, becouse i had to calculate the whole range's maximum value.

I have 2 x 255 range, that is 510. And there is the last 40% range, so a simple calculation and you get the final in pixels.

I had to convert these values in pixels, and played a little for the better visual matching.

And here is the final green variable calc measure code:

Code: Select all

```
[CalcGrn]
Measure=Calc
Formula=(#xg# - #brg#)
ifCondition=((CalcGrn > 0)&&(CalcGrn < 255)&&(CalcGrn <> #gg#))
ifTrueAction=[!SetVariable "gg" [CalcGrn]]
ifCondition2=(CalcGrn < 1)
ifTrueAction2=[!SetVariable "gg" 0]
ifCondition3=(CalcGrn > 254)
ifTrueAction3=[!SetVariable "gg" 255]
DynamicVariables=1
```

For safety reasons, at the end of the color and brightness calculations i save the final variables into a set.inc file:

Code: Select all

```
[SkinRefresMemory]
Measure=Calc
Formula=(#rr#<>#rx#)||(#gg#<>#gx#)||(#bb#<>#bx#)?1:0
ifEqualValue=1
ifEqualAction=[!WriteKeyValue Variables "rx" "#rr#" "set.inc"][!WriteKeyValue Variables "gx" "#gg#" "set.inc"][!WriteKeyValue Variables "bx" "#bb#" "set.inc"]
DynamicVariables=1
Disabled=0
```

I hope this script will be helpfull!