goldenXcode / grafx2

Automatically exported from code.google.com/p/grafx2
0 stars 0 forks source link

Auto palette-layout #509

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
A checkbox to enable automatic palette layout (row & column number) based on 
the colours used.

Upon loading an image, the program would count the colours from index 0 to 
highest used index, and adjust the layout to show all colours.

Alternatively, it could count up to highest non-black colour instead of highest 
used colour.

"Auto-layout" checkbox could be situated on the "Palettes" popup.

Original issue reported on code.google.com by ilija.melentijevic on 26 Sep 2012 at 12:32

GoogleCodeExporter commented 9 years ago
Well for 40 colors exactly, I don't know if you'll prefer 40x1, 20x2, 10x4, 
8x5, 5x8...
Sounds like the most comfortable option would be a lists of presets, sorted by 
color count ex:
8x8 (64)
4x4 (16)
4x1 (4)
Then grafx2 can run up the list until it finds a setting that can include all 
image colors. For example in the case above, a 8-color image would use the 4x4 
setting.
If none fits, it picks the biggest one : it can scroll anyway.

Original comment by yrizoud on 26 Sep 2012 at 2:42

GoogleCodeExporter commented 9 years ago
I never did it, but my idea was to find a setting that allows the color 
swatches to be as square as possible, given the range to display and the 
available space in the menu.
The algorithm is not too complicated:
 * Let H,W be the size of the available palette space
 * Start with one line of N colors. Compute h = H/N, w = W/1. Ratio[1] = w/h = W*N/H
 * Try with 2 lines of (N+1)/2 colors. h = 2H/N, w = W/2. Ratio[2] = w/h = WN/4H
 * If ratio is less than 1, compute Ratio[2] = 4H/WN instead.
 * If Ratio[2] > Ratio[1], Ratio[1] is optimal.
 * Else, try with 3 lines of (N+1)/3 colors...
 * Stop when we reach N lines (we shouldn't ever, because W > H).

Original comment by pulkoma...@gmail.com on 26 Sep 2012 at 7:49

GoogleCodeExporter commented 9 years ago
Hmm yes I'm not 100% sure how effective autolayout would be, but I work on 
pieces ranging anywhere from 4 to 100+ colours and since these things are not 
saved per project I always have to set the palette layout by hand when I switch 
projects. Even if auto-layout is not super-flawless it would still hopefully 
give a very practical result.

If it's any help, I find that if cells can't be square, it's usually better for 
them to be slightly wider than slightly taller :)

Original comment by ilija.melentijevic on 26 Sep 2012 at 10:50