mirror of
https://github.com/moparisthebest/Simba
synced 2025-01-30 14:50:18 -05:00
Fixed the color conversions (RGB-values should be Bytes, not integers.. IMO), oh and it was taking the wrong methods (from graphics.pas instead of colour_conv.pas)
Added testscript for colour conversions, but I cbf to finnish it. Changed the export limit! We are already exporting more than 200 methods, win! git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@427 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
212e41ecd1
commit
1e1c08e5a4
@ -42,7 +42,7 @@ uses
|
|||||||
ColorBox, about, framefunctionlist, ocr, updateform, simbasettings;
|
ColorBox, about, framefunctionlist, ocr, updateform, simbasettings;
|
||||||
|
|
||||||
const
|
const
|
||||||
SimbaVersion = 423;
|
SimbaVersion = 427;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -201,7 +201,6 @@ type
|
|||||||
TB_SelectClient: TToolButton;
|
TB_SelectClient: TToolButton;
|
||||||
ToolButton8: TToolButton;
|
ToolButton8: TToolButton;
|
||||||
MTrayIcon: TTrayIcon;
|
MTrayIcon: TTrayIcon;
|
||||||
ColorListBox1: TColorListBox;
|
|
||||||
procedure ActionClearDebugExecute(Sender: TObject);
|
procedure ActionClearDebugExecute(Sender: TObject);
|
||||||
procedure ActionCloseTabExecute(Sender: TObject);
|
procedure ActionCloseTabExecute(Sender: TObject);
|
||||||
procedure ActionCopyExecute(Sender: TObject);
|
procedure ActionCopyExecute(Sender: TObject);
|
||||||
|
9
Tests/PS/colour conversions.mufa
Normal file
9
Tests/PS/colour conversions.mufa
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
program new;
|
||||||
|
var
|
||||||
|
R,G,B : byte;
|
||||||
|
begin
|
||||||
|
ColorToRGB(clwhite,r,g,b);
|
||||||
|
Writeln([r,g,b]);
|
||||||
|
Writeln(RGBToColor(50,150,250));//16422450
|
||||||
|
writeln(XYZToColor(0.5,0.7,0.9));//1513219
|
||||||
|
end.
|
@ -118,16 +118,16 @@ AddFunction(@ps_GetPage,'function GetPage(url : string): string;');
|
|||||||
|
|
||||||
{ Color Conversions and Speed }
|
{ Color Conversions and Speed }
|
||||||
SetCurrSection('Color Convert');
|
SetCurrSection('Color Convert');
|
||||||
AddFunction(@ColorToRGB, 'procedure ColorToRGB(Color: integer; out r, g, b: Integer);');
|
AddFunction(@Colour_Conv.ColorToRGB, 'procedure ColorToRGB(Color: integer; out r, g, b: Byte);');
|
||||||
AddFunction(@RGBToColor, 'function RGBtoColor(r, g, b: integer): TColor;');
|
AddFunction(@Colour_conv.RGBToColor, 'function RGBtoColor(r, g, b: Byte): TColor;');
|
||||||
AddFunction(@ColorToHSL, 'procedure ColorToHSL(Color: Integer; out h, s, l: Extended);');
|
AddFunction(@Colour_conv.ColorToHSL, 'procedure ColorToHSL(Color: Integer; out h, s, l: Extended);');
|
||||||
AddFunction(@HSLToColor, 'function HSLToColor(H, S, L: Extended): TColor;');
|
AddFunction(@Colour_conv.HSLToColor, 'function HSLToColor(H, S, L: Extended): TColor;');
|
||||||
AddFunction(@ColorToXYZ, 'procedure ColorToXYZ(Color: Integer; out x, y, z: Extended);');
|
AddFunction(@Colour_conv.ColorToXYZ, 'procedure ColorToXYZ(Color: Integer; out x, y, z: Extended);');
|
||||||
AddFunction(@XYZToColor, 'function XYZToColor(X, Y, Z: Extended): TColor;');
|
AddFunction(@Colour_conv.XYZToColor, 'function XYZToColor(X, Y, Z: Extended): TColor;');
|
||||||
AddFunction(@RGBToHSL, 'procedure RGBToHSL(R, G, B: Integer; out h, s, l: Extended);');
|
AddFunction(@Colour_conv.RGBToHSL, 'procedure RGBToHSL(R, G, B: Byte; out h, s, l: Extended);');
|
||||||
AddFunction(@HSLToRGB, 'procedure HSLtoRGB(H, S, L: extended; out R, G ,B: Integer);');
|
AddFunction(@Colour_conv.HSLToRGB, 'procedure HSLtoRGB(H, S, L: extended; out R, G ,B: Byte);');
|
||||||
AddFunction(@RGBToXYZ, 'procedure RGBToXYZ(R, G, B: Integer;out x, y ,z: Extended);');
|
AddFunction(@Colour_conv.RGBToXYZ, 'procedure RGBToXYZ(R, G, B: Byte;out x, y ,z: Extended);');
|
||||||
AddFunction(@XYZToRGB, 'procedure XYZToRGB(X, Y, Z: Extended; out R, G, B: integer);');
|
AddFunction(@Colour_conv.XYZToRGB, 'procedure XYZToRGB(X, Y, Z: Extended; out R, G, B: Byte);');
|
||||||
|
|
||||||
{ Color Finding }
|
{ Color Finding }
|
||||||
SetCurrSection('Color');
|
SetCurrSection('Color');
|
||||||
|
@ -515,8 +515,8 @@ end;
|
|||||||
procedure AddFunction( Ptr : Pointer; DeclStr : String);
|
procedure AddFunction( Ptr : Pointer; DeclStr : String);
|
||||||
begin;
|
begin;
|
||||||
// SetLength(ExportedMethods,c+1);
|
// SetLength(ExportedMethods,c+1);
|
||||||
if c >= 200 then
|
if c >= 300 then
|
||||||
raise exception.create('PSThread.LoadMethods: Exported more than 200 functions');
|
raise exception.create('PSThread.LoadMethods: Exported more than 300 functions');
|
||||||
Result[c].FuncDecl:= DeclStr;
|
Result[c].FuncDecl:= DeclStr;
|
||||||
Result[c].FuncPtr:= Ptr;
|
Result[c].FuncPtr:= Ptr;
|
||||||
Result[c].Section:= CurrSection;
|
Result[c].Section:= CurrSection;
|
||||||
@ -526,7 +526,7 @@ end;
|
|||||||
begin
|
begin
|
||||||
c := 0;
|
c := 0;
|
||||||
CurrSection := 'Other';
|
CurrSection := 'Other';
|
||||||
SetLength(Result,200);
|
SetLength(Result,300);
|
||||||
{$i PSInc/psexportedmethods.inc}
|
{$i PSInc/psexportedmethods.inc}
|
||||||
|
|
||||||
SetLength(Result,c);
|
SetLength(Result,c);
|
||||||
|
@ -37,12 +37,11 @@ Function RGBtoColor(r,g,b : byte) : TColor; overload; inline;
|
|||||||
Function RGBtoColor(r,g,b : integer) : TColor; overload; inline;
|
Function RGBtoColor(r,g,b : integer) : TColor; overload; inline;
|
||||||
Procedure ColorToRGB(Color : integer;out r,g,b : byte); overload; inline;
|
Procedure ColorToRGB(Color : integer;out r,g,b : byte); overload; inline;
|
||||||
Procedure ColorToRGB(Color : integer;out r,g,b : integer); overload; inline;
|
Procedure ColorToRGB(Color : integer;out r,g,b : integer); overload; inline;
|
||||||
Procedure RGBToXYZ(R,G,B : integer;out x,y,z : Extended); inline;
|
Procedure RGBToXYZ(R,G,B : byte;out x,y,z : Extended); inline;
|
||||||
Procedure XYZToRGB(X,Y,Z : Extended;out R,G,B: integer); inline;
|
Procedure XYZToRGB(X,Y,Z : Extended;out R,G,B: byte); inline;
|
||||||
Procedure RGBToHSL(RR,GG,BB : integer;out H,S,L : Extended); inline;
|
Procedure RGBToHSL(RR,GG,BB : byte;out H,S,L : Extended); inline;
|
||||||
Procedure RGBToHSLNonFixed(RR,GG,BB : integer;out H,S,L : Extended); inline;
|
Procedure RGBToHSLNonFixed(RR,GG,BB : byte;out H,S,L : Extended); inline;
|
||||||
Procedure HSLtoRGB(H,S,L : extended;out R,G,B : Byte); inline;overload;
|
Procedure HSLtoRGB(H,S,L : extended;out R,G,B : Byte); inline;
|
||||||
Procedure HSLtoRGB(H,S,L : extended;out R,G,B : Integer); inline;overload;
|
|
||||||
Procedure ColorToHSL(Col: Integer; out h, s, l: Extended); inline;
|
Procedure ColorToHSL(Col: Integer; out h, s, l: Extended); inline;
|
||||||
procedure ColorToXYZ(color: Integer; out X, Y, Z: Extended); inline;
|
procedure ColorToXYZ(color: Integer; out X, Y, Z: Extended); inline;
|
||||||
function XYZToColor(X, Y, Z: Extended): TColor; inline;
|
function XYZToColor(X, Y, Z: Extended): TColor; inline;
|
||||||
@ -100,7 +99,7 @@ end;
|
|||||||
X, Y and Z components.
|
X, Y and Z components.
|
||||||
/\}
|
/\}
|
||||||
|
|
||||||
Procedure RGBToXYZ(R,G,B : integer;out x,y,z : Extended); inline;
|
Procedure RGBToXYZ(R,G,B : byte;out x,y,z : Extended); inline;
|
||||||
var
|
var
|
||||||
Red,Green,Blue : Extended;
|
Red,Green,Blue : Extended;
|
||||||
begin;
|
begin;
|
||||||
@ -129,7 +128,7 @@ end;
|
|||||||
Red (R), Green (G) and Blue (B) components.
|
Red (R), Green (G) and Blue (B) components.
|
||||||
/\}
|
/\}
|
||||||
|
|
||||||
Procedure XYZToRGB(X,Y,Z : Extended;out R,G,B: integer); inline;
|
Procedure XYZToRGB(X,Y,Z : Extended;out R,G,B: byte); inline;
|
||||||
var
|
var
|
||||||
TempR,TempG,TempB,Tempx,tempy,tempz : Extended;
|
TempR,TempG,TempB,Tempx,tempy,tempz : Extended;
|
||||||
begin;
|
begin;
|
||||||
@ -161,7 +160,7 @@ end;
|
|||||||
H (Hue), S (Saturation) and L (Luminance) components.
|
H (Hue), S (Saturation) and L (Luminance) components.
|
||||||
/\}
|
/\}
|
||||||
|
|
||||||
Procedure RGBToHSL(RR,GG,BB : integer;out H,S,L : Extended); inline;
|
Procedure RGBToHSL(RR,GG,BB : byte;out H,S,L : Extended); inline;
|
||||||
var
|
var
|
||||||
R, G, B, D, Cmax, Cmin: Extended;
|
R, G, B, D, Cmax, Cmin: Extended;
|
||||||
begin
|
begin
|
||||||
@ -208,7 +207,7 @@ end;
|
|||||||
This function does not multiply it by 100.
|
This function does not multiply it by 100.
|
||||||
/\}
|
/\}
|
||||||
|
|
||||||
Procedure RGBToHSLNonFixed(RR,GG,BB : integer;out H,S,L : Extended); inline;
|
Procedure RGBToHSLNonFixed(RR,GG,BB : byte;out H,S,L : Extended); inline;
|
||||||
var
|
var
|
||||||
R, G, B, D, Cmax, Cmin: Extended;
|
R, G, B, D, Cmax, Cmin: Extended;
|
||||||
begin
|
begin
|
||||||
@ -251,7 +250,7 @@ end;
|
|||||||
Red (R), Green (G) and Blue (B) components.
|
Red (R), Green (G) and Blue (B) components.
|
||||||
/\}
|
/\}
|
||||||
|
|
||||||
procedure HSLtoRGB(H, S, L: extended; out R, G, B: Byte); inline; overload;
|
procedure HSLtoRGB(H, S, L: extended; out R, G, B: Byte); inline;
|
||||||
var
|
var
|
||||||
Temp,Temp2 : Extended;
|
Temp,Temp2 : Extended;
|
||||||
//begin
|
//begin
|
||||||
@ -294,56 +293,13 @@ begin;
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure HSLtoRGB(H,S,L : extended;out R,G,B : Integer); inline;
|
|
||||||
var
|
|
||||||
Temp,Temp2 : Extended;
|
|
||||||
//begin
|
|
||||||
|
|
||||||
Function Hue2RGB(TempHue : Extended) : integer;
|
|
||||||
begin;
|
|
||||||
if TempHue < 0 then
|
|
||||||
TempHue := TempHue + 1
|
|
||||||
else if TempHue > 1 then
|
|
||||||
TempHue := TempHue - 1;
|
|
||||||
if ( ( 6 * TempHue ) < 1 ) then
|
|
||||||
Result :=Round(255 * (( Temp + ( Temp2 - Temp ) * 6 * TempHue )))
|
|
||||||
else if ( ( 2 * TempHue ) < 1 ) then
|
|
||||||
Result :=Round(255 * Temp2)
|
|
||||||
else if ( ( 3 * TempHue ) < 2 ) then
|
|
||||||
Result :=Round(255 * (Temp + ( Temp2 - Temp ) * ( ( TwoDivThree ) - TempHue ) * 6))
|
|
||||||
else
|
|
||||||
Result :=Round(255 * Temp);
|
|
||||||
end;
|
|
||||||
|
|
||||||
begin;
|
|
||||||
H := H / 100;
|
|
||||||
S := S / 100;
|
|
||||||
L := L / 100;
|
|
||||||
if s = 0 then
|
|
||||||
begin;
|
|
||||||
R := Round(L * 255);
|
|
||||||
G := R;
|
|
||||||
B := R;
|
|
||||||
end else
|
|
||||||
begin;
|
|
||||||
if (L < 0.5) then
|
|
||||||
Temp2 := L * ( 1 + S )
|
|
||||||
else
|
|
||||||
Temp2 := (L + S) - ( S * L);
|
|
||||||
Temp := 2 * L - Temp2;
|
|
||||||
R := Hue2RGB( H + ( OneDivThree ) );
|
|
||||||
G := Hue2RGB( H );
|
|
||||||
B := Hue2RGB( H - ( OneDivThree ) );
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
{/\
|
{/\
|
||||||
Split the Given Color col in H, S, L components.
|
Split the Given Color col in H, S, L components.
|
||||||
/\}
|
/\}
|
||||||
|
|
||||||
Procedure ColorToHSL(Col: Integer; out h, s, l: Extended); inline;
|
Procedure ColorToHSL(Col: Integer; out h, s, l: Extended); inline;
|
||||||
Var
|
Var
|
||||||
R, G, B: Integer;
|
R, G, B: byte;
|
||||||
Begin
|
Begin
|
||||||
ColorToRGB(Col, R, G, B);
|
ColorToRGB(Col, R, G, B);
|
||||||
RGBToHSL(R, G, B, H, S, L);
|
RGBToHSL(R, G, B, H, S, L);
|
||||||
@ -351,7 +307,7 @@ End;
|
|||||||
|
|
||||||
procedure ColorToXYZ(color: Integer; out X, Y, Z: Extended); inline;
|
procedure ColorToXYZ(color: Integer; out X, Y, Z: Extended); inline;
|
||||||
var
|
var
|
||||||
R, G, B: Integer;
|
R, G, B: byte;
|
||||||
begin
|
begin
|
||||||
ColorToRGB(Color, R, G, B);
|
ColorToRGB(Color, R, G, B);
|
||||||
RGBToXYZ(R, G, B, X, Y, Z);
|
RGBToXYZ(R, G, B, X, Y, Z);
|
||||||
@ -359,7 +315,7 @@ end;
|
|||||||
|
|
||||||
function HSLToColor(H, S, L: Extended): TColor; inline;
|
function HSLToColor(H, S, L: Extended): TColor; inline;
|
||||||
var
|
var
|
||||||
r, g, b: Integer;
|
r, g, b: byte;
|
||||||
begin
|
begin
|
||||||
HSLToRGB(H, S, L, r, g, b);
|
HSLToRGB(H, S, L, r, g, b);
|
||||||
Result := RGBToColor(r, g, b);
|
Result := RGBToColor(r, g, b);
|
||||||
@ -367,7 +323,7 @@ end;
|
|||||||
|
|
||||||
function XYZToColor(X, Y, Z: Extended): TColor; inline;
|
function XYZToColor(X, Y, Z: Extended): TColor; inline;
|
||||||
var
|
var
|
||||||
r, g, b: Integer;
|
r, g, b: byte;
|
||||||
begin
|
begin
|
||||||
XYZToRGB(X, Y, Z, r, g, b);
|
XYZToRGB(X, Y, Z, r, g, b);
|
||||||
Result := RGBToColor(r, g, b);
|
Result := RGBToColor(r, g, b);
|
||||||
|
Loading…
Reference in New Issue
Block a user