MatchColorSet v1

8 views
Skip to first unread message

Carlo Hogeveen

unread,
Jul 26, 2023, 9:48:49 AMJul 26
to Semware @ GoogleGroups

 

Nerd alert!

I also had a go at automatically matching 16 input colors with TSE's 16 standard color(name)s, and also failed, though in an expected and not yet solved way.

 

https://ecarlo.nl/tse/DemosAndTests.html#MatchColorSet

 

The example below (Sammy’s first request) excellently demonstrates the remaining problem, caused by the tool's aggression and short-sightedness.

The tool first links the two closest matching colors, then for the remaining colors it links the next two closest matching colors, and so on.

It therefore links a new grey color to TSE's very close dark grey color, and then is stuck with linking a new darker grey color to TSE's light grey color.

Given that there are 16! (16 factorial = 21 trillion) color set combinations possible, trying them all is not an option.

I do have a glimmer of an idea for a generic solution, which I am going to let simmer, but may not implement.

For now any next version of this tool is postponed indefinitely.

 

Carlo

 

 

TSE Name

TSE Color

Closest Matched Input Color

_BLACK_

000000 - RGB( 0, 0, 0)

000000 - RGB( 0, 0, 0)

_BLUE_

000080 - RGB( 0, 0, 128)

220077 - RGB( 34, 0, 119)

_GREEN_

008000 - RGB( 0, 128, 0)

007722 - RGB( 0, 119, 34)

_CYAN_

008080 - RGB( 0, 128, 128)

227788 - RGB( 34, 119, 136)

_RED_

800000 - RGB(128, 0, 0)

660033 - RGB(102, 0, 51)

_MAGENTA_

800080 - RGB(128, 0, 128)

770088 - RGB(119, 0, 136)

_BROWN_

808000 - RGB(128, 128, 0)

996600 - RGB(153, 102, 0)

_LIGHT_GRAY_

C0C0C0 - RGB(192, 192, 192)

444455 - RGB( 68, 68, 85)

_DARK_GRAY_

808080 - RGB(128, 128, 128)

777799 - RGB(119, 119, 153)

_LIGHT_BLUE_

0000FF - RGB( 0, 0, 255)

3322FF - RGB( 51, 34, 255)

_LIGHT_GREEN_

00FF00 - RGB( 0, 255, 0)

00FF33 - RGB( 0, 255, 51)

_LIGHT_CYAN_

00FFFF - RGB( 0, 255, 255)

22EEFF - RGB( 34, 238, 255)

_LIGHT_RED_

FF0000 - RGB(255, 0, 0)

FF0033 - RGB(255, 0, 51)

_LIGHT_MAG_

FF00FF - RGB(255, 0, 255)

FF33DD - RGB(255, 51, 221)

_YELLOW_

FFFF00 - RGB(255, 255, 0)

FFEE33 - RGB(255, 238, 51)

_WHITE_

FFFFFF - RGB(255, 255, 255)

FFFFFF - RGB(255, 255, 255)

 

 

knud van eeden

unread,
Jul 26, 2023, 10:33:39 AMJul 26
to Semware @ GoogleGroups
That color result looks really good.

with friendly greetings
Knud van Eeden

--

---
You received this message because you are subscribed to the Google Groups "SemWare TSE Pro text editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to semware+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/semware/004901d9bfc7%24e5bf7ff0%24b13e7fd0%24%40ecarlo.nl.

knud van eeden

unread,
Jul 26, 2023, 10:36:46 AMJul 26
to Semware @ GoogleGroups
As a side note: FYIO (not related)

knud van eeden

unread,
Jul 26, 2023, 1:07:48 PMJul 26
to Semware @ GoogleGroups

For the interested other reader:


>> Describe this TSE SAL program:

> ChatGPT

This is a Text Editor Scripting Language (TSE SAL) script for The SemWare Editor (TSE). It is written to match a set of 16 input colors to TSE's standard 16 colors. 

The high-level functionality of the script can be summarized as follows:

1. **Input**: The input to the script is a list of 16 or 32 colors in a buffer. Each color should be on a new line. Colors can be in various formats such as hexadecimal (e.g., `0x0099ff` or `#0099ff`) or RGB (e.g., `rgb(0, 153, 255)`). If 16 colors are provided, the script will match them with TSE's set of standard 16 colors. If 32 colors are provided, it will match the first 16 input colors with the last 16 reference colors. 

2. **Calculating Differences**: The script calculates the differences between all 16 input colors and all 16 standard or reference colors. This is done by considering the RGB color values as three-dimensional coordinates and calculating the distance between these coordinates for each pair of colors.

3. **Matching Colors**: The script identifies the closest match between the input and standard or reference colors by finding the pair with the smallest calculated distance. This process is repeated until all colors are matched.

4. **Output**: The script generates an HTML file that presents the matched colors in a table. The user is asked whether they want to open the HTML file in their default web browser.

5. **Error Handling**: The script addresses two potential errors: one related to the equal treatment of RGB components when calculating color differences (which can distort perception of brightness), and the other related to the algorithm's aggressive approach to linking colors based on smallest differences (which can lead to bad matches).

The script also includes a number of utility functions, such as functions to calculate the square root of a number (since TSE does not have a built-in function for this), to calculate the square of a number, and to calculate the distance between two points in three-dimensional space (used for the color comparison). 

The script is compatible with Windows TSE v4.4 and above. To use it, the script file should be placed in TSE's "mac" directory and compiled there.

with friendly greetings
Knud van Eeden
On Wednesday, July 26, 2023 at 03:48:55 PM GMT+2, Carlo Hogeveen <t...@ecarlo.nl> wrote:


--

S.E. Mitchell

unread,
Aug 24, 2023, 5:58:05 PMAug 24
to sem...@googlegroups.com
Thanks for doing this!
I have added this one to SetPalette.
--
Sammy Mitchell

--
Reply all
Reply to author
Forward
0 new messages