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.



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



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



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!



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



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


I have been using this tool a lot and it is extremely helpful. For me, a couple of things would make it even better:
- provide a way to enter #rrggbb by hand as well as allowing pasting of the values
- 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?



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!



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



It says "file type not found." Any way I can get the file from BBS?
I love this program and really wanna use it.
[Please log in to post a comment]