• 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: HSC to RGB
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: HSC to RGB


  • Subject: Re: HSC to RGB
  • From: Shane Stanley <email@hidden>
  • Date: Fri, 16 Oct 2015 22:35:06 +1100

On 16 Oct 2015, at 7:39 PM, Fred Diepeveen <email@hidden> wrote:

I need a script to convert HSV to RGB.
The data I get from a website is : hsv(0, 57%, 85%)

Has anyone solved the algorithms in applescript and/or does anyone know about a tool, that can be used in a applescript?

The maths look a bit complex to me, but if you're running Mavericks or later, there's a simple workaround: you make an NSColor with the HSV/HSB values you have, and then retrieve the R, G and B values of the color:

use framework "Foundation"

on rgbFromH:hue saturation:sat value:val
set theColor to current application's NSColor's colorWithHue:hue / 360 saturation:sat / 100 brightness:val / 100 alpha:1.0
set theRed to theColor's redComponent()
set theGreen to theColor's greenComponent()
set theBlue to theColor's blueComponent()
return {(theRed * 255 + 0.5) div 1, (theGreen * 255 + 0.5) div 1, (theBlue * 255 + 0.5) div 1}
end rgbFromH:saturation:value:

its rgbFromH:0 saturation:57 value:85
  --> {217, 93, 93}


-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >HSC to RGB (From: Fred Diepeveen <email@hidden>)

  • Prev by Date: Re: LiferayNativity.osax?
  • Next by Date: Re: Help with Script to mount SMB
  • Previous by thread: HSC to RGB
  • Next by thread: iWork Scripting Updates Documentation
  • Index(es):
    • Date
    • Thread