GreycLab / gmic

GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing
Other
66 stars 11 forks source link

(Feature Idea) Literals to affect inputs #42

Closed Reptorian1125 closed 4 months ago

Reptorian1125 commented 5 months ago

I just have a idea to extend the usage of binary/hex literals outside of the math parser.

Syntax:

-0x(100,200)

This would be equivalent of

(256,512)

The reason I think this is a good idea is that some languages use hexadecimal to generate palettes. At the moment, we have to do a little bit of finicky thing to bypass the issue of conversion.

Some other suggestion for syntax:

-0x3(AABBCC,DDEEFF)

The number after -0x tells us the number of channels in the output image. So, first pixel is #AABBCC.Yes, this would mean ^ wouldn't be allowed, but for simplicity of conversion, this is fine. Other characters are permitted like [ , ] or [ / ] or [ ; ]. And of course, to enforce the numbers of characters. So, 3 would means 6 characters for each numbers, 4 would mean 8 characters, and so forth.

The reason for -0x is that 0x is reserved for numbers of 0x0x0x0 image.

And of course, you can extend this concept to binary like -0b() or -0bN() where N is the number of channels. You could argue of -0dN() for decimals, as it can be done too and it can be even easier to work with too.

Some catch is that this might require c-koi to make new color dialogs for each cases and they output 1 string variable per color. This would simplify the process of making palettes with GUI. prawnsushi for example struggled with inputs, and this alleviates that issue.

Reptorian1125 commented 4 months ago

Another development for this idea it seems that ~ might be preferable to - because of ${-command} thing, and ~ seems to be unused.

In addition, this can be extended to base64 as well. base642uint8 $1 can be replaced with ~b64($1). That's better because it's a single variable argument which makes some things possible.

dtschump commented 4 months ago
Reptorian1125 commented 4 months ago

~ operator is not used outside the math parser, and this idea goes outside of it.

Same. However, this is more for making GUI scripting easier with new color dialog that outputs one variable only, and it simplifies input image creation by eliminating the need of ^ as well as GUI development by not needing as much variable named. If you look at say, Transfer Color [Reduced Colors], there's 1300+ variables and that in my mind is iffy. So, with this and new color dialog that outputs one variable, a lot less variables is needed. So, probably only ~0d(N?)() is needed for this to work. N basically does similar thing to int2rgb, so N>1 outputs colors.