Debian Codegraph @

examples/instantfpc/castle_color_hex_to_pascal

raw
1 #!/usr/bin/env instantfpc
2
3 {
4 Copyright 2020-2022 Michalis Kamburelis.
5
6 This file is part of "Castle Game Engine".
7
8 "Castle Game Engine" is free software; see the file COPYING.txt,
9 included in this distribution, for details about the copyright.
10
11 "Castle Game Engine" is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15 ----------------------------------------------------------------------------
16 }
17
18 { Convert color in hexadecimal notation to Pascal.
19
20 To make this work,
21 - install FPC, which should include the instantfpc binary
22 - install CGE using FpMake/FpPkg following https://castle-engine.io/fpmake
23
24 Then run like
25 ./castle_color_hex_to_pascal FFFF00 # yellow
26 }
27
28 uses SysUtils, CastleVectors, CastleParameters, CastleColors;
29
30 var
31 ColorStr: String;
32 Color: TVector4;
33 begin
34 Parameters.CheckHigh(1);
35 ColorStr := Parameters[1];
36 Color := HexToColor(ColorStr);
37 Writeln(Format('Color: TCastleColor = (Data: (%f, %f, %f, %f)); // hex: %s', [
38 Color[0],
39 Color[1],
40 Color[2],
41 Color[3],
42 ColorStr
43 ]));
44 end.