NAME
TPalette - color palette representation based on string data
HIERARCHY
TPalette (scalar-based type)
used by TView and derived classes
SYNOPSIS
use TUI::Views;
my $palette = TPalette->new(
data => "\x01\x02\x03",
size => 3,
);
my $len = $palette->at(0); # 3
my $first = $palette->at(1); # ord("\x01")
my @entries = @{$palette}; # length-prefixed palette data
my $copy = TPalette->new(
copy_from => \@data
);
my @data = @{$copy};
my $other = TPalette->new(
copy_from => [
3,
TColorAttr->new( bios => 0x01 ),
TColorAttr->new( bios => 0x02 ),
TColorAttr->new( bios => 0x03 ),
]
);
my @attr = @{$other}; # palette entries as TColorAttr objects
DESCRIPTION
TPalette represents a color palette as used by TVision views. Unlike most TVision classes, TPalette is not derived from TObject.
The original TVision implementation stored a palette as a length-prefixed Pascal string. For compatibility, the Perl port preserves the same logical layout while using an array-based object representation internally:
[ count, entry1, entry2, ... ]
Element [0] contains the number of palette entries and palette data begins at index 1.
Palette objects are typically created once and then shared or cloned by views that require color information.
Palette entries are commonly integer attribute values obtained from string data, but may also be arbitrary objects such as instances of TColorAttr.
CONSTRUCTOR
new
my $palette = TPalette->new(
data => $data,
size => $size,
);
my $palette = TPalette->new(
copy_from => $other
);
Creates a new palette object.
- data
-
String containing the palette data. Used together with
size(Str). - size
-
Number of entries in the palette (PositiveOrZeroInt).
- copy_from
-
Optional palette to copy data from (TPalette). Ignored when
dataandsizeare provided.
new_TPalette
my $palette = new_TPalette($data, $size);
my $palette = new_TPalette($other);
Factory-style constructor using positional arguments.
This constructor forwards to the internal implementation and is provided for compatibility with traditional Turbo Vision construction patterns.
METHODS
assign
$palette->assign($other);
Assigns the contents of another palette to this palette.
at
my $entry = $palette->at($index);
Returns the palette entry at the specified index as an integer value.
clone
my $copy = $palette->clone();
Creates and returns a clone of the palette.
SEE ALSO
AUTHORS
Borland International (original Turbo Vision design)
J. Schneider <brickpool@cpan.org> (Perl implementation and maintenance)
CONTRIBUTORS
magiblot <magiblot@hotmail.com>
COPYRIGHT AND LICENSE
Copyright (c) 1990-1994, 1997 by Borland International
Copyright (c) 2019-2026 the "AUTHORS" and "CONTRIBUTORS" as listed above.
This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution).