Color Picker Guide

Table of Contents

Introduction

NetLogo 7 introduces a new, more powerful way of selecting colors, which replaces Color Swatches. As was the case previously there are four different contexts in which colors can be selected: from the Tools menu, from a Color Input widget, when selecting a plot pen color and when editing a Note. The ways in which the versions differ involve whether a selected color can be copied or “picked,” whether transparency is allowed, and what forms of input and output specifications are allowed, as will be described later.

For information on the different ways colors are represented in NetLogo see the Colors section of the NetLogo Programming Guide. The NetLogo primitives for working with colors are approximate-hsb approximate-rgb base-colors color extract-hsb extract-rgb hsb import-pcolors import-pcolors-rgb pcolor rgb scale-color shade-of? wrap-color. The Palette Extension offers additional ways to work with colors.

All versions of the Color Picker have two tabs, Simple, and Advanced. The Simple tab allows users to pick a color from a rectangular grid. This is analogous to the Color Swatches dialog, although it is more visually streamlined.

Simple Tab

The Simple tab of the Color Picker in the Tools menu has buttons to allow the user to copy the color (icon to the right of the grey rectangle), or exit the dialog (cancel).

As shown below Simple tab for the Color Input adds a blue ‘OK’ button to the right of ‘Cancel.’ Choosing ‘OK’ changes the Input to the selected color, exiting the dialog. ‘Copy’ puts the NetLogo Color number corresponding to the selected color in the clipboard. It can then be copied to the Code Tab, or any other text area. The dialog remains open. Cancel closes the dialog without changing the color input widget.

When editing a Note, there are four buttons that can be clicked to open a Color Picker.

The ‘Simple’ tab of the color picker is the same, regardless of context. The ‘Advanced’ tab allows different output formats, depending on the context.

The Advanced Tab

Introduction

The Advanced Tab allows a much more nuanced way to choose a color.

The rainbow slider on the left allows users to select a hue. The slider to its right allows the user to select the transparency of the color. By default, the color is fully opaque, and the knob is at the top of the slider, moving it down makes the color more transparent. You can also drag the small circle in the rectangle to the right of the sliders to quickly explore variants of the selected hue. Moving from it from left to right (horizontally) increases the saturation. Moving it bottom to top (vertically) increases the lightness.

Input Format

A powerful feature of the Advanced tab is that you can import colors using the following common formats RGB, RGBA, HSB, HSBA, HSL, HSLA and hexadecimal as well as NetLogo Number or NetLogo word. Use the Input Format pulldown menu to select the format and you will be able to set the appropriate value(s). The pulldown menu below shows the output options, which have the acronyms above spelled out. There follow two examples of specifying an input. For a NetLogo word there is a text field. For HSB (Hue, Saturation, Brightness) there are three numeric fields. The color selected using the Input format can then be modified by using the hue slider, transparency slider or the palette rectangle.

In this example the input is a NetLogo word.

In this example the input is HSB.

Output Format

The color that results after any adjustments can be output in the selected Output Format. The full list of output formats is NetLogo Number, NetLogo word and RGBA (Red, Green, Blue, Alpha). However in some contexts only a NetLogo Number can be output. As the user changes a color the value of the Input value is updated. In the image below it was initially lime - 0.3, but changed to lime - 0.6

Output Formats for Different Contexts

For the Color Input and plot pen colors the output format is a NetLogo number. Transparency is not supported for the Color Input in this release, but may be available in the future.

For Notes the output format is RGBA.

For the Tools menu Color Picker the output formats are NetLogo number, NetLogo word and RGBA.

Details about RGB Output

There is no explicit RGB output format. However when you select “RGBA”, and your color is opaque (maximum alpha), the result is RGB format - a 3-item list (no alpha). Otherwise “RGBA” output produces a 4-item list (with alpha). In the example below you can see that the output is a 3-item list, because there is no transparency and RGBA output is selected.

Details about the Alpha Bar

Some users may want to skip this section on first reading. The “alpha” bar of the Advanced tab is used to adjust the transparency of a color. If neither the input format nor the output format allows transparency the alpha bar will be hidden. The formats that do not allow transparency are: NetLogo number, NetLogo word RGB, HSB, and HSL. If the input supports alpha, but the output does not, the output dropdown will be highlighted and will have a tooltip that explains that the output color will be opaque. The first example shows the case where there is no alpha bar. The second example show the highlighted output because there is transparency, but an opaque output format.