Merge branch 'master' into Doodle

This commit is contained in:
Sharoy Veduchi 2023-06-27 21:08:56 -07:00 committed by GitHub
commit 4f05d5ae80
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 49 deletions

View file

@ -1,4 +1,5 @@
Cd(__DIR__);; Cd(__DIR__);;
#define PALETTES_PATH "~/PaletteEditor/Palettes/" #define PALETTES_PATH "~/PaletteEditor/Palettes/"
#include "PaletteSelect" #include "PaletteSelect"
#include "PaletteGod"
#include "PaletteEdit" #include "PaletteEdit"

View file

@ -38,13 +38,10 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
CSliderState *s = c->state; CSliderState *s = c->state;
I64 size = (c->win_task->pix_width / 16), I64 size = (c->win_task->pix_width / 16),
border = size / 16,
size2 = (c->win_task->pix_height / 32), size2 = (c->win_task->pix_height / 32),
// slider_amount = 3, i,
i, k, j,// l,
pos, col, pos, col,
bias; bias;
CBGR24 tempColor;
/////////////////////// ///////////////////////
// CURRENT SELECTION // // CURRENT SELECTION //
@ -53,17 +50,8 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
// current color box preview // current color box preview
dc->color = BLACK; dc->color = BLACK;
GrPrint(dc, 10, 10, "Preview:"); GrPrint(dc, 10, 10, "Preview:");
GrPrint(dc, 10, 26, "Current Color: #%d", selected_color);
// pixel loop for current color preview
for (i = 0; i <= 12; i++)
for (j = 0; j <= 12; j++)
{
tempColor = gr_palette[selected_color];
if (i < border || i > 12 - border || j < border || j > 12 - border)
tempColor = 0x000000;
DrawPixel(c->win_task->pix_left + 78 + i, t + 7 + j, tempColor);
}
GrPrint(dc, 10, 26, "Current Color: #%d", selected_color + 1);
if (selected_color == 15) if (selected_color == 15)
dc->color = LTGRAY; dc->color = LTGRAY;
else if (gr_palette[selected_color] > 0xCCCCCC) else if (gr_palette[selected_color] > 0xCCCCCC)
@ -72,7 +60,9 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
dc->color = 15; dc->color = 15;
GrRect(dc, 94, 8, 58, 12); GrRect(dc, 94, 8, 58, 12);
// #Hex value
dc->color = selected_color; dc->color = selected_color;
GrRect(dc, 78, 8, 12, 12);
GrPrint(dc, 95, 10, "#%x%x%x", gr_palette[selected_color].r, GrPrint(dc, 95, 10, "#%x%x%x", gr_palette[selected_color].r,
gr_palette[selected_color].g, gr_palette[selected_color].g,
gr_palette[selected_color].b); gr_palette[selected_color].b);
@ -152,23 +142,6 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
for (i = 0; i < COLORS_NUM; i++) for (i = 0; i < COLORS_NUM; i++)
{ {
for (j = 0; j <= size; j++)
{
for (k = 0; k <= size; k++)
{
tempColor = gr_palette[i];
// black borders
if (k < border || k > size - border || j < border || j > size - border - 1)
{
if (selected_color == i)
tempColor = 0xFFFFFF;
else
tempColor = 0x000000;
}
// color preview
DrawPixel(c->win_task->pix_left + j + (size * i), c->win_task->pix_bottom - size * 1.5 + k, tempColor);
}
}
// color label and text preview // color label and text preview
// TODO: THIS LOGIC DOESNT WORK ON LIGHT THEMES // TODO: THIS LOGIC DOESNT WORK ON LIGHT THEMES
// if color too light or too dark add bg // if color too light or too dark add bg
@ -183,6 +156,7 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
dc->color = LTRED;*/ dc->color = LTRED;*/
else else
dc->color = 15; dc->color = 15;
if (i == selected_color) if (i == selected_color)
dc->color = 0; dc->color = 0;
GrRect(dc, 6, (size2 * 2) + 65 + 16 * i, 80, 18); GrRect(dc, 6, (size2 * 2) + 65 + 16 * i, 80, 18);
@ -195,11 +169,18 @@ U0 DrawCtrlSlider(CDC *dc, CCtrl *c)
dc->color = 15; dc->color = 15;
else else
dc->color = i; dc->color = i;
bias = (size / 2) - 4; bias = (size / 2) - 4;
if (i >= 9) if (i >= 9)
bias = (size / 2) - 8; bias = (size / 2) - 8;
GrPrint(dc, bias + (i * size), c->win_task->pix_height - (size * .6) + (size / 4), "%d", i + 1);
GrPrint(dc, 10, (size2 * 2) + 70 + 16 * i, "#%d: Test", i + 1); GrPrint(dc, bias + (i * size), c->win_task->pix_height - (size * .6) + (size / 4), "%d", i);
GrPrint(dc, 10, (size2 * 2) + 70 + 16 * i, "#%d: Test", i);
// Border for preview box
GrRect(dc, (size * i)-2, c->win_task->pix_height - (size*1.5)-1, size+2, size+1);
// preview box
dc->color = i;
GrRect(dc, (size * i), c->win_task->pix_height - (size*1.5), size, size);
} }
@ -373,12 +354,15 @@ public U0 PaletteEditor()
" PreviousColor(,,SC_CURSOR_UP);" " PreviousColor(,,SC_CURSOR_UP);"
" NextColor(,,SC_CURSOR_RIGHT);" " NextColor(,,SC_CURSOR_RIGHT);"
" NextColor(,,SC_CURSOR_DOWN);" " NextColor(,,SC_CURSOR_DOWN);"
" RandomColor(,'r');"
" RandomPalette(,'R');"
"}" "}"
"About {" "About {"
" Info(,CH_CTRLI);" " Info(,CH_CTRLI);"
"}" "}"
); );
DocClear; DocClear;
DocCursor(OFF);
WinBorder(ON); WinBorder(ON);
CCtrl *c = SliderNew; CCtrl *c = SliderNew;
@ -442,6 +426,13 @@ public U0 PaletteEditor()
current_palette = ""; current_palette = "";
current_palette = PaletteSelect; current_palette = PaletteSelect;
break; break;
case 'r':
gr_palette[selected_color] = ColorGod;
LFBFlush;
break;
case 'R':
PaletteGod;
break;
case CH_CTRLI: case CH_CTRLI:
PopUpOk("\n\n Use the arrows to select color\n\n # to manually input hex value","\n\n\n\t\tMade by y4my4m\n\n"); PopUpOk("\n\n Use the arrows to select color\n\n # to manually input hex value","\n\n\n\t\tMade by y4my4m\n\n");
break; break;

View file

@ -1,15 +1,18 @@
CBGR24 ColorGod(Bool instant=TRUE)
public U0 PaletteGodGenerate() {// Generate a random color, seed-based or not
{ if (instant)
I64 i; return RandI32 & 0xFFFFFF;
CBGR24 palette; else
return GodPick & 0xFFFFFF;
for (i = 0; i < 16; i++)
{
palette = GodPick & 0xFFFFFF;
gr_palette[i] = palette;
LFBFlush;
}
} }
PaletteGodGenerate; public U0 PaletteGod(Bool seedUse=FALSE, Bool instant=TRUE)
{// Generate a random palette, seed-based or not
I64 i;
if (seedUse) Seed(GodPick);
for (i=0; i < 16; i++)
gr_palette[i] = ColorGod(instant);
LFBFlush;
}

View file

@ -0,0 +1,10 @@
public CBGR24 gr_palette_tradition[COLORS_NUM] = {
0xE8E8E9, 0x374B88, 0x4FBC2C, 0x29CACE, 0xDD0000, 0x8C33FF, 0x875721, 0x7F7A7C, 0x15171C, 0x2EA1FF, 0x4FFF00, 0xFFBB, 0x690000, 0x6E3FFC, 0xFFCC00, 0xC0F14
};
public U0 PaletteSetTradition(Bool persistent=TRUE)
{
GrPaletteSet(gr_palette_tradition);
LFBFlush;
if (persistent)
fp_set_std_palette = &PaletteSetTradition;
}