TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Pepe on August 20, 2020, 07:52:17 AM

Title: Translate CECOLOR from RGB string to OLE color
Post by: Pepe on August 20, 2020, 07:52:17 AM
A simple question:

My current editor color is set as a 'true color' (CECOLOR variable value is a string) and I need to translate it into an OLE color number.

Is there any easier way to get it rather than dealing with the string?
Title: Re: Translate CECOLOR from RGB string to OLE color
Post by: hmspe on August 20, 2020, 08:45:42 AM
No direct conversion that I know of, but Lee Mac's LM:parsenumbers function makes handling the string easy.
Title: Re: Translate CECOLOR from RGB string to OLE color
Post by: RGUS on August 20, 2020, 10:13:39 AM
Lee Mac has the answer. I hope I can post this link Lee.
http://www.lee-mac.com/colourconversion.html
Title: Re: Translate CECOLOR from RGB string to OLE color
Post by: Pepe on August 20, 2020, 10:50:58 AM
Thank you both!

I know those useful Lee-Mac's works.

This is the way I get it dealing with the string and using Lee-Mac's stuff:

Code - Auto/Visual Lisp: [Select]
  1. (eval (read (strcat "(LM:RGB->OLE " (vl-string-translate "," " " (vl-string-left-trim "RGB:" (getvar "CECOLOR"))) ")")))
  2. ;;other way
  3. (apply 'LM:RGB->OLE (read (strcat "(" (vl-string-translate "," " " (vl-string-left-trim "RGB:" (getvar "CECOLOR"))) ")")))

So, i was trying to find a shortcut... :whistling: