Packed Record THSLAPixel

Hierarchy
Properties

Unit

Declaration

type THSLAPixel = packed record

Description

Pixel color defined in linear HSL colorspace with gamma correction.

Values range from 0 to 65535. See TGSBAPixel for corrected hue and brightness.

Example drawing all the colors in HSL colorspace:

hslapixel_gradient

procedure TForm1.FormPaint(Sender: TObject);
var x,y: integer;
    p: PBGRAPixel;
    image: TBGRABitmap;
    hsla: THSLAPixel;
begin
  image := TBGRABitmap.Create(ClientWidth,ClientHeight);
  hsla.lightness := 32768;
  hsla.alpha := 65535;
  for y := 0 to image.Height-1 do
  begin
    p := image.Scanline[y];
    hsla.saturation := y*65536 div image.Height;
    for x := 0 to image.Width-1 do
    begin
      hsla.hue := x*65536 div image.Width;
      pˆ:= HSLAToBGRA(hsla);
      inc(p);
    end;
  end;
  image.InvalidateBitmap; // changed by direct access

  image.Draw(Canvas,0,0,True);
  image.free;
end;

Overview

Fields

Public hue: word;
Public saturation: word;
Public lightness: word;
Public alpha: word;

Methods

Public class function New(const AHue,ASaturation,ALightness:word): THSLAPixel; overload; static;
Public class function New(const AHue,ASaturation,ALightness,AAlpha:word): THSLAPixel; overload; static;

Description

Fields

Public hue: word;

Hue of the pixel. The 6 primary colors red/yellow/green/cyan/blue/violet are stretched equally. Extremum values 0 and 65535 are red

Public saturation: word;

Saturation of the color. 0 is gray and 65535 is the brightest color (including white)

Public lightness: word;

Lightness of the color. 0 is black, 32768 is normal, and 65535 is white

Public alpha: word;

Opacity of the pixel. 0 is transparent and 65535 is opaque

Methods

Public class function New(const AHue,ASaturation,ALightness:word): THSLAPixel; overload; static;

This item has no description.

Public class function New(const AHue,ASaturation,ALightness,AAlpha:word): THSLAPixel; overload; static;

This item has no description.