« [CIFalseColor]バーコードに色を塗る | トップページ | [NSPrinter]メモ »

[ColorPicker] AppleScript用のFloatの値を取得します

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
##自分環境がos12なので2.8にしているだけです
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions


property refMe : a reference to current application


-------RGB16bitColorに16bitRGB値を格納
tell application "Finder"
set the listRGB16bitColor to (choose color default color {0, 0, 0, 1}) as list
end tell

##########Color Picker Value 16Bit
set numRcolor16Bit to item 1 of listRGB16bitColor as number
set numGcolor16Bit to item 2 of listRGB16bitColor as number
set numBcolor16Bit to item 3 of listRGB16bitColor as number
set numAcolor16Bit to 65535 as number

log numRcolor16Bit
log numGcolor16Bit
log numBcolor16Bit
log numAcolor16Bit

##########Standard RGB Value 8Bit
set numRcolor8Bit to numRcolor16Bit / 256 div 1 as number
set numGcolor8Bit to numGcolor16Bit / 256 div 1 as number
set numBcolor8Bit to numBcolor16Bit / 256 div 1 as number
set numAcolor8Bit to numAcolor16Bit / 256 div 1 as number

log numRcolor8Bit
log numGcolor8Bit
log numBcolor8Bit
log numAcolor8Bit

##########NSColorValue Float
set numRcolorFloat to numRcolor8Bit / 255 as number
set numGcolorFloat to numGcolor8Bit / 255 as number
set numBcolorFloat to numBcolor8Bit / 255 as number
set numAcolorFloat to numAcolor8Bit / 255 as number

log numRcolorFloat
log numGcolorFloat
log numBcolorFloat
log numAcolorFloat


-----を付けて
set theDisptext to "colorWithRed:" & numRcolorFloat & " green:" & numGcolorFloat & " blue:" & numBcolorFloat & " alpha:" & numAcolorFloat & " " as text


tell application "Finder"
set the clipboard to theDisptext
end tell

------ダイアログ表示用のテキスト
set theRGB8bitColor to "R:" & numRcolorFloat & " G:" & numGcolorFloat & " B:" & numBcolorFloat as text

tell application "Finder"
-----------------ファインダ アクティブ
activate
-----------------ダイアログ表示
display dialog "RGB:" & theRGB8bitColor & " のFloatColorが
出来ました
コピーして使って下さい。" default answer the theDisptext with icon 1 with title "コードをコピーしてください" default button 1
end tell

|

« [CIFalseColor]バーコードに色を塗る | トップページ | [NSPrinter]メモ »

AppleScript Color」カテゴリの記事