ArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2014-12-10T01:51:25+02:00 https://brainmodular.org/forums/app.php/feed/topic/4621 2014-12-10T01:51:25+02:00 2014-12-10T01:51:25+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30873#p30873 <![CDATA[Scripting - Color Handling - ptColorChooser]]> So this Type TColor is it the same Hexadecimal reading as a Color Selection?

Trying to use TColor and force the same Hexadecimal results does not output the intended value as in the script.
I am not for sure how it is done, whether it's the conversion from the Type to a Float/Single used on the output?
Maybe this conversion is what is confusing me in how this works.

-S

Statistics: Posted by sephult — 10 Dec 2014, 00:51


]]>
2014-12-09T20:31:34+02:00 2014-12-09T20:31:34+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30872#p30872 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
Yeah I was driving myself nuts trying to implement. :)
Thank you for your sharing, I will see what I can get going with this.


Definitely would be nice if we could get a basic string to hex output to match the colors hex values.
This definitely seems like a suggestion that probably needs implemented in the script.

Will see what can do maybe if I can get working and learn some more about how its handled...I can start looking into modifying this script.

Thanks!!
-S

Statistics: Posted by sephult — 09 Dec 2014, 19:31


]]>
2014-12-09T11:36:36+02:00 2014-12-09T11:36:36+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30871#p30871 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
edit, found back this one my help, to add at the end of your scripts.

at that time needed to declare a new type on top header Tcolor.,
then during callback or process, u can call a needed fonction ,

like HSLtoRGB(0,0,0) will return black, then u can get all the colors via setting up hue, sat and lum with is the most handy way imo

type TColor = -$7FFFFFFF-1..$7FFFFFFF;
///////////////////////////////////////////////////////////////////
function RGBtoBGR (rgb: integer): integer;
begin
Result := $10000*round(Byte(rgb)) + $100*round (Byte(rgb shr 8)) + round (Byte(rgb shr 16));
end;
///////////////////////////////////////
function RGB(r, g, b: Byte): TColor;
begin
Result := (r or (g shl 8) or (b shl 16));
end;
///////////////////////////////////////
function HSLtoRGB (H, S, L: single): TColor;
var
M1, M2: single;

function HueToColourValue (Hue: single) : byte;
var
V : double;
begin
if Hue < 0 then
Hue := Hue + 1
else
if Hue > 1 then
Hue := Hue - 1;

if 6 * Hue < 1 then
V := M1 + (M2 - M1) * Hue * 6
else
if 2 * Hue < 1 then
V := M2
else
if 3 * Hue < 2 then
V := M1 + (M2 - M1) * (2/3 - Hue) * 6
else
V := M1;
Result := round (255 * V)
end;

var
R, G, B: byte;
begin
if S = 0 then
begin
R := round (255 * L);
G := R;
B := R
end else begin
if L <= 0.5 then
M2 := L * (1 + S)
else
M2 := L + S - L * S;
M1 := 2 * L - M2;
R := HueToColourValue (H + 1/3);
G := HueToColourValue (H);
B := HueToColourValue (H - 1/3)
end;

Result := RGB (R, G, B)
end;

///////////////////////////////////////
procedure RGBtoHSL (RGB: TColor; var H, S, L : single);
var
R, G, B, D, Cmax, Cmin: single;
begin
R := GetRValue (RGB) / 255;
G := GetGValue (RGB) / 255;
B := GetBValue (RGB) / 255;
Cmax := MaxS (R, MaxS (G, B));
Cmin := MinS (R, MinS (G, B));

// calculate luminosity
L := (Cmax + Cmin) / 2;

if Cmax = Cmin then // it's grey
begin
H := 0; // it's actually undefined
S := 0
end else begin
D := Cmax - Cmin;

// calculate Saturation
if L < 0.5 then
S := D / (Cmax + Cmin)
else
S := D / (2 - Cmax - Cmin);

// calculate Hue
if R = Cmax then
H := (G - B) / D
else
if G = Cmax then
H := 2 + (B - R) /D
else
H := 4 + (R - G) / D;

H := H / 6;
if H < 0 then
H := H + 1
end
end;
///////////////////////////////////////
function GetRValue(rgb: DWORD): Byte;
begin
Result := Byte(rgb);
end;
///////////////////////////////////////
function GetGValue(rgb: DWORD): Byte;
begin
Result := Byte(rgb shr 8);
end;
///////////////////////////////////////
function GetBValue(rgb: DWORD): Byte;
begin
Result := Byte(rgb shr 16);
end;
////////////////////////////////////

Statistics: Posted by 23fx23 — 09 Dec 2014, 10:36


]]>
2014-12-08T23:56:13+02:00 2014-12-08T23:56:13+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30869#p30869 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
No i do not think it is related to what you are thinking.

So if you reverse engineer it and take the hexadecimal color value for the color:
Trying to convert this back to a single to feed the color using a Tparameter of ColorChooser...or a specific color output for scripting.
It seems that no matter how I implement the output variation is unknown.

Possibly reverse engineering it and using a data parameter to capture the floating value and then pumping that back in might work.
Would be nice to solely work in hexadecimal for the color outputs to standardize, unfortunately in scripting it looks to not be that way.

-S

Statistics: Posted by sephult — 08 Dec 2014, 22:56


]]>
2014-12-08T20:33:44+02:00 2014-12-08T20:33:44+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30867#p30867 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
In case of the latter, it might be something related to an interference with background colors (well, just an intuition : ) )

Q

Statistics: Posted by Question — 08 Dec 2014, 19:33


]]>
2014-12-08T20:12:59+02:00 2014-12-08T20:12:59+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30866#p30866 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
So I am confused how to handle controlling color outputs from fastscripts.

It seems no matter what I try that the color outputs do not seem to match what I am intending.


Since the color outputs are read out in Hexadecimal, I cannot seem to get the intended hexadecimal to ColorChooser conversion
to match.

I've even tried to read in a ColorFader and push that value through to the output and cannot get the correct colors.


Anyone have any examples or success in managing colors through scripting?

-S

Statistics: Posted by sephult — 08 Dec 2014, 19:12


]]>
BrainModular BrainModular Users Forum 2014-12-10T01:51:25+02:00 https://brainmodular.org/forums/app.php/feed/topic/4621 2014-12-10T01:51:25+02:00 2014-12-10T01:51:25+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30873#p30873 <![CDATA[Scripting - Color Handling - ptColorChooser]]> So this Type TColor is it the same Hexadecimal reading as a Color Selection?

Trying to use TColor and force the same Hexadecimal results does not output the intended value as in the script.
I am not for sure how it is done, whether it's the conversion from the Type to a Float/Single used on the output?
Maybe this conversion is what is confusing me in how this works.

-S

Statistics: Posted by sephult — 10 Dec 2014, 00:51


]]>
2014-12-09T20:31:34+02:00 2014-12-09T20:31:34+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30872#p30872 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
Yeah I was driving myself nuts trying to implement. :)
Thank you for your sharing, I will see what I can get going with this.


Definitely would be nice if we could get a basic string to hex output to match the colors hex values.
This definitely seems like a suggestion that probably needs implemented in the script.

Will see what can do maybe if I can get working and learn some more about how its handled...I can start looking into modifying this script.

Thanks!!
-S

Statistics: Posted by sephult — 09 Dec 2014, 19:31


]]>
2014-12-09T11:36:36+02:00 2014-12-09T11:36:36+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30871#p30871 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
edit, found back this one my help, to add at the end of your scripts.

at that time needed to declare a new type on top header Tcolor.,
then during callback or process, u can call a needed fonction ,

like HSLtoRGB(0,0,0) will return black, then u can get all the colors via setting up hue, sat and lum with is the most handy way imo

type TColor = -$7FFFFFFF-1..$7FFFFFFF;
///////////////////////////////////////////////////////////////////
function RGBtoBGR (rgb: integer): integer;
begin
Result := $10000*round(Byte(rgb)) + $100*round (Byte(rgb shr 8)) + round (Byte(rgb shr 16));
end;
///////////////////////////////////////
function RGB(r, g, b: Byte): TColor;
begin
Result := (r or (g shl 8) or (b shl 16));
end;
///////////////////////////////////////
function HSLtoRGB (H, S, L: single): TColor;
var
M1, M2: single;

function HueToColourValue (Hue: single) : byte;
var
V : double;
begin
if Hue < 0 then
Hue := Hue + 1
else
if Hue > 1 then
Hue := Hue - 1;

if 6 * Hue < 1 then
V := M1 + (M2 - M1) * Hue * 6
else
if 2 * Hue < 1 then
V := M2
else
if 3 * Hue < 2 then
V := M1 + (M2 - M1) * (2/3 - Hue) * 6
else
V := M1;
Result := round (255 * V)
end;

var
R, G, B: byte;
begin
if S = 0 then
begin
R := round (255 * L);
G := R;
B := R
end else begin
if L <= 0.5 then
M2 := L * (1 + S)
else
M2 := L + S - L * S;
M1 := 2 * L - M2;
R := HueToColourValue (H + 1/3);
G := HueToColourValue (H);
B := HueToColourValue (H - 1/3)
end;

Result := RGB (R, G, B)
end;

///////////////////////////////////////
procedure RGBtoHSL (RGB: TColor; var H, S, L : single);
var
R, G, B, D, Cmax, Cmin: single;
begin
R := GetRValue (RGB) / 255;
G := GetGValue (RGB) / 255;
B := GetBValue (RGB) / 255;
Cmax := MaxS (R, MaxS (G, B));
Cmin := MinS (R, MinS (G, B));

// calculate luminosity
L := (Cmax + Cmin) / 2;

if Cmax = Cmin then // it's grey
begin
H := 0; // it's actually undefined
S := 0
end else begin
D := Cmax - Cmin;

// calculate Saturation
if L < 0.5 then
S := D / (Cmax + Cmin)
else
S := D / (2 - Cmax - Cmin);

// calculate Hue
if R = Cmax then
H := (G - B) / D
else
if G = Cmax then
H := 2 + (B - R) /D
else
H := 4 + (R - G) / D;

H := H / 6;
if H < 0 then
H := H + 1
end
end;
///////////////////////////////////////
function GetRValue(rgb: DWORD): Byte;
begin
Result := Byte(rgb);
end;
///////////////////////////////////////
function GetGValue(rgb: DWORD): Byte;
begin
Result := Byte(rgb shr 8);
end;
///////////////////////////////////////
function GetBValue(rgb: DWORD): Byte;
begin
Result := Byte(rgb shr 16);
end;
////////////////////////////////////

Statistics: Posted by 23fx23 — 09 Dec 2014, 10:36


]]>
2014-12-08T23:56:13+02:00 2014-12-08T23:56:13+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30869#p30869 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
No i do not think it is related to what you are thinking.

So if you reverse engineer it and take the hexadecimal color value for the color:
Trying to convert this back to a single to feed the color using a Tparameter of ColorChooser...or a specific color output for scripting.
It seems that no matter how I implement the output variation is unknown.

Possibly reverse engineering it and using a data parameter to capture the floating value and then pumping that back in might work.
Would be nice to solely work in hexadecimal for the color outputs to standardize, unfortunately in scripting it looks to not be that way.

-S

Statistics: Posted by sephult — 08 Dec 2014, 22:56


]]>
2014-12-08T20:33:44+02:00 2014-12-08T20:33:44+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30867#p30867 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
In case of the latter, it might be something related to an interference with background colors (well, just an intuition : ) )

Q

Statistics: Posted by Question — 08 Dec 2014, 19:33


]]>
2014-12-08T20:12:59+02:00 2014-12-08T20:12:59+02:00 https://brainmodular.org/forums/viewtopic.php?t=4621&p=30866#p30866 <![CDATA[Scripting - Color Handling - ptColorChooser]]>
So I am confused how to handle controlling color outputs from fastscripts.

It seems no matter what I try that the color outputs do not seem to match what I am intending.


Since the color outputs are read out in Hexadecimal, I cannot seem to get the intended hexadecimal to ColorChooser conversion
to match.

I've even tried to read in a ColorFader and push that value through to the output and cannot get the correct colors.


Anyone have any examples or success in managing colors through scripting?

-S

Statistics: Posted by sephult — 08 Dec 2014, 19:12


]]>