Log In  


Cart #okpal-10 | 2025-03-18 | Embed ▽ | License: CC4-BY-NC-SA
91

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.

To use a palette in your programs:

	fetch("pal/0.pal"):poke(0x5000)

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)

Changelog

2025-03-18: version 1.2.1 (release #okpal-10)

  • Added: "Export File" menu entry to save a copy of the current file without opening it.
  • Changed: ".hex" files are saved without metadata.
  • Changed: dragging color dots is much more precise.
  • Changed: constrain color changes along an axis when dragging a color dot
    using the right or middle mouse buttons (instead of holding "shift" or "control").
  • Changed: bigger color dots, easier to grab.
  • Changed: propagate palette to sprite and map editors only when focus is lost.
  • Changed: Don't automatically register as default app for ".pal" and ".hex".
  • Fixed: bug in opening files (due to bug in picotron's wrangle.lua since 0.1.1e)
  • Fixed: reset display palette rows when hiding the color band.


2025-03-13: version 1.2.0 (release #okpal-9)

  • Added: new alternate view with hue/lum and hue/sat pickers.
  • Added: hold "shift" or "ctrl" when dragging a color dot to constrain the change along one axis.
  • Added: ability to scroll the hue axis of the alternate view, either with the scroll wheel or the dedicated control at the bottom of the screen.
  • Added: color names in the alternate view.
  • Added: color band in the alternate view.
  • Added: settings to hide the color names and color band.
  • Changed: simplified the old view (remove color lines on the 1D sliders)

2025-03-08: version 1.1.0 (release #okpal-8)

  • removed remapping option when importing ".hex" palettes (was not working very well anyway);
  • added text entries for the hex code, the hue, the saturation and the luminance;
  • added a new tab for drawing color ramps in the test zone;
  • added dialog when creating a new palette (to choose between empty palette or default colors);
  • added settings dialog;
  • added settings to register OkPal as default app for ".pal" and ".hex" files;
  • added settings for disabling the propagation of the palette to the sprite and map editors;
  • changed dialog when importing ".hex" files;
  • changed dialog for displaying help;
  • fixed menu bar colors when default colors are redefined;
  • fixed undo/redo of test cube color changes;

2025-02-26: version 1.0.4 (release #okpal-7)

  • added registering as default app for ".pal" and ".hex" (needed for the file dialog?)
  • added undo/redo and help buttons;
  • added "clear" button to the "test cubes";
  • added legends for the two pickers;
  • changed: moved the luminance slider to the left of the sat/lum picker for consistency;
  • fixed: palette is now propagated to all gfx and map editors (thanks to Eiyeron for the implementation);
  • fixed: the "test cubes" saved in metadata where not properly loaded;

2024-08-23: version 1.0.3 (release #okpal-6)

  • added: add file icon to saved palettes;
  • changed: can load and import palettes by
    double-clicking in the file dialog (no need
    to drag-and-drop anymore);
  • fixed: bug in BBS;

2024-05-03: version 1.0.2 (release #okpal-5)

  • fixed: bug while using "+" button in Picotron
    0.1.0g;
  • changed: disabled tabs in BBS, as it prevents
    the cart from running;

2024-04-27: version 1.0.1 (release #okpal-4)

  • fixed: picotron's palette was not locked in the
    default file on first opening;
  • fixed: saving a ".pal" file from an imported
    ".hex" file was not working;
  • explain how to export to .hex in the manual;

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).
91


All Comments

This looks super promising.


Very nice palette editor! and I think the userdata format you've chosen is probably ideal.
I added the ability to import and export your pal format to some of my apps to be compatible with this.


Thanks! I was just playing with your #paint cartridge! And by taking a look at your code, I figured how to add support for loading a palette by drag-and-drop (using the "drop_items" event).


would be lovely to offer the option to save as hex file
(text file, one colour per line, hexadecimal format without leading #)

example from lospec: https://lospec.com/palette-list/the-cosmos.hex

this is easy to convert with tonum in order to poke into picotron


Yes, it's planned! In the last version, you can already import hex files (by using the "Open File" dialog from the menu; note that you can't double click to open the files, you have to drag-and-drop them onto the application window).

I need to add an import dialog (to configure if you want to replace the default palette or just use the last 32 colors), and an export option in the menu.


This is brilliant! I love how it adds an icon to the toolbar and integrates nicely with the desktop. And the editor itself is lovely. Great work!

Feature request: the ability to simply cut and paste the resulting hex code for the color shown ... sometimes I just want to get that single color into my code really quickly.

Thanks for your work drakmaniso!

edit: woops ... just noticed this feature has already been added! Excellent!


love this, im currently workign on a 64 palette, would be interesting to see in this tool


I'm working on improving the import functionality. The problem with editing 64 colors palettes in OkPal is that it will overwrite the colors used by Picotron's GUI, which can make it difficult to find the "save" item in the menu...


4

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).


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


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


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


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)


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...


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


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.


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


1

I wonder if we will then use this system to create your own games, including those with a changed palette ?


this is a tool for editing! inside a game, we can always change the 64 colours of the palette, this program is not needed


when OkPal is open, if i load a new cart to ram it closes the current working palette. is there a way for it to then automatically open 0.pal for the new loaded cart?

also, it would be really neat if when saving a .pal, it would save this as metadata for the file icon!

userdata("u8",16,16,"0001010101010101010101000000000000010707070707070707060100000000000107070707070707070606010000000001070707070707070706060601000000010707070707070707060606060100000107070707070707070707070701000001070707070707070707070707010000010707060601010d0d01010707010000010707060601010d0d010107070100000107070101070706060d0d07070100000107070101070706060d0d07070100000107070d0d01010d0d060607070100000107070d0d01010d0d060607070100000107070707070707070707070701000001070707070707070707070707010000010101010101010101010101010100")


@merwok What what what?? How do you change the palette the normal way then?


Wow, it's definitely nice to be able to export as a .pal file!
If .pal files were included in the standard cart configuration, we'd be able to easily reuse, share, and manage palettes.


@Baulers
"How do you change the palette the normal way then?"
pal(color_num, 0xrrggbb, 2) --2 is rgb mode


3

@drakmaniso, could you please give more details on how to get the colors into the tile and map editors?

I'm not entirely sure how to "fetch" the pid from /ram/system/processes.pod. Also not sure what my_palette should actually be.


yeah that's cool!!!!!
i used a system like in
https://www.lexaloffle.com/bbs/?tid=143591


1

I have been using this tool a lot and it is extremely helpful. For me, a couple of things would make it even better:

  1. provide a way to enter #rrggbb by hand as well as allowing pasting of the values
  2. Allow setting HSV and RGB values by typing them in individually

But really, thank you for creating this. even if you don't decide to take on my suggestions or they are unworkable.


I have a problem, after saving my program which uses 32 additional edited colors. When I reload my program again, it says at the bottom in the terminal: 'file not found' and my 32 new colors are not displayed. I have to reload okpal, add the new palette which contained my 32 new colors so that they are re-displayed in the editor. However, I added the palette at the start of my program (poke4(0x5000, get(fetch"/ram/cart/pal/0.pal")). I don't understand why?


4

Hello. As someone was complaining about not seeing the palette's changes reflected in all instances of map.p64 and gfx.p64, I made a quick fork to send the set_palette event to all related processes.

I also slapdashed an in-program help viewer to replace the text editor window opening, which might fall behind the workspace and be kept opened forever until a shutdown or a reboot.

The fork is there. I haven't fully tested my changes, I'm mostly posting it to give to @drakmaniso the code if they want to integrate it or part of it.

Have a nice day!

Cart #eyn_okpal_fork-0 | 2024-11-25 | Embed ▽ | License: CC4-BY-NC-SA
4


Cool! Is it possible to get this program onto Picotron from BBS? I really want to use this for my future projects.


@Retro_Pup_Pico_8 Yep! Just type load #okpal and the you can use save whatever to save it.


It says "file type not found." Any way I can get the file from BBS?
I love this program and really wanna use it.


For me load #okpal-7 worked


This is amazing to me.
Thank you so much.
Excellent work.



[Please log in to post a comment]