NAME

TUI::Views::Palette - 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 => $data,
  size => length($data)
);

my $byte = $palette->at($index);

my @colors = @{$palette};
# @colors now contains the palette entries as integer values

DESCRIPTION

TPalette represents a color palette as used by TUI::Vision views. Unlike most TUI::Vision classes, TPalette is not derived from TObject and does not use a hash-based object layout. Instead, it is conceptually based on scalar string data.

This design mirrors the original Turbo Vision definition, where TPalette is simply a string type. Each character in the string represents a color entry. The Perl implementation preserves this model while providing a small set of object-style methods for convenience and compatibility.

Palette objects are typically created once and then shared or cloned by views that require color information.

TPalette supports array dereferencing through operator overloading. Dereferencing a palette as an array returns a list of byte values representing the palette entries.

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. When provided, data and size are ignored (TPalette).

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 $byte = $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

TUI::Views::View, TUI::Views::PaletteConst

AUTHORS

  • Borland International (original Turbo Vision design)

  • J. Schneider <brickpool@cpan.org> (Perl implementation and maintenance)

COPYRIGHT AND LICENSE

Copyright (c) 1990-1994, 1997 by Borland International

Copyright (c) 2021-2026 the "AUTHORS" as listed above.

This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution).