1
-- $Id: xthick02a.adb 11680 2011-03-27 17:57:51Z airwin $
3
-- Multiple window and color map 0 demo.
5
-- Copyright (C) 2007 Alan W. Irwin
7
-- This file is part of PLplot.
9
-- PLplot is free software; you can redistribute it and/or modify
10
-- it under the terms of the GNU Library General Public License as published
11
-- by the Free Software Foundation; either version 2 of the License, or
12
-- (at your option) any later version.
14
-- PLplot is distributed in the hope that it will be useful,
15
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
16
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
-- GNU Library General Public License for more details.
19
-- You should have received a copy of the GNU Library General Public License
20
-- along with PLplot; if not, write to the Free Software
21
-- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25
Ada.Numerics.Long_Elementary_Functions,
33
Ada.Numerics.Long_Elementary_Functions,
41
------------------------------------------------------------------------------
42
-- Demonstrates multiple windows and color map 0 palette, both default and
44
------------------------------------------------------------------------------
46
procedure xthick02a is
47
--------------------------------------------------------------------------
49
-- Draws a set of numbered boxes with colors according to cmap0 entry.
50
--------------------------------------------------------------------------
52
procedure draw_windows(nw, cmap0_offset : Integer) is
53
vmin, vmax : Long_Float;
56
Set_Character_Height(0.0, 3.5);
57
Set_Font_Style(Script_Font);
59
for i in 0..(nw-1) loop
60
Set_Pen_Color(i+cmap0_offset);
61
Advance_To_Subpage(Next_Subpage);
66
Set_Viewport_Normalized(vmin, vmax, vmin, vmax);
67
Set_Viewport_World(0.0, 1.0, 0.0, 1.0);
68
Box_Around_Viewport("bc", 0.0, 0, "bc", 0.0, 0);
73
Write_Text_World(0.5, 0.5, 1.0, 0.0, 0.5, Trim(Integer'image(i), Left));
77
--------------------------------------------------------------------------
79
-- Demonstrates multiple windows and default color map 0 palette.
80
--------------------------------------------------------------------------
86
-- Divide screen into 16 regions
87
Set_Number_Of_Subpages(4, 4);
92
--------------------------------------------------------------------------
94
-- Demonstrates multiple windows, user-modified color map 0 palette, and
95
-- HLS -> RGB translation.
96
--------------------------------------------------------------------------
100
-- Use 100 custom colors in addition to base 16
101
r, g, b: Integer_Array_1D(0..115);
103
-- Min & max lightness values
104
lmin : Long_Float := 0.15;
105
lmax : Long_Float := 0.85;
106
h, l, s : Long_Float;
107
r1, g1, b1 : Long_Float;
111
-- Divide screen into 100 regions.
112
Set_Number_Of_Subpages(10, 10);
116
-- Bounds on HLS, from Set_Color_HLSrgb() commentary
117
-- hue [0., 360.] degrees
118
-- lightness [0., 1.] magnitude
119
-- saturation [0., 1.] magnitude
121
-- Vary hue uniformly from left to right
122
h := (360.0 / 10.0 ) * Long_Float( i mod 10 );
124
-- Vary lightness uniformly from top to bottom, between min & max.
125
l := lmin + (lmax - lmin) * Long_Float(i / 10) / 9.0;
127
-- Use max saturation.
130
HLS_To_RGB(h, l, s, r1, g1, b1);
132
-- Ada rounds to nearest integer. We want to truncate
133
-- approximately like C to match that example. -0.5 produces
134
-- at least one -1 result (rather than zero) so we subtract
135
-- something with a slightly smaller absolute value.
136
r(i+16) := Integer((r1 * 255.001) - 0.499999999999999);
137
g(i+16) := Integer((g1 * 255.001) - 0.499999999999999);
138
b(i+16) := Integer((b1 * 255.001) - 0.499999999999999);
141
-- Load default cmap0 colors into our custom set.
143
Get_Color_RGB(i, r(i), g(i), b(i));
146
-- Now set cmap0 all at once (faster, since fewer driver calls).
147
Set_Color_Map_0(r, g, b);
149
draw_windows(100, 16);
155
-- Parse and process command line arguments.
156
Parse_Command_Line_Arguments(Parse_Full);
158
-- Initialize plplot.
165
-- Don't forget to call End_PLplot to finish off!