4D v13

PV Color to index

Home

 
4D View v13
PV Color to index

PV Color to index 


 

PV Color to index ( color ) -> Function result 
Parameter Type   Description
color  Longint in Color number
Function result  Integer in Indexed color number

The PV Color to index command returns the number of the specified RGB color in the default 4D color palette. 4D's indexed colors range from 0 to 255.

Refer to the descriptions of the following 4D commands for detailed information on the RGB colors used by 4D:

Example  

This method sets in cell A1 the background color set by the RGB values (0 to 255) entered in cells A2, A3, and A4. The C1 cell displays the number of the index color closest in the 4D palette — with the ad hoc background color — while cells C2, C3, and C4 display the RGB values corresponding to this indexed color, which then illustrates the difference between the starting values.

 C_LONGINT($Color`Background color for A1 (RGB) then color after indexing
 C_INTEGER($Red;$Green;$Blue`RGB colors at the start and when finished
 C_INTEGER($Index`Number in the 4D palette
 
 PV SET CELL STRING VALUE(Area;2;1;"Color") `Labels
 PV SET CELL STRING VALUE(Area;2;2;"Red")
 PV SET CELL STRING VALUE(Area;2;3;"Green")
 PV SET CELL STRING VALUE(Area;2;4;"Blue")
 
 $Red:=PV Get cell num value(Area;1;2) `Starting RGB colors
 $Green:=PV Get cell num value(Area;1;3)
 $Blue:=PV Get cell num value(Area;1;4)
 
 $Color:=PV RGB to color($Red;$Green;$Blue)
 PV SET CELL PROPERTY(Area;1;1;pv style color back odd;$Color`Assign A1 background
 
 $Index:=PV Color to index($Color`"Indexing"
 PV SET CELL NUM VALUE(Area;3;1;$Index`Number in the 4D palette
 $Color:=PV Index to color($Index`New color
 PV SET CELL PROPERTY(Area;3;1;pv style color back odd;$Color`Assign C1background
 
 PV COLOR TO RGB($Color;$Red;$Green;$Blue`Decompose
 PV SET CELL NUM VALUE(Area;3;2;$Red`RGB colors after "indexing"
 PV SET CELL NUM VALUE(Area;3;3;$Green)
 PV SET CELL NUM VALUE(Area;3;4;$Blue)

 
PROPERTIES 

Product: 4D
Theme: PV Tools
Number: 15861

 
INDEX

Alphabetical list of commands

 
HISTORY 

Created: 4D View 6.8

 
SEE ALSO 

PV Index to color