palCollection - palette collection library

Started by HydroNitrogen, Aug 23, 2018, 01:43 pm

Previous topic - Next topic


Aug 23, 2018, 01:43 pm Last Edit: Feb 05, 2019, 06:37 pm by HydroNitrogen

palCollection (Palette Collection) is a simple but powerful library that aims to be easy to use and can be implemented by other software.
palCollection brings new, popular, historic and beautiful palettes that have been seen in the real world in all kind of places to ComputerCraft.


palCollection is available on GitHub here. You can check out its repo, or download the library file directly by executing the following in your terminal:

Code Select
wget palCollection.lua


palCollection requires my other library palPal to function!
Please see this forum post to inquire more information about working with palPal.

Alternatively, you can just download palPal directly by executing the following in your terminal:

Code Select
wget palPal.lua


palCollection currently has 5 palettes.

  • default from Dan200/ComputerCraft The default palette that ComputerCraft has been using for years. Really old, and pretty ugly, yet a little nostalgic.
  • greyshades from HydroNitrogen A linear colour gradient starting from black (0) to white (1) in 16 steps.
  • zxspectrum from The ZX Spectrum (and compatibles) computers uses a variation of the 4-bit RGBI palette philosophy. This results in each of the colors of the 3-bit palette having a basic and bright variant, with the exception of black. The bright half of the palette is generated using the video display's maximum voltage levels for each of the three R/G/B color components that a color uses. The basic half of the palette is displayed by simply reducing these voltages.
  • solarized from Solarized is a sixteen color palette (eight monotones, eight accent colors) designed for use with terminal and gui applications. It has several unique properties. I designed this colorscheme with both precise CIELAB lightness relationships and a refined set of hues based on fixed color wheel relationships. It has been tested extensively in real world use on color calibrated displays (as well as uncalibrated/intentionally miscalibrated displays) and in a variety of lighting conditions.
  • onedark from A modified version of the dark Vim/Neovim color scheme for the GUI and 16/256/true-color terminals, based on FlatColor, with colors inspired by the excellent One Dark syntax theme.

You can view a more accecible version of the palette table here.


palCollection has a particular layout of variables. To harness palCollection's power, we must first load it into our environment by doing the following:

Code Select
local palCollection = require("palCollection")
Now we can access palCollection's

Code Select
-- palette tables (to be passed to palPal to load palettes)
-- for example:
 palCollection.palettes.solarized -- returns palette table { ... }

 -- palette colours (to be used as friendly names for referring in for example .setTextColour)
 -- for example:
 palCollection.colours.solarized.violet -- returns number 4096

 -- palette sources (where the palette colour data originated from)
 -- for example:
 palCollection.sources.solarized -- returns string ""

 -- note: en-us users can replace colour with color, but not grey with gray.

  • [icode]<palette>[/icode] refers to the name of a palette here, for example [icode]solarized[/icode] or [icode]default[/icode].
  • [icode]<colour>[/icode] refers to the name of a colour here, for example [icode]violet[/icode] (in solarized) or [icode]darkerWhite[/icode] (in greyshades).


palCollection's simpleness can be demonstrated using the following brief example to show the concept of loading a diffrent palette in and then drawing al it's colours.

Code Select
-- First we load palCollection and palPal into our environment
 local palPal = require("palPal")
 local palCollection = require("palCollection")

 -- Then we give 16 rows in the terminal unique background colours.
 local c, y = 1, 1
  term.setCursorPos(1, y)
  c = c * 2; y = y + 1
 until c > 32768

 -- Now we loop trough all diffrent palettes
 for name, palette in pairs(palCollection.palettes) do
  -- We load the palette into the term using palPal
  palPal.loadPalette(term, palette)
  -- And we wait for the user to press a key to continue to the next colour

 -- Then we restore the default palette again
 palPal.loadPalette(term, palCollection.palettes.default)

 -- Finally we clean up the terminal
 term.write("Thanks for viewing the palCollection demo!")

Executing the example will result in a slideshow of all palettes, trough which the user must continue by pressing keys.


palCollection is licenced under the MIT licence, Copyright (c) 2018 Wendelstein7 (a.k.a. HydroNitrogen)

You can definetely use this in your programs, I really recommend everyone doing so! You should make your programs that require it download the library from the raw GitHub link.
You are allowed to distribute this library yourself along with your other software that requires it (giving proper credit), but I strongly recommend downloading it from GitHub dynamically.
Please do collaborate on the ComputerCraft Wiki! Thanks!
Also like my post if you found it informative or helpful. This gets me to know what I should do more of. Thanks again!