• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Styled Text Library - Getting RGB from style data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Styled Text Library - Getting RGB from style data


  • Subject: Re: Styled Text Library - Getting RGB from style data
  • From: Arthur J Knapp <email@hidden>
  • Date: Mon, 11 Mar 2002 09:53:10 -0500

> Date: Sun, 10 Mar 2002 22:37:46 +1100
> Subject: Styled Text Library - Getting RGB from style data
> From: Malcolm Fitzgerald <email@hidden>


> To: <email@hidden>

> Arthur,

;-)

Ya know, it is surprising convenient to have one's personal email
directed to the applescript-users list...

;-)


> I'm starting to play with the styled text scripts that you sent. They're
> working quite well enough for the simple, small pieces of styled text that I
> need to convert.

> I ran foul of your color-conversion hack though.

So did Nigel Garvey...

> ... Your notes describe the
> work around that you generated (see below).

> Your "item 2 of" hack produced all sorts of odd results.

Yeah, it was a bad work-around... :(

> enough though and set to work. I finally realised that applescript's RGB
> color class wants numbers between 0-65535 and that two bytes were needed.
> Web safe colours couldn't be assured, but accuracy would be.

Right, an RGB is a collection of 3 unsigned 2-byte integers. My problem
was that I didn't initially understand how to go from:

Red Green Blue
00 00 AA AA FF FF

to this:

<font color="#00AAFF">, ie:

Red Green Blue
00 AA FF

The answer is to use the most-significant byte. You can obtain this
value from an integer in the range of 0-6553 simply by div-ing by 256:

{0, 32768, 4528} --> {0 div 256, 32768 div 256, 4528 div 256} -->
{0, 128, 17} --> 00 80 11


> -- 00 00 00 33 00 12 00 0D 00 04 03 4C 00 0F 00 00 33 33 FF FF

> -- ??? The color info in these contains more data than
> -- in a web hexidecimal triplet. I need to research a
> -- correct conversion process. "Web-safe" colors seem
> -- to always be the hex-triplet doubled, ie:
> --
> -- <body bgcolor="#00AAFF">
> --
> -- translates in RGB to
> --
> -- 0000AAAAFFFF
> --
> -- so my "hack" is to just grab one of the two integers
> -- of the RGB,

So in this case, the better "hack" would be to simply grab the first byte.


{ Arthur J. Knapp, of <http://www.STELLARViSIONs.com>
<mailto:email@hidden>
try
<http://www.eremita.demon.co.uk/scripting/applescript/>
on error number -128
end try
}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Curses! How to make new window in OSX Finder?
  • Next by Date: Re: Curses! How to make new window in OSX Finder?
  • Previous by thread: Styled Text Library - Getting RGB from style data
  • Next by thread: Re: Labeled parameter bug
  • Index(es):
    • Date
    • Thread