From 32a7553a81f7b5240af0a573d4fb5d441cf17b1e Mon Sep 17 00:00:00 2001 From: Olly Date: Sat, 30 Sep 2023 03:08:48 +0100 Subject: [PATCH] Export GetBestColor --- Source/Simba.lpr | 15 ++++++------ .../imports/simba/simba.import_colormath.pas | 23 ++++++++++++++++++- Source/simba.ide_analytics.pas | 7 +++++- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Source/Simba.lpr b/Source/Simba.lpr index 63614d46e..0c4f93e83 100644 --- a/Source/Simba.lpr +++ b/Source/Simba.lpr @@ -12,15 +12,14 @@ simba.init, Classes, SysUtils, Interfaces, Forms, simba.mufasatypes, simba.main, - simba.aboutform, simba.debugimageform, simba.imagetostringform, - simba.functionlistform, simba.scripttabsform, simba.outputform, - simba.colorpickerhistoryform, simba.filebrowserform, simba.notesform, - simba.settingsform, simba.associate, simba.openexampleform, - simba.package_form, simba.shapeboxform, simba.backupsform, - simba.findinfilesform, + simba.aboutform, simba.debugimageform, simba.imagetostringform, simba.functionlistform, + simba.scripttabsform, simba.outputform, simba.colorpickerhistoryform, simba.filebrowserform, + simba.notesform, simba.settingsform, simba.associate, simba.openexampleform, + simba.package_form, simba.shapeboxform, simba.backupsform, simba.findinfilesform, simba.compiler_dump, simba.plugin_dump, - simba.scriptthread, simba.ide_initialization, simba.threading, - simba.openssl, simba.ide_codetools_setup; + simba.scriptthread, + simba.ide_initialization, simba.ide_analytics, simba.ide_codetools_setup, + simba.openssl; begin {$IF DECLARED(SetHeapTraceOutput)} diff --git a/Source/script/imports/simba/simba.import_colormath.pas b/Source/script/imports/simba/simba.import_colormath.pas index 0464c7d6c..3a41fe0dd 100644 --- a/Source/script/imports/simba/simba.import_colormath.pas +++ b/Source/script/imports/simba/simba.import_colormath.pas @@ -14,7 +14,7 @@ implementation uses Graphics, lptypes, - simba.colormath_distance, simba.colormath; + simba.colormath_distance, simba.colormath, simba.colormath_aca; (* Color Math @@ -402,6 +402,16 @@ procedure _LapeColorDistance2(const Params: PParamArray; const Result: Pointer); PSingle(Result)^ := ColorDistance(PColor(Params^[0])^, PColor(Params^[1])^); end; +(* +GetBestColor +~~~~~~~~~~~~ +> function GetBestColor(ColorSpace: EColorSpace; Colors: TColorArray): TBestColor; +*) +procedure _LapeGetBestColor(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + TBestColor(Result^) := GetBestColor(PColorSpace(Params^[0])^, PColorArray(Params^[1])^); +end; + (* TColor.R ~~~~~~~~ @@ -708,6 +718,17 @@ procedure ImportColorMath(Compiler: TSimbaScript_Compiler); addGlobalFunc('function ColorDistance(Color1, Color2: TColor; const ColorSpace: EColorSpace; const Multipliers: TChannelMultipliers): Single; overload', @_LapeColorDistance1); addGlobalFunc('function ColorDistance(Color1, Color2: TColor): Single; overload', @_LapeColorDistance2); + addGlobalType([ + 'record', + ' Color: TColor;', + ' Mods: TChannelMultipliers;', + ' Tolerance: Single;', + 'end;'], + 'TBestColor' + ); + + addGlobalFunc('function GetBestColor(Formula: EColorSpace; Colors: TColorArray): TBestColor;', @_LapeGetBestColor); + addGlobalType([ 'record', ' const ALICEBLUE = TColor($FFF8F0);', diff --git a/Source/simba.ide_analytics.pas b/Source/simba.ide_analytics.pas index feb7c13e7..f3c25a35e 100644 --- a/Source/simba.ide_analytics.pas +++ b/Source/simba.ide_analytics.pas @@ -1,3 +1,8 @@ +{ + Author: Raymond van Venetiƫ and Merlijn Wajer + Project: Simba (https://github.com/MerlijnWajer/Simba) + License: GNU General Public License (https://www.gnu.org/licenses/gpl-3.0) +} unit simba.ide_analytics; {$i simba.inc} @@ -28,7 +33,7 @@ procedure SendAnalytics; end; initialization - SimbaIDEInitialization.RegisterMethodOnAfterCreate(@SendAnalytics, 'Analytics'); + SimbaIDEInitialization_AddBeforeShow(@SendAnalytics, 'Analytics', True); end.