all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Returning hex value from rgb combination (each from 0 to 255)
@ 2024-08-31 17:10 Heime
  2024-08-31 17:43 ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2024-08-31 17:10 UTC (permalink / raw)
  To: Heime via Users list for the GNU Emacs text editor

How can I make a function that takes r g and b values (from 0 to 255) and
returns the corresponding hex value ? 





^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Returning hex value from rgb combination (each from 0 to 255)
  2024-08-31 17:10 Returning hex value from rgb combination (each from 0 to 255) Heime
@ 2024-08-31 17:43 ` Eli Zaretskii
  2024-08-31 17:54   ` Vagn Johansen
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-08-31 17:43 UTC (permalink / raw)
  To: help-gnu-emacs

> Date: Sat, 31 Aug 2024 17:10:27 +0000
> From: Heime <heimeborgia@protonmail.com>
> 
> How can I make a function that takes r g and b values (from 0 to 255) and
> returns the corresponding hex value ? 

What is "the corresponding hex value"?



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Returning hex value from rgb combination (each from 0 to 255)
  2024-08-31 17:43 ` Eli Zaretskii
@ 2024-08-31 17:54   ` Vagn Johansen
  2024-08-31 18:24     ` Eli Zaretskii
  0 siblings, 1 reply; 6+ messages in thread
From: Vagn Johansen @ 2024-08-31 17:54 UTC (permalink / raw)
  To: help-gnu-emacs

Eli Zaretskii <eliz@gnu.org> writes:

>> Date: Sat, 31 Aug 2024 17:10:27 +0000
>> From: Heime <heimeborgia@protonmail.com>
>> 
>> How can I make a function that takes r g and b values (from 0 to 255) and
>> returns the corresponding hex value ? 
>
> What is "the corresponding hex value"?
>

Probably the format used by color-rgb-to-hex

(color-rgb-to-hex 1 0 0 2) => "#ff0000"


-- 
Vagn Johansen




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Returning hex value from rgb combination (each from 0 to 255)
  2024-08-31 17:54   ` Vagn Johansen
@ 2024-08-31 18:24     ` Eli Zaretskii
  2024-08-31 18:44       ` Heime
  0 siblings, 1 reply; 6+ messages in thread
From: Eli Zaretskii @ 2024-08-31 18:24 UTC (permalink / raw)
  To: help-gnu-emacs

> From: Vagn Johansen <gonz808@hotmail.com>
> Date: Sat, 31 Aug 2024 19:54:49 +0200
> 
> Eli Zaretskii <eliz@gnu.org> writes:
> 
> >> Date: Sat, 31 Aug 2024 17:10:27 +0000
> >> From: Heime <heimeborgia@protonmail.com>
> >> 
> >> How can I make a function that takes r g and b values (from 0 to 255) and
> >> returns the corresponding hex value ? 
> >
> > What is "the corresponding hex value"?
> >
> 
> Probably the format used by color-rgb-to-hex
> 
> (color-rgb-to-hex 1 0 0 2) => "#ff0000"

Then he had better used (color-rgb-to-hex 1 0 0) instead, as 2 digits
per component will get him in trouble eventually.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Returning hex value from rgb combination (each from 0 to 255)
  2024-08-31 18:24     ` Eli Zaretskii
@ 2024-08-31 18:44       ` Heime
  2024-08-31 21:26         ` Stephen Berman
  0 siblings, 1 reply; 6+ messages in thread
From: Heime @ 2024-08-31 18:44 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: help-gnu-emacs

On Sunday, September 1st, 2024 at 6:24 AM, Eli Zaretskii <eliz@gnu.org> wrote:

> > From: Vagn Johansen gonz808@hotmail.com
> > Date: Sat, 31 Aug 2024 19:54:49 +0200
> > 
> > Eli Zaretskii eliz@gnu.org writes:
> > 
> > > > Date: Sat, 31 Aug 2024 17:10:27 +0000
> > > > From: Heime heimeborgia@protonmail.com
> > > > 
> > > > How can I make a function that takes r g and b values (from 0 to 255) and
> > > > returns the corresponding hex value ?
> > > 
> > > What is "the corresponding hex value"?
> > 
> > Probably the format used by color-rgb-to-hex
> > 
> > (color-rgb-to-hex 1 0 0 2) => "#ff0000"
> 
> 
> Then he had better used (color-rgb-to-hex 1 0 0) instead, as 2 digits
> per component will get him in trouble eventually.

But this requires values from 0.0 to 1.0 rather than from 0 to 255.



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Returning hex value from rgb combination (each from 0 to 255)
  2024-08-31 18:44       ` Heime
@ 2024-08-31 21:26         ` Stephen Berman
  0 siblings, 0 replies; 6+ messages in thread
From: Stephen Berman @ 2024-08-31 21:26 UTC (permalink / raw)
  To: Heime; +Cc: help-gnu-emacs

On Sat, 31 Aug 2024 18:44:22 +0000 Heime <heimeborgia@protonmail.com> wrote:

> On Sunday, September 1st, 2024 at 6:24 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>
>> > From: Vagn Johansen gonz808@hotmail.com
>> > Date: Sat, 31 Aug 2024 19:54:49 +0200
>> >
>> > Eli Zaretskii eliz@gnu.org writes:
>> >
>> > > > Date: Sat, 31 Aug 2024 17:10:27 +0000
>> > > > From: Heime heimeborgia@protonmail.com
>> > > >
>> > > > How can I make a function that takes r g and b values (from 0 to 255) and
>> > > > returns the corresponding hex value ?
>> > >
>> > > What is "the corresponding hex value"?
>> >
>> > Probably the format used by color-rgb-to-hex
>> >
>> > (color-rgb-to-hex 1 0 0 2) => "#ff0000"
>>
>>
>> Then he had better used (color-rgb-to-hex 1 0 0) instead, as 2 digits
>> per component will get him in trouble eventually.
>
> But this requires values from 0.0 to 1.0 rather than from 0 to 255.

So define a function that takes integer RGB values between 0 and 255 and
divide them by 255.0 before passing them to color-rgb-to-hex.

Steve Berman



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-08-31 21:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-31 17:10 Returning hex value from rgb combination (each from 0 to 255) Heime
2024-08-31 17:43 ` Eli Zaretskii
2024-08-31 17:54   ` Vagn Johansen
2024-08-31 18:24     ` Eli Zaretskii
2024-08-31 18:44       ` Heime
2024-08-31 21:26         ` Stephen Berman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.