Log In  

Cart #okpal-3 | 2024-04-06 | Embed ▽ | License: CC4-BY-NC-SA
44

Okpal is a tool to create and edit color palettes. You can easily use those palettes in your programs, and even directly in Picotron's sprite and map editors.

Features

  • Any change to the palette is propagated to Picotron's sprite and map editors.
  • Use a perceptually uniform color space (oklab).
  • Choose colors by hue, saturation and lightness.
  • Reorder colors by drag-and-drop.
  • Supports two file formats: ".hex" and ".pal"
  • Multiple options for importing external palettes (keep default palette, overwrite it, or try to match it)

Usage

The tool shows you four different views of the 64 colors in the current palette:

  • at the top-left of the screen, the colors are shown in palette order (same as in sprite editor first tab);
  • below, on the left, the colors are shown inside a circle picker: the angle correspond to the hue, and the distance from the center correspond to the saturation;
  • in the middle the colors are shown as inside a square picker: the X axis correspond to the saturation, and the Y axis correspond to the lightness;
  • finally, on the right is a "test zone", where you can use 24 paintable cubes to test color combinations.

To modify a color, you must first select it. You can do that either by clicking in the palette overview at the top of the screen, or by clicking directly on one of the color dots in the circle picker or in the square picker.

Once selected, some information about the color are displayed on the right of the palette overview:

  • the color number;
  • the hex code corresponding to the RGB values of the color;
  • a padlock icon: if the padlock is closed, the color is "locked" and cannot be edited; click on the icon to lock/unlock it;
  • an eye icon: if the eye is closed, the color is only shown in the palette overview; it is hidden in the circle and square pickers.
  • a paint bucket icon: you can click on it to change the color background to the current selected color; click again to go back to a black background.

You can copy the current color by using Ctrl-C, and paste a copied color onto the current one by using Ctrl-V. This also works outside OkPal: the color is stored in the clipboard as a hex code ("#ffacc5").

There is five different ways to adjust the selected color:

  • a small colored circle outside the circle picker allows you to change the hue of the color;
  • a small colored circle inside the circle picker allows you to change at the same time the hue and the saturation;
  • a small colored triangle below the square picker allows you to change just the saturation;
  • a small colored triangle at the right of the square picker allows you to change the lightness;
  • finally, a small colored circle inside the square picker allows you to change at the same time the saturation and the lightness.

Any change you make can be reverted by hitting Ctrl-Z for undo. Use Ctrl-Y for redo.

Once you have several colors in you palettes, you can reorder them in the palette overview: just drag one color onto another, they will swap their positions. Note that both colors must be unlocked.

Using the palette in cartridges

By default, the palette you edit is saved in the cart you're working on, alongside your sprite sheets and maps.

The default path is "/ram/cart/pal/0.pal"

In order to use a palette in your programs, you just need to copy it in memory:

poke4(0x5000, get(fetch"/ram/cart/pal/0.pal"))

Loading and saving

If you only need one palette for your cart, you don't need to do anything special to save it. It is saved alongside the rest of your assets each time you hit Ctrl-S.

It's possible to work with multiple palettes, but it is a little clumsy, because it's not yet possible to fully integrate third-party tools with Picotron's interface.

In order to create a new palette, you cannot yet use the '+' button at the right of the tabs. Instead, you need to use "Save File As" in the menu, and choose the name of your new palette, for example "1.pal". If you need to start from scratch for this new palette, use "Empty Palette" or "Picotron Palette" from the menu.

To switch to another already created palette, choose "Open File" in the menu, but do not double-click on the file you want to open, as this do not work yet. Instead, you can drag and drop the file from the dialog onto OkPal's window, and it will open it.

Importing and exporting

You can import palettes from external tools. Currently the only supported format is ".hex" files, which are simple text files with one line per color, represented by their RGB code in hex format (without "#" or "0x" , just the hexadecimal numbers).

To import a palette, choose "Open File" from the menu, but do not double-click on the file. Instead, drag-and-drop the hex file onto OkPal's window. If this is the first time you open this external palette in OkPal, a dialog will appear to let you choose how to arrange the colors in the palette. You can either:

  • Keep default Picotron palette in the first 32 colors, and put the imported colors in the last 32 slots.
  • Completely remove the Picotron palette and import the whole palette, but reorder the colors to try to match the default colors.
  • Or simply import the palette as is. Note that this will affect the interface and probably make it difficult to use the menu, the sprite editor and the map editor.

Changelog

2024-04-06: version 1.0.0 (release #okpal-3)

  • propagate palette to sprite and map editors;
  • undo/redo;
  • reorder colors by drag-and-drop;
  • import dialog;
  • reorder imported colors to match default colors;
  • added a manual;
  • menu entries to initialize the palette and open
    the manual;
  • flash padlock icon when trying to edit a locked
    color;
  • shift-click paint-bucket icon to change the "white"
    color used in the interface, and ctrl-click the
    icon to change the "black" (useful when importing
    external palettes);

2024-04-02: version 0.0.3 (release #okpal-2)

  • Added the ability to change the background color (by clicking on the small paint bucket icon), and switched the default background to black.
  • Added the ability to import ".hex" files (using drag and drop from the "Open File" dialog); to actually create the ".pal" file, you need to save.
  • Improved the color pickers.
  • Added the ability to copy/paste colors (using a hex string starting with #).
  • Added the ability to show/hide individual colors (right click on a color in the palette).

2024-04-01: v0.0.1 (release #okpal-1)

  • Added the ability to lock colors, to avoid accidentally modifying them. By default the first 33 colors are locked (click on the padlock to unlock)
  • Added the ability to hide specific rows of color from the two color pickers.
  • Added sliders to change the individual components (hue, saturation and luminance).
  • Added the ability to select a color by clicking on their dot in the color pickers.
  • Added a test zone, with 24 paintable cubes (click on a cube face to change its color).
P#145244 2024-03-31 14:43 ( Edited 2024-04-06 08:58)

Post-Release Comments
3

I found how to propagate the palette to the sprite and map editors! This makes the tool much more immediately useful, as you can create your own colors and use them directly in Picotron's standard editors, and even go back and forth between OkPal and the editors to make some tweaks.

If other are writing color tools, here's how to do it:

send_message(gfx_pid, { event = "set_palette", palette = my_palette })

Where gfx_pid is the pid of the sprite editor; you can find it by fetching /ram/system/processes.pod, and searching for the entry with the correct name. And my_palette is just the userdata corresponding to the palette in memory (so type i32, 64 entries).

P#145881 2024-04-06 09:01 ( Edited 2024-04-06 11:08)

The RGB code doesn't include the alpha channel, right?

P#145898 2024-04-06 16:26

I think picotron just ignores the alpha value, but I haven't tested it.

P#145899 2024-04-06 16:30

This baby is in my startup.lua. That is all I have to say.

P#145956 2024-04-07 06:52

This is super useful! Its the kinda thing that works well built in with the other programs.

Do you think you could add exporting .hex? That'd be helpful because I'm trying to make an extended palette to use with https://www.lexaloffle.com/bbs/?pid=144322#p to make lighting work better. And I'm sure it would be useful for sharing to other platforms and such.

(oh just realized I can copy individual codes, but its still a bit of work to put those in a .hex file manually)

P#145995 2024-04-07 20:24

You can already export to .hex! Just use "Save File As" from the menu, and enter a name ending in .hex.

Maybe I should add an "Export" entry in the menu to make it more obvious? But that would still use the same file dialog, as this is not really customizable...

I also realized I forgot to explain the export feature in the manual...

P#146028 2024-04-08 05:45 ( Edited 2024-04-08 05:49)

Yeah it does ignore it, but if I make a text file for this, do I include it?

P#146184 2024-04-09 17:35

It's safer to not include any alpha channel. All the hex files I found online had only 6 digits, so this seem to be the standard.

P#146192 2024-04-09 19:05

I liked it, thank you for sharing.

P#146341 2024-04-11 06:31

i've cant wait to make my own palette but its to hard to use the mouse

P#146560 2024-04-13 19:04 ( Edited 2024-04-13 20:26)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-04-15 11:32:59 | 0.014s | Q:27