#!/usr/bin/env instantfpc

{
  Copyright 2020-2022 Michalis Kamburelis.

  This file is part of "Castle Game Engine".

  "Castle Game Engine" is free software; see the file COPYING.txt,
  included in this distribution, for details about the copyright.

  "Castle Game Engine" is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

  ----------------------------------------------------------------------------
}

{ Convert color in hexadecimal notation to Pascal.

  To make this work,
  - install FPC, which should include the instantfpc binary
  - install CGE using FpMake/FpPkg following https://castle-engine.io/fpmake

  Then run like
    ./castle_color_hex_to_pascal FFFF00 # yellow
}

uses SysUtils, CastleVectors, CastleParameters, CastleColors;

var
  ColorStr: String;
  Color: TVector4;
begin
  Parameters.CheckHigh(1);
  ColorStr := Parameters[1];
  Color := HexToColor(ColorStr);
  Writeln(Format('Color: TCastleColor = (Data: (%f, %f, %f, %f)); // hex: %s', [
    Color[0],
    Color[1],
    Color[2],
    Color[3],
    ColorStr
  ]));
end.
