English

How To: Create a custom color palette using Avenue

Summary

This article provides sample Avenue code for creating a custom color palette file (.avp).

Procedure

  1. Open a new script window.

    A. Activate the Project window.
    B. Click the Scripts icon.
    C. Click New.

  2. Copy the code into the new script window.
    Code:
    'Create Custom Color Palette
    'Creates an Object Database file to store the colors in
    defName = FileName.Make("$AVHOME/symbols").MakeTmp("mycolors","avp")
    theODBfile = FileDialog.Put(defName,"*.avp","Save Color Palette As")
    myODB = ODB.Make(theODBfile)

    'Create a symbol list and add colors to it
    'Colors are defined by their RGB (Red, Green, Blue) values.
    'Modify the RGB values to the RGB values of the colors you want to add
    aSymbolList = SymbolList.Make
    for each i in 0..255 by 5
    myColor = Color.Make
    myColor.SetRGBList({0,255,i})
    aSymbolList.Add(myColor)
    end

    'Create a palette, add the symbol list to the palette and save to the file
    myPalette = Palette.Make
    myPalette.SetList(#PALETTE_LIST_COLOR, aSymbolList)
    myODB.Add(myPalette)
    myODB.Commit


  3. Compile the script by clicking the compile button.
    [O-Image] Script compile button
  4. Run the script by clicking the run button.
    [O-Image] Run compiled script button