delphi - 使用 delphi 按 Hue 和 Luminosity 对颜色(调色板)列表进行排序

标签 delphi delphi-xe

我有几个颜色列表(TColor)存储在数组中,我喜欢使用 HUE o 亮度进行排序,是否存在任何具有此类函数或算法的 delphi 库或组件?

最佳答案

Delphi 包含一个名为 GraphUtil 的单元,它有一个名为 SortColorArray 的函数。

procedure SortColorArray(ColorArray: TColorArray; L, R: Integer;
  SortType: TColorArraySortType; Reverse: Boolean = False);

此函数可以按色相、饱和度、亮度、红、绿、蓝对颜色列表进行排序。

你可以这样使用它

var
 ColorList : TColorArray; 
 i         : Integer;
begin

  SetLength(ColorList,WebNamedColorsCount);
  //fill the list the colors in this case using webcolors
  for i := 0 to WebNamedColorsCount - 1 do
  begin
   ColorList[i].Value:=WebNamedColors[i].Value;
   ColorList[i].Name :='';
  end;
  //sort the colors by HUE
  SortColorArray(ColorList,0,WebNamedColorsCount-1,stHue,False);

  //do your stuff here

end;

关于delphi - 使用 delphi 按 Hue 和 Luminosity 对颜色(调色板)列表进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5738174/

相关文章:

delphi - Delphi 中的公共(public)类成员和发布类成员有什么区别?

delphi - Delphi编译器是否执行优化?

json - 如何在 delphi 中使用 THTTPClient 发布 json?

delphi - 创建无边框表单而不丢失 Windows 命令

string - StringOf 是否复制传递给它的数据?

delphi - 如何在枚举中定义一个非常大的常量而不发出警告?

delphi - 我们可以使用 DUnit 编写什么样的测试用例?

delphi - 在Delphi中远程启动/访问应用程序

MySQL 删除一个 SELECT 结果

delphi - TMemo 如何处理 Mac 上的回车(CRLF)问题?