1.9.9 • Published 1 day ago

@netlogo/netlogo-color-picker v1.9.9

Weekly downloads
-
License
ISC
Repository
-
Last release
1 day ago

Introducing the Color Picker Feature for NetLogo Web

This is a guide to the Color Picker feature for NetLogo Web. The Color Picker is a user interface that allows a user to explore and experiment with different colors, and finally select one. The selected color can then be provided to the program using the Color Picker in the form of a callback function. The Color Picker is still in the experimental stage, all feedback is welcome.

Usage

To integrate the Color Picker into your NetLogo Web project, start by installing the Color Picker npm package:

npm i @netlogo/netlogo-color-picker

After importing it into your project, you can create a Color Picker by calling the constructor. The ColorPicker class constructor accepts a single config object that contains the necessary properties for initialization:

  • parent: The HTML element that will host the Color Picker. This ensures the picker is embedded in the correct location in your UI.
  • initColor: The initial color selected in the Color Picker, expressed as an RGB array (e.g., [255, 0, 0] for red).
  • onColorSelect: A callback function that is invoked when a color is selected. This function should handle the selected color data. The returned color data is an array, where the first element is the selected color, and the second element is an array of the saved colors.
  • savedColors: An optional array of colors that the user can save for later use. Each color is also represented as an RGB array.

Here is a basic example of how to instantiate the Color Picker:

const colorPickerConfig = {
    parent: document.getElementById('color-picker-container'),
    initColor: [255, 255, 255], // Initial color as rgb (white)
    onColorSelect: (colorData) => {
        console.log('Selected color:', colorData);
    },
    savedColors: [[255, 0, 0], [0, 255, 0]] // Optional saved colors
};

const colorPicker = new ColorPicker(colorPickerConfig);

TypeScript

You can import import the ColorPickerConfig interface.

export interface ColorPickerConfig {
    parent: HTMLElement;
    initColor: number[];
    onColorSelect: (colorData: [number[], number[][]]) => void;
    savedColors?: number[][];
}

Feature Overview

The Color Picker consists of three modes: Grid, Wheel, and Slider. Each mode provides a different way of selecting colors.

  • Grid: Grid mode provides the standard NetLogo grid for selecting NetLogo colors. The grid contains cells of NetLogo colors from 0 - 139.9, moving up by a default of increment 1, which a user can change in the increment bar at the bottom of the feature.
  • Wheel: Wheel mode provides another way to select NetLogo colors, but with an inner and outer wheel. The outer wheel selects the base color for the outer wheel, and the outer wheel allows you to change the brightness of the base color. This provides a more intuitive way to select colors, especially on touch screens and mobile.
  • Slider: Slider mode comes in two sub-modes, RGB and HSL. This mode provides the traditional way of choosing a color by adjusting three sliders. You can choose an RGB color by specifying each individual value in the corresponding slider. Likewise, you can choose an HSL color in HSL mode in the same way. Additionally, you can access the saved colors tab in the Slider mode. The saved colors tab allows you to "save" a color by pressing the button with a + sign. This color is saved in one of the squares, and you can set the color back to this color by pressing on it.

Limitations

There are many limitations as this project is still in the experimental stage. As such, all feedback and contributions are welcome.

1.9.9

1 day ago

1.9.8

2 days ago

1.9.7

2 days ago

1.9.6

1 month ago

1.9.1

1 month ago

1.9.0

1 month ago

1.9.5

1 month ago

1.9.4

1 month ago

1.9.3

1 month ago

1.9.2

1 month ago

1.8.2

3 months ago

1.8.6

3 months ago

1.8.5

3 months ago

1.8.4

3 months ago

1.8.3

3 months ago

1.7.3

3 months ago

1.8.1

3 months ago

1.7.2

3 months ago

1.8.0

3 months ago

1.7.1

3 months ago

1.7.0

3 months ago

1.6.7

3 months ago

1.7.4

3 months ago

1.6.4

3 months ago

1.6.3

3 months ago

1.6.6

3 months ago

1.6.5

3 months ago

1.6.2

3 months ago

1.5.3

3 months ago

1.6.1

3 months ago

1.5.2

3 months ago

1.6.0

3 months ago

1.5.1

3 months ago

1.4.2

3 months ago

1.5.0

3 months ago

1.4.1

3 months ago

1.4.0

3 months ago

1.2.0

3 months ago

1.3.0

3 months ago

1.1.1

4 months ago

1.1.0

4 months ago

1.1.2

4 months ago

1.0.3

4 months ago

1.0.2

7 months ago

1.0.1

8 months ago

0.0.1

8 months ago