(OLD) (ARCHIVED) Puppy Linux Discussion Forum Forum Index (OLD) (ARCHIVED) Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info

This forum can also be accessed as http://oldforum.puppylinux.com
It is now read-only and serves only as archives.

Please register over the NEW forum
https://forum.puppylinux.com
and continue your work there. Thank you.

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Mon 21 Sep 2020, 06:54
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Listing all color names
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
Page 2 of 3 [43 Posts]   Goto page: Previous 1, 2, 3 Next
Author Message
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Fri 15 Feb 2019, 22:33    Post subject:  

vovchik wrote:
I have added a self-contained icon and copy the selection result to the clipboard in this little mod.
Thank you. Great artwork - as always.

As for sending output to clipboard I see some issues.

- Adding to step's observation I would go further. IMO any overwriting of the clipboard should require the explicit consent of the user. Could be done with an extra button. Normally the GtkColorChooser writes to stdout (which your mod still does), but additionally writing to clipboard might be regarded as unexpected and unwanted.

- Some Puppies use xsel instead of xclip. Should be considered when coding clipboard interaction.

- Color hex values can already be easily selected and copied from the "Color name" field of the GtkColorChooser, so I don't see a need to make copying easier or even compulsory. On the other hand there is no way to copy the names Crying or Very sad (well, not with GtkColorChooser but with MochiMoppel's "waste of time" scripts Wink )

- The GtkColorChooser already has a dedicated clipboard: the 20-field color palette. A bit feeble as the palette can not be saved but useful as long as the application is not closed (e.g. see implementation in Geany).

Instead of writing to the clipboad I think writing to a custom palette file would be a better feature. Yad can optionally return the decimal values instead of the hex values, though in a format that needs further tweaking. I don't know if for yad such saving and ideally updating the color name list is possible while keeping the dialog open, but at least it should be possible after dismissing the dialog.
Back to top
View user's profile Send private message 
tlchost

Joined: 05 Aug 2007
Posts: 2111
Location: Baltimore, Maryland USA

PostPosted: Sat 16 Feb 2019, 07:47    Post subject: foregound/background  

What would be very helpful for folks developing web pages would be a way of manipulating the values of foreground and background colors and viewing the result on the screen...it could avoid unfortunate combinations like white/yellow or black/blue [/i]
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Tue 19 Feb 2019, 01:32    Post subject:  

OK, here is my prototype for a yad color picker with save capability.
This capability is not meant for X11 colors and therefore slightly off-topic. Since X11 colors should not be messed with and mixed with other names, the save option is disabled for /usr/share/X11/rgb.txt but can be useful to create/read custom color palettes.

How to run the script:
1) Create a new file for the colors you are going to save. Example: File name mycolors.gpl in directory /root/.config/mm_yadcolors/.
The first line of the file should read "GIMP Palette" (mandatory for use in mtPaint) and the following lines should contain the palette name and one or more comments, starting with #
The content would look like this:
GIMP Palette
Name: My favorite colors
#


2) Run below script (let's call it mm_yadcolors) as
Code:
mm_yadcolors  /root/.config/mm_yadcolors/mycolors.gpl

This should open the yad colorpicker with an empty color list and a "Save" button to save your custom colors.
If mm_yadcolors is run without a palette file as argument, the script will open /usr/share/X11/rgb.txt . No "Save" button.

The script saves the last used color and the last used window geometry to the /tmp directory. Change to the .config directory if these values need to survive a reboot.

[Update 2019-2-21] Added support for mtPaint/GIMP palette format.
[Update 2019-2-23] Removed demo code from script and reworded explanation.
[Update 2020-3-29] Fixed issue with newer yad version (thanks step)
Code:
#!/bin/bash
## loads default X11 rgb palette or - when passed as parameter - any user defined color palette
## option to save user defined colors (disabled for X11 palette)
## supports mtPaint and GIMP palette formats (read/write) 
## remembers last used color, window size and location

[[ -f $1 ]] && palettefile=$1 || palettefile=/usr/share/X11/rgb.txt
[[ $palettefile = /usr/share/X11/rgb.txt ]] && enable= || enable=true
export geofile=/tmp/yadcol_geometry.txt
    valfile=/tmp/yadcol_lastused.txt

function savegeo {
 WINDOWID=$(xprop -root _NET_ACTIVE_WINDOW)
 WINDOWID=${WINDOWID##* }
 XWININFO=$(xwininfo -id $WINDOWID)
 set -- ${@} ${XWININFO#* X: }
 AX=$1 AY=$5 RX=$9 RY=${13}
 echo -n "${15}x${17}+$((AX-RX))+$((AY-RY))" > $geofile
};export -f savegeo

fileheader=$(grep '^[^ 0-9].*' -o "$palettefile")   #extract GIMP file header
[[ $fileheader ]] && fileheader=${fileheader}$'\n'  #keep variable empty if header does not exist

while : ;do
 colorval=$(yad --color --title="YAD - ${palettefile##*/}" --init-color="$(< $valfile)"  --geometry="$(< $geofile)" --always-print-result --gtk-palette --expand-palette --palette=<(awk "/^[ 0-9]/" "$palettefile") ${enable:+--button="Save color:bash -c 'savegeo; kill -s SIGUSR2 \$YAD_PID'"} --button="OK:bash -c 'savegeo; kill -s SIGUSR1 \$YAD_PID'" --button="Cancel:9" )
 ret=$?
 case $ret in
 0) : OK; echo -n $colorval; echo $colorval > "$valfile" ; break ;;
 1) : SAVE; newname=$(gxmessage -title "Save color" -bg $colorval -c -entrytext 'NewColorName' $'\n\t'"Color $colorval")
      (($?)) || printf '%s%d %d %d\t%s\n%s\n' "$fileheader" 0\x${colorval:1:2} 0\x${colorval:3:2} 0\x${colorval:5:2} "$newname" "$(awk '/^[ 0-9]/' "$palettefile")" > "$palettefile"
      echo $colorval > "$valfile" ;;
 *) : CANCEL; break ;; #ret = 9 or 252
 esac
done
yad_custom_color_dialog.png
 Description   
 Filesize   56.01 KB
 Viewed   1121 Time(s)

yad_custom_color_dialog.png


Last edited by MochiMoppel on Sat 28 Mar 2020, 21:07; edited 4 times in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Thu 21 Feb 2019, 05:19    Post subject:  

I made some changes to above script and added support for mtPaint/GIMP palette formats.
Files created with the script such as the included demo palette can be loaded into mtPaint and will be displayed as an indexed palette. Unfortunately mtPaint AFAIK has no support for color names.
Reading mtPaint/GIMP files was less of a problem before but their unsupported file headers produced ugly gibberish. Reading should now work without flaws (tested with palettes included in GIMP).
Back to top
View user's profile Send private message 
musher0

Joined: 04 Jan 2009
Posts: 15041
Location: Gatineau (Qc), Canada

PostPosted: Thu 21 Feb 2019, 08:51    Post subject: Re: foregound/background  

tlchost wrote:
What would be very helpful for folks developing web pages would be a way of manipulating the values of foreground and background colors and viewing the result on the screen...it could avoid unfortunate combinations like white/yellow or black/blue [/i]

Thanks tlchost, MochiMoppei.

I'd add to tlchost's suggestion -- which is sorely needed, I think, -- that it
would be nice to be able to save maybe up to ten colors, and that this
"color yadget" does not close after each choice.

When I develop an urxvt pseudo-GUI window, I find myself scribbling a lot
of hex colors on a sheet of paper. Having a list handy in an editor could
save time.

As to your approach of leaving rgb.txt alone, I think it is a good idea,
although gcolor2 allows saving new color names in the rgb.txt list.

My 2 ¢. BFN.

_________________
musher0
~~~~~~~~~~
"You want it darker? We kill the flame." (L. Cohen)

Last edited by musher0 on Thu 21 Feb 2019, 11:45; edited 1 time in total
Back to top
View user's profile Send private message 
perdido


Joined: 09 Dec 2013
Posts: 1601
Location: ¿Altair IV , Just north of Eeyore Junction.?

PostPosted: Fri 22 Feb 2019, 22:33    Post subject:  

MochiMoppel wrote:
OK, here is my prototype for a yad color picker with save capability.


Easy for a simpleton like myself. Looks good Smile
I have added up to 15 colors in the save window (program will do more)


.
MM_color_palette.jpg
 Description   
 Filesize   47.81 KB
 Viewed   812 Time(s)

MM_color_palette.jpg

Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Sat 23 Feb 2019, 22:06    Post subject:  

@perdido: I like your EnvyGreen. Reminds me of my IKEA coasters.

I have updated my script and my explanations. I removed the demo code as it seemed to cause some confusion.

Speaking of green brings me back to my thread topic. My focus are X11 color names, not W3C color names used in web pages. Both color schemes are largely the same, but there are still differences, which makes it all the more important not to confuse them or mix them in the same palette. Sometimes different names are used for the same color (e.g. cyan vs. aqua), sometimes the same name is used for different colors, e.g. green:

This is the W3C color named "green", chosen from the "Font colour" dropdown box in this forum software:
██████
The hex value is #008000 which makes is relatively dark

This is the X11 color named "green", usable in commands like gxmessage -bg green "Hello World"
██████
The hex value is #00FF00
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Sat 28 Mar 2020, 21:06    Post subject:  

Forum member step kindly informed me that recent yad versions don't ignore invalid options anymore, a "feature" I deliberately exploited in my yad script. I therefore applied his fix and updated the script. Should work now with all yad versions.
Back to top
View user's profile Send private message 
Colonel Panic


Joined: 16 Sep 2006
Posts: 2177

PostPosted: Thu 02 Apr 2020, 08:50    Post subject:  

Here's a web page that you might find useful;

http://sedition.com/perl/rgb.html

_________________
Gigabyte M68MT-52P motherboard, AMD Athlon II X4 630, 5.8 GB of DDR3 RAM and a 250 GB Hitachi hard drive running Ubuntu 16.04.6, MX-19.2, Peppermint 10, PCLinuxOS 20.02, LXLE 18.04.3, Pardus 19.2, exGENT 200119, Bionic Pup 8.0 and Xenial CE 7.5 XL.
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3822
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Thu 09 Apr 2020, 17:49    Post subject:  

Bonjour,
Thanks MochiMoppel for this very useful script. Smile
To use it easily and make it more handly, I made a little script named "yadcolmgr" (create, manage and load color palettes) I would like to share with anyone who might be interested. Your script is in the PET under the name "yadcol", with small changes so that the configuration files are stored persistently in /root/.config/yadcol and no longer temporarily in /tmp.
I also provide a script that I made for my own use a long time ago and that allows to extract colors from the current JWM theme. The colors can be dragged and dropped directly into the Yadcol window and a palette can be created this way.
Exclamation [EDIT 200513]: New version, please see the post below.

Cordialement.
200513_135540_371x187_easyshot.jpg
 Description   
 Filesize   14.52 KB
 Viewed   233 Time(s)

200513_135540_371x187_easyshot.jpg

200409_233413_232x509_easyshot.png
 Description   
 Filesize   20.8 KB
 Viewed   431 Time(s)

200409_233413_232x509_easyshot.png

get_jwm_theme_fonts_colors_all.pet
Description 
pet

 Download 
Filename  get_jwm_theme_fonts_colors_all.pet 
Filesize  5.21 KB 
Downloaded  103 Time(s) 

_________________

Puppy Search

Last edited by Argolance on Wed 13 May 2020, 08:00; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Fri 08 May 2020, 22:36    Post subject:  

Bonjour Argolance. Sorry for the late response. I tried your scripts but didn't spend much time with them. That may be the reason why I couldn't really figure out how they work. Basically I like the idea of a central place to manage various color palelettes

Argolance wrote:
Your script is in the PET under the name "yadcol", with small changes so that the configuration files are stored persistently in /root/.config/yadcol
Only if the user runs yadcolmgr first where directory /root/.config/yadcol is created.

yadcolmgr expects the user to edit the raw color text files. Not everyone's cup of tea. Maybe it would be easier for the user to integrate your yadcolmgr into yadcol. Selecting a palette from your dropdown box could automatically populate the color picker and allow instant editing without the need for text files. Haven't tried and don't know if feasible.

Quote:
I also provide a script that I made for my own use a long time ago and that allows to extract colors from the current JWM theme. The colors can be dragged and dropped directly into the Yadcol window and a palette can be created this way.
Can't say much about it as it wouldn't work for me. I think it is hard coded to read /root/.jwm/jwmrc-theme, a file I don't use. My theme settings are in /root/jwmrc.

Salut
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3822
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Tue 12 May 2020, 04:04    Post subject:  

Bonjour,

@MochiMoppel
MochiMoppel wrote:
Sorry for the late response.

Thanks for your comment: better late than never! Wink
Quote:
I tried your scripts but didn't spend much time with them. That may be the reason why I couldn't really figure out how they work

May be indeed... Smile
Quote:
Selecting a palette from your dropdown box could automatically populate the color picker and allow instant editing without the need for text files.

I don't know if I understood you correctly, but it seems to me that's exactly what yadcolmgr does: Create, manage and instantly load selected palette using your script yadcol (please, see the picture below). Of course, user can also, if it is useful, edit the palette of his choice in the text editor to remove duplicate colors, for example, or rename them, or convert a standard palette into a GIMP palette, as well as browse to the palettes directory to rename them, but these are additional conveniences... Maybe I should change the text in the tooltip to make it clearer?
Exclamation [EDIT 200513]: I finally made a separate, more detailed help file instead of the tool-tip and took the opportunity to improve my script significantly:[lis3t]- Moved the palettes directory to the subdirectory /root/.config/yadcol/palettes
- Warning (that works properly now!) when a created palette color file already exists or when user wants to delete one.
- Multiple simultaneous instances of YadCol from a single of YadColMgr allowed
- fr translation[/list]
Quote:
Can't say much about it as it wouldn't work for me. I think it is hard coded to read /root/.jwm/jwmrc-theme, a file I don't use. My theme settings are in /root/jwmrc.

What strange kind of Puppy do you use? Shocked Is there any, using JWM that doesn't have its hidden /root/.jwm folder where its themes are stored? Rolling Eyes

Exclamation [EDIT 200519]: Note that if the previous version of yadcolmgr has been installed, the /root/.config/yadcol/palettes folder should be created manually and the palette files moved to it.

Cordialement.
yadcol-200510_all.pet
Description 
pet

 Download 
Filename  yadcol-200510_all.pet 
Filesize  17.69 KB 
Downloaded  81 Time(s) 
200513_133626_524x517_easyshot.jpg
 Description   
 Filesize   65.17 KB
 Viewed   245 Time(s)

200513_133626_524x517_easyshot.jpg


_________________

Puppy Search

Last edited by Argolance on Tue 19 May 2020, 07:02; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Fri 15 May 2020, 02:11    Post subject:  

Argolance wrote:
I don't know if I understood you correctly, but it seems to me that's exactly what yadcolmgr does
No, that's not what I meant. My idea was to have the dropdown and the whole managing stuff in the original yad script, so there would be no need for a separate managing tool. I'm a simple minded single script guy Laughing My yad skills are getting rusty but I'll see if I can produce a demo. May take a couple of days. I understand that your solution works for you and certainly for many other users, so please don't pay too much attention to my views. Diversity is always good and my personal preferences don't matter much.

On a related subject: 3 days ago I dusted off my old mini-tower machine, which is loud but 64bit capable and tried Bionicpup64. Nice experience. However I noticed that bionicpup includes a file /root/.rgb.txt , symlinked to /usr/share/X11/rgb.txt . This makes no sense. I know that musher0 ventilated this idea earlier in this thread, but at this time it was fair for me to assume that he doesn't know how gcolor2 is supposed to work. But now it appears in bionicpub Shocked
Digging deaper I found that it has been in woof-CE since 2015 at the request of musher0. I don't blame him for not knowing better, but the guys at woof-CE should. Would dimkr be so kind and remove it? Gcolor2 needs no symlink to the X11 colors since it displays them by default. The only problem is that in woof-CE the directory /usr/share/X11 is not the place where gcolor2 would look for the rgb.txt file. This is what needs to be fixed. The file /root/.rgb.txt should not be preinstalled and in no case symlinked to the X11 colors.

[EDIT] I see little chance to have woof-CE's dimkr (a.k.a forum member Iguleder) remove the symlink. His last post dates from Dec 2015. Maybe someone else from the woof-CE team can do it?
Screenshot.png
 Description   
 Filesize   49.18 KB
 Viewed   213 Time(s)

Screenshot.png


Last edited by MochiMoppel on Fri 15 May 2020, 08:31; edited 1 time in total
Back to top
View user's profile Send private message 
Argolance


Joined: 06 Jan 2008
Posts: 3822
Location: PORT-BRILLET (Mayenne - France)

PostPosted: Fri 15 May 2020, 03:44    Post subject:  

Bonjour,
MochiMoppel wrote:
Diversity is always good and my personal preferences don't matter much.

Without diversity, this world would be hell itself! Uniformity is the enemy of humans, that's why I don't like so much the world we are building. That's why, among other things much more fundamental, I like our little Puppy Wink .
So, if I've made you want to add features your script, I'm really glad Smile

Cordialement.

_________________

Puppy Search
Back to top
View user's profile Send private message Visit poster's website 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Mon 18 May 2020, 00:58    Post subject:  

With rgb.txt being such an unreliable source for color names I wonder if we should continue to rely on it.

Getting the names of 752 color names from Xorg, the real source, is very fast and easy:
Code:
busybox strings -n3 $(type -p Xorg) | grep -m1 -A751 alice


Extracting also the corresponding hex values from the binary Xorg file would be more complicated. Haven't done it yet.
What is easy though is an adaption of the gtkdialog script of the initial post. Meanwhile I figured out what causes the segmentation fault when trying to display all colors: The vbox that contains the colorbuttons can't handle 700+ widgets, so I have to split the widgets into 2 vboxes:
Code:
busybox strings -n3 $(type -p Xorg) | grep -m1 -A751 alice |awk 'BEGIN {
print "<window title=\"Color Names as per Xorg\"><vbox><vbox  width=\"250\" height=\"400\" scrollable=\"true\"><vbox>"}
++i==400 {print "</vbox><vbox>"}   #start 400th item in new vbox to avoid segmentation fault
{print "<hbox><colorbutton><variable>\""$0"\"</variable><default>"$0"</default></colorbutton><entry><input>echo \" "$0"\"</input></entry></hbox>"}
END {print "</vbox></vbox><button></button></vbox></window>"}' | gtkdialog -s

When pushing the OK button the output of gtkdialog can be used as the source for any further processing/conversion:
Code:
AliceBlue="#f0f8ff"
AntiqueWhite="#faebd7"
AntiqueWhite1="#ffefdb"
AntiqueWhite2="#eedfcc"
AntiqueWhite3="#cdc0b0"
AntiqueWhite4="#8b8378"
alice blue="#f0f8ff"
antique white="#faebd7"
aquamarine="#7fffd4"
aquamarine1="#7fffd4"
aquamarine2="#76eec6"
aquamarine3="#66cdaa"
aquamarine4="#458b74"
azure="#f0ffff"
[...]


[EDIT] Code needs some refinement. Number of colors may vary. Bionicpup64 knows 782 colors, 30 more than its included rgb.txt file. Xorg may also be a mere wrapper script without color names, so the binary Xorg has to be found first.
ColorNamesXorg.png
 Description   
 Filesize   8.48 KB
 Viewed   138 Time(s)

ColorNamesXorg.png

Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 2 of 3 [43 Posts]   Goto page: Previous 1, 2, 3 Next
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.2451s ][ Queries: 13 (0.0849s) ][ GZIP on ]