NSColorList

TIFFANYカラーのCLR(macOS用のカラーリストファイル)



ダウンロード - tiffany.clr.zip



20240927090859_1140x5182

|

XML2CRL v2



ダウンロード - xml2clrprocess.zip



コーレルのXMLからカラーデータを出力CLRファイルにします
AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# LSSharedFileList を Plistに解凍します
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011property refMe : a reference to current application
012
013set appFileManager to refMe's NSFileManager's defaultManager()
014
015###################################
016#####ファイル選択ダイアログ
017###################################
018set appFileManager to refMe's NSFileManager's defaultManager()
019set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
020set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
021set strAppendPath to ("Colors") as text
022set ocidDefaultLocationURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:(strAppendPath) isDirectory:false
023set aliasDefaultLocation to (ocidDefaultLocationURL's absoluteURL()) as alias
024tell current application
025  set strName to name as text
026end tell
027####スクリプトメニューから実行したら
028if strName is "osascript" then
029  tell application "Finder"
030    activate
031  end tell
032else
033  tell current application
034    activate
035  end tell
036end if
037####ダイアログを出す
038set listUTI to {"com.apple.color-file"} as list
039set aliasFilePath to (choose file with prompt "CLRファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
040####入力ファイルパス
041set strFilePath to (POSIX path of aliasFilePath) as text
042set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
043set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
044set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
045set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
046set ocidPrefixName to ocidBaseFilePathURL's lastPathComponent()
047###################################
048#####保存先ダイアログ
049###################################
050###ファイル名
051set strPrefixName to ocidPrefixName as text
052###拡張子変える場合
053set strFileExtension to "tsv"
054###ダイアログに出すファイル名
055set strDefaultName to (strPrefixName & "." & strFileExtension) as text
056set strPromptText to "名前を決めてください"
057set strMesText to "名前を決めてください"
058####
059set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
060set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
061set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
062
063####実在しない『はず』なのでas «class furl»で
064set aliasSaveFilePath to (choose file name strMesText default location aliasDefaultLocation default name strDefaultName with prompt strPromptText) as «class furl»
065####UNIXパス
066set strSaveFilePath to POSIX path of aliasSaveFilePath as text
067####ドキュメントのパスをNSString
068set ocidSaveFilePath to refMe's NSString's stringWithString:strSaveFilePath
069####ドキュメントのパスをNSURLに
070set ocidSaveFilePathURL to refMe's NSURL's fileURLWithPath:ocidSaveFilePath
071###拡張子取得
072set strFileExtensionName to ocidSaveFilePathURL's pathExtension() as text
073###ダイアログで拡張子を取っちゃった時対策
074if strFileExtensionName is not strFileExtension then
075  set ocidSaveFilePathURL to ocidSaveFilePathURL's URLByAppendingPathExtension:(strFileExtension)
076end if
077
078###################################
079#####本処理
080###################################
081#出力用のテキスト
082set ocidOutPutString to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083#CLRを読み込み
084set ocidReadData to refMe's NSColorList's alloc()'s initWithName:(strPrefixName) fromFile:(ocidFilePath)
085#キーを取得
086set ocidAllKeys to ocidReadData's allKeys()
087#出力テキスト用のカウンター
088set numLineNo to 1 as integer
089#キーの順に繰り返し
090repeat with itemKey in ocidAllKeys
091  (ocidOutPutString's appendString:(numLineNo as text))
092  (ocidOutPutString's appendString:("\t"))
093    #キーにNULが入るの事があるので除去する
094  set ocidChrSet to refMe's NSCharacterSet's controlCharacterSet
095  set ocidKeyString to (itemKey's stringByTrimmingCharactersInSet:(ocidChrSet))
096  (ocidOutPutString's appendString:(ocidKeyString as text))
097  #キーからNSCOLORを取り出して
098  set ocidItemColor to (ocidReadData's colorWithKey:(itemKey))
099  #カラースペース判定用の値
100  set ocidItemColorSpace to ocidItemColor's colorSpace()
101  set numColorSpace to ocidItemColorSpace's colorSpaceModel() as integer
102  #カラースペース毎に取得値違うので分岐
103  if numColorSpace = 0 then
104    set strColorSpace to ("Gray") as text
105    set strIntW to ocidItemColor's whiteComponent as text
106    set strIntA to ocidItemColor's alphaComponent as text
107    (ocidOutPutString's appendString:("\t"))
108    (ocidOutPutString's appendString:(strColorSpace))
109    (ocidOutPutString's appendString:("\t"))
110    (ocidOutPutString's appendString:(strIntW))
111    (ocidOutPutString's appendString:("\t"))
112    (ocidOutPutString's appendString:(strIntA))
113  else if numColorSpace = 1 then
114    set strColorSpace to ("RGB") as text
115    set strIntR to ocidItemColor's redComponent as text
116    set strIntG to ocidItemColor's greenComponent as text
117    set strIntB to ocidItemColor's blueComponent as text
118    set strIntA to ocidItemColor's alphaComponent as text
119    
120    set ocidDecimalR to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntR))
121    set ocidDecimalG to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntG))
122    set ocidDecimalB to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntB))
123    set ocidDecimalA to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntA))
124    
125    set ocid8bit to (refMe's NSDecimalNumber's alloc()'s initWithString:("255"))
126    
127    set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
128    (ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundUp))
129    (ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle))
130    (ocidFormatter's setUsesGroupingSeparator:(false))
131    (ocidFormatter's setMaximumFractionDigits:(0))
132    (ocidFormatter's setMinimumFractionDigits:(0))
133    
134    set ocid8bitR to (ocidFormatter's stringFromNumber:(ocidDecimalR's decimalNumberByMultiplyingBy:(ocid8bit)))
135    set ocid8bitG to (ocidFormatter's stringFromNumber:(ocidDecimalG's decimalNumberByMultiplyingBy:(ocid8bit)))
136    set ocid8bitB to (ocidFormatter's stringFromNumber:(ocidDecimalB's decimalNumberByMultiplyingBy:(ocid8bit)))
137    set ocid8bitA to (ocidFormatter's stringFromNumber:(ocidDecimalA's decimalNumberByMultiplyingBy:(ocid8bit)))
138    
139    
140    (ocidOutPutString's appendString:("\t"))
141    (ocidOutPutString's appendString:(strColorSpace))
142    (ocidOutPutString's appendString:("\t"))
143    (ocidOutPutString's appendString:(ocid8bitR as text))
144    (ocidOutPutString's appendString:("\t"))
145    (ocidOutPutString's appendString:(ocid8bitG as text))
146    (ocidOutPutString's appendString:("\t"))
147    (ocidOutPutString's appendString:(ocid8bitB as text))
148    (ocidOutPutString's appendString:("\t"))
149    (ocidOutPutString's appendString:(ocid8bitA as text))
150    
151    
152  else if numColorSpace = 2 then
153    set strColorSpace to ("CMYK") as text
154    set strIntC to ocidItemColor's cyanComponent as text
155    set strIntM to ocidItemColor's magentaComponent as text
156    set strIntY to ocidItemColor's yellowComponent as text
157    set strIntK to ocidItemColor's blackComponent as text
158    set strIntA to ocidItemColor's alphaComponent as text
159    
160    set ocidDecimalC to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntC))
161    set ocidDecimalM to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntM))
162    set ocidDecimalY to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntY))
163    set ocidDecimalK to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntK))
164    set ocidDecimalA to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntA))
165    #
166    set ocid100 to (refMe's NSDecimalNumber's alloc()'s initWithString:("100"))
167    #
168    #
169    set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
170    (ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundUp))
171    (ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle))
172    (ocidFormatter's setUsesGroupingSeparator:(false))
173    (ocidFormatter's setMaximumFractionDigits:(3))
174    (ocidFormatter's setMinimumFractionDigits:(0))
175    #
176    set ocidDecC to (ocidFormatter's stringFromNumber:(ocidDecimalC's decimalNumberByMultiplyingBy:(ocid100)))
177    set ocidDecM to (ocidFormatter's stringFromNumber:(ocidDecimalM's decimalNumberByMultiplyingBy:(ocid100)))
178    set ocidDecY to (ocidFormatter's stringFromNumber:(ocidDecimalY's decimalNumberByMultiplyingBy:(ocid100)))
179    set ocidDecK to (ocidFormatter's stringFromNumber:(ocidDecimalK's decimalNumberByMultiplyingBy:(ocid100)))
180    set ocidDecA to (ocidFormatter's stringFromNumber:(ocidDecimalA's decimalNumberByMultiplyingBy:(ocid100)))
181    
182    
183    (ocidOutPutString's appendString:("\t"))
184    (ocidOutPutString's appendString:(strColorSpace))
185    (ocidOutPutString's appendString:("\t"))
186    (ocidOutPutString's appendString:(ocidDecC as text))
187    (ocidOutPutString's appendString:("\t"))
188    (ocidOutPutString's appendString:(ocidDecM as text))
189    (ocidOutPutString's appendString:("\t"))
190    (ocidOutPutString's appendString:(ocidDecY as text))
191    (ocidOutPutString's appendString:("\t"))
192    (ocidOutPutString's appendString:(ocidDecK as text))
193    (ocidOutPutString's appendString:("\t"))
194    (ocidOutPutString's appendString:(ocidDecA as text))
195  end if
196  #行くギリの改行
197  (ocidOutPutString's appendString:("\n"))
198  set numLineNo to numLineNo + 1 as integer
199end repeat
200
201
202#テキストで保存
203set listDone to ocidOutPutString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
204if (item 1 of listDone) is true then
205  return "正常終了"
206else if (item 1 of listDone) is false then
207  log (item 2 of listDone)'s localizedDescription() as text
208  return "保存に失敗しました"
209end if
210
211
212
213
AppleScriptで生成しました

|

[com.apple.color-file]CLR2TSV CLRカラーファイルから色の値を取得してTSVタブ区切りテキストに出力する (RGB8bit)


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# LSSharedFileList を Plistに解凍します
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011property refMe : a reference to current application
012
013set appFileManager to refMe's NSFileManager's defaultManager()
014
015###################################
016#####ファイル選択ダイアログ
017###################################
018set appFileManager to refMe's NSFileManager's defaultManager()
019set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
020set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
021set strAppendPath to ("Colors") as text
022set ocidDefaultLocationURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:(strAppendPath) isDirectory:false
023set aliasDefaultLocation to (ocidDefaultLocationURL's absoluteURL()) as alias
024tell current application
025  set strName to name as text
026end tell
027####スクリプトメニューから実行したら
028if strName is "osascript" then
029  tell application "Finder"
030    activate
031  end tell
032else
033  tell current application
034    activate
035  end tell
036end if
037####ダイアログを出す
038set listUTI to {"com.apple.color-file"} as list
039set aliasFilePath to (choose file with prompt "CLRファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
040####入力ファイルパス
041set strFilePath to (POSIX path of aliasFilePath) as text
042set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
043set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
044set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
045set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
046set ocidPrefixName to ocidBaseFilePathURL's lastPathComponent()
047###################################
048#####保存先ダイアログ
049###################################
050###ファイル名
051set strPrefixName to ocidPrefixName as text
052###拡張子変える場合
053set strFileExtension to "tsv"
054###ダイアログに出すファイル名
055set strDefaultName to (strPrefixName & "." & strFileExtension) as text
056set strPromptText to "名前を決めてください"
057set strMesText to "名前を決めてください"
058####
059set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
060set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
061set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
062
063####実在しない『はず』なのでas «class furl»で
064set aliasSaveFilePath to (choose file name strMesText default location aliasDefaultLocation default name strDefaultName with prompt strPromptText) as «class furl»
065####UNIXパス
066set strSaveFilePath to POSIX path of aliasSaveFilePath as text
067####ドキュメントのパスをNSString
068set ocidSaveFilePath to refMe's NSString's stringWithString:strSaveFilePath
069####ドキュメントのパスをNSURLに
070set ocidSaveFilePathURL to refMe's NSURL's fileURLWithPath:ocidSaveFilePath
071###拡張子取得
072set strFileExtensionName to ocidSaveFilePathURL's pathExtension() as text
073###ダイアログで拡張子を取っちゃった時対策
074if strFileExtensionName is not strFileExtension then
075  set ocidSaveFilePathURL to ocidSaveFilePathURL's URLByAppendingPathExtension:(strFileExtension)
076end if
077
078###################################
079#####本処理
080###################################
081#出力用のテキスト
082set ocidOutPutString to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083#CLRを読み込み
084set ocidReadData to refMe's NSColorList's alloc()'s initWithName:(strPrefixName) fromFile:(ocidFilePath)
085#キーを取得
086set ocidAllKeys to ocidReadData's allKeys()
087#出力テキスト用のカウンター
088set numLineNo to 1 as integer
089#キーの順に繰り返し
090repeat with itemKey in ocidAllKeys
091  (ocidOutPutString's appendString:(numLineNo as text))
092  (ocidOutPutString's appendString:("\t"))
093  (ocidOutPutString's appendString:(itemKey))
094  #キーからNSCOLORを取り出して
095  set ocidItemColor to (ocidReadData's colorWithKey:(itemKey))
096  #カラースペース判定用の値
097  set ocidItemColorSpace to ocidItemColor's colorSpace()
098  set numColorSpace to ocidItemColorSpace's colorSpaceModel() as integer
099  #カラースペース毎に取得値違うので分岐
100  if numColorSpace = 0 then
101    set strColorSpace to ("Gray") as text
102    set strIntW to ocidItemColor's whiteComponent as text
103    set strIntA to ocidItemColor's alphaComponent as text
104    (ocidOutPutString's appendString:("\t"))
105    (ocidOutPutString's appendString:(strColorSpace))
106    (ocidOutPutString's appendString:("\t"))
107    (ocidOutPutString's appendString:(strIntW))
108    (ocidOutPutString's appendString:("\t"))
109    (ocidOutPutString's appendString:(strIntA))
110  else if numColorSpace = 1 then
111    set strColorSpace to ("RGB") as text
112    set strIntR to ocidItemColor's redComponent as text
113    set strIntG to ocidItemColor's greenComponent as text
114    set strIntB to ocidItemColor's blueComponent as text
115    set strIntA to ocidItemColor's alphaComponent as text
116    
117    set ocidDecimalR to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntR))
118    set ocidDecimalG to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntG))
119    set ocidDecimalB to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntB))
120    set ocidDecimalA to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntA))
121    
122    set ocid8bit to (refMe's NSDecimalNumber's alloc()'s initWithString:("255"))
123    
124    set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
125    (ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundUp))
126    (ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle))
127    (ocidFormatter's setUsesGroupingSeparator:(false))
128    (ocidFormatter's setMaximumFractionDigits:(0))
129    (ocidFormatter's setMinimumFractionDigits:(0))
130    
131    set ocid8bitR to (ocidFormatter's stringFromNumber:(ocidDecimalR's decimalNumberByMultiplyingBy:(ocid8bit)))
132    set ocid8bitG to (ocidFormatter's stringFromNumber:(ocidDecimalG's decimalNumberByMultiplyingBy:(ocid8bit)))
133    set ocid8bitB to (ocidFormatter's stringFromNumber:(ocidDecimalB's decimalNumberByMultiplyingBy:(ocid8bit)))
134    set ocid8bitA to (ocidFormatter's stringFromNumber:(ocidDecimalA's decimalNumberByMultiplyingBy:(ocid8bit)))
135    
136    
137    (ocidOutPutString's appendString:("\t"))
138    (ocidOutPutString's appendString:(strColorSpace))
139    (ocidOutPutString's appendString:("\t"))
140    (ocidOutPutString's appendString:(ocid8bitR as text))
141    (ocidOutPutString's appendString:("\t"))
142    (ocidOutPutString's appendString:(ocid8bitG as text))
143    (ocidOutPutString's appendString:("\t"))
144    (ocidOutPutString's appendString:(ocid8bitB as text))
145    (ocidOutPutString's appendString:("\t"))
146    (ocidOutPutString's appendString:(ocid8bitA as text))
147    
148    
149  else if numColorSpace = 2 then
150    set strColorSpace to ("CMYK") as text
151    set strIntC to ocidItemColor's cyanComponent as text
152    set strIntM to ocidItemColor's magentaComponent as text
153    set strIntY to ocidItemColor's yellowComponent as text
154    set strIntK to ocidItemColor's blackComponent as text
155    set strIntA to ocidItemColor's alphaComponent as text
156    
157    set ocidDecimalC to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntC))
158    set ocidDecimalM to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntM))
159    set ocidDecimalY to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntY))
160    set ocidDecimalK to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntK))
161    set ocidDecimalA to (refMe's NSDecimalNumber's decimalNumberWithString:(strIntA))
162    #
163    set ocid100 to (refMe's NSDecimalNumber's alloc()'s initWithString:("100"))
164    #
165    #
166    set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
167    (ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundUp))
168    (ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle))
169    (ocidFormatter's setUsesGroupingSeparator:(false))
170    (ocidFormatter's setMaximumFractionDigits:(3))
171    (ocidFormatter's setMinimumFractionDigits:(0))
172    #
173    set ocidDecC to (ocidFormatter's stringFromNumber:(ocidDecimalC's decimalNumberByMultiplyingBy:(ocid100)))
174    set ocidDecM to (ocidFormatter's stringFromNumber:(ocidDecimalM's decimalNumberByMultiplyingBy:(ocid100)))
175    set ocidDecY to (ocidFormatter's stringFromNumber:(ocidDecimalY's decimalNumberByMultiplyingBy:(ocid100)))
176    set ocidDecK to (ocidFormatter's stringFromNumber:(ocidDecimalK's decimalNumberByMultiplyingBy:(ocid100)))
177    set ocidDecA to (ocidFormatter's stringFromNumber:(ocidDecimalA's decimalNumberByMultiplyingBy:(ocid100)))
178    
179    
180    (ocidOutPutString's appendString:("\t"))
181    (ocidOutPutString's appendString:(strColorSpace))
182    (ocidOutPutString's appendString:("\t"))
183    (ocidOutPutString's appendString:(ocidDecC as text))
184    (ocidOutPutString's appendString:("\t"))
185    (ocidOutPutString's appendString:(ocidDecM as text))
186    (ocidOutPutString's appendString:("\t"))
187    (ocidOutPutString's appendString:(ocidDecY as text))
188    (ocidOutPutString's appendString:("\t"))
189    (ocidOutPutString's appendString:(ocidDecK as text))
190    (ocidOutPutString's appendString:("\t"))
191    (ocidOutPutString's appendString:(ocidDecA as text))
192  end if
193  #行くギリの改行
194  (ocidOutPutString's appendString:("\n"))
195  set numLineNo to numLineNo + 1 as integer
196end repeat
197
198
199#テキストで保存
200set listDone to ocidOutPutString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
201if (item 1 of listDone) is true then
202  return "正常終了"
203else if (item 1 of listDone) is false then
204  log (item 2 of listDone)'s localizedDescription() as text
205  return "保存に失敗しました"
206end if
207
208
209
210
AppleScriptで生成しました

|

[com.apple.color-file]CLR2TSV CLRカラーファイルから色の値を取得してTSVタブ区切りテキストに出力する (整数値)


AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#!/usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003#
004# LSSharedFileList を Plistに解凍します
005#com.cocolog-nifty.quicktimer.icefloe
006----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
007use AppleScript version "2.8"
008use framework "Foundation"
009use framework "AppKit"
010use scripting additions
011property refMe : a reference to current application
012
013set appFileManager to refMe's NSFileManager's defaultManager()
014
015###################################
016#####ファイル選択ダイアログ
017###################################
018set appFileManager to refMe's NSFileManager's defaultManager()
019set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSLibraryDirectory) inDomains:(refMe's NSUserDomainMask))
020set ocidLibraryDirPathURL to ocidURLsArray's firstObject()
021set strAppendPath to ("Colors") as text
022set ocidDefaultLocationURL to ocidLibraryDirPathURL's URLByAppendingPathComponent:(strAppendPath) isDirectory:false
023set aliasDefaultLocation to (ocidDefaultLocationURL's absoluteURL()) as alias
024tell current application
025  set strName to name as text
026end tell
027####スクリプトメニューから実行したら
028if strName is "osascript" then
029  tell application "Finder"
030    activate
031  end tell
032else
033  tell current application
034    activate
035  end tell
036end if
037####ダイアログを出す
038set listUTI to {"com.apple.color-file"} as list
039set aliasFilePath to (choose file with prompt "CLRファイルを選んでください" default location (aliasDefaultLocation) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
040####入力ファイルパス
041set strFilePath to (POSIX path of aliasFilePath) as text
042set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
043set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
044set ocidFilePathURL to (refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:false)
045set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
046set ocidPrefixName to ocidBaseFilePathURL's lastPathComponent()
047###################################
048#####保存先ダイアログ
049###################################
050###ファイル名
051set strPrefixName to ocidPrefixName as text
052###拡張子変える場合
053set strFileExtension to "tsv"
054###ダイアログに出すファイル名
055set strDefaultName to (strPrefixName & "." & strFileExtension) as text
056set strPromptText to "名前を決めてください"
057set strMesText to "名前を決めてください"
058####
059set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
060set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
061set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
062
063####実在しない『はず』なのでas «class furl»で
064set aliasSaveFilePath to (choose file name strMesText default location aliasDefaultLocation default name strDefaultName with prompt strPromptText) as «class furl»
065####UNIXパス
066set strSaveFilePath to POSIX path of aliasSaveFilePath as text
067####ドキュメントのパスをNSString
068set ocidSaveFilePath to refMe's NSString's stringWithString:strSaveFilePath
069####ドキュメントのパスをNSURLに
070set ocidSaveFilePathURL to refMe's NSURL's fileURLWithPath:ocidSaveFilePath
071###拡張子取得
072set strFileExtensionName to ocidSaveFilePathURL's pathExtension() as text
073###ダイアログで拡張子を取っちゃった時対策
074if strFileExtensionName is not strFileExtension then
075  set ocidSaveFilePathURL to ocidSaveFilePathURL's URLByAppendingPathExtension:(strFileExtension)
076end if
077
078###################################
079#####本処理
080###################################
081#出力用のテキスト
082set ocidOutPutString to refMe's NSMutableString's alloc()'s initWithCapacity:(0)
083#CLRを読み込み
084set ocidReadData to refMe's NSColorList's alloc()'s initWithName:(strPrefixName) fromFile:(ocidFilePath)
085#キーを取得
086set ocidAllKeys to ocidReadData's allKeys()
087#出力テキスト用のカウンター
088set numLineNo to 1 as integer
089#キーの順に繰り返し
090repeat with itemKey in ocidAllKeys
091  (ocidOutPutString's appendString:(numLineNo as text))
092  (ocidOutPutString's appendString:("\t"))
093  (ocidOutPutString's appendString:(itemKey))
094  #キーからNSCOLORを取り出して
095  set ocidItemColor to (ocidReadData's colorWithKey:(itemKey))
096  #カラースペース判定用の値
097  set ocidItemColorSpace to ocidItemColor's colorSpace()
098  set numColorSpace to ocidItemColorSpace's colorSpaceModel() as integer
099  #カラースペース毎に取得値違うので分岐
100  if numColorSpace = 0 then
101    set strColorSpace to ("Gray") as text
102    set strIntW to ocidItemColor's whiteComponent as text
103    set strIntA to ocidItemColor's alphaComponent as text
104    (ocidOutPutString's appendString:("\t"))
105    (ocidOutPutString's appendString:(strColorSpace))
106    (ocidOutPutString's appendString:("\t"))
107    (ocidOutPutString's appendString:(strIntW))
108    (ocidOutPutString's appendString:("\t"))
109    (ocidOutPutString's appendString:(strIntA))
110  else if numColorSpace = 1 then
111    set strColorSpace to ("RGB") as text
112    set strIntR to ocidItemColor's redComponent as text
113    set strIntG to ocidItemColor's greenComponent as text
114    set strIntB to ocidItemColor's blueComponent as text
115    set strIntA to ocidItemColor's alphaComponent as text
116    (ocidOutPutString's appendString:("\t"))
117    (ocidOutPutString's appendString:(strColorSpace))
118    (ocidOutPutString's appendString:("\t"))
119    (ocidOutPutString's appendString:(strIntR))
120    (ocidOutPutString's appendString:("\t"))
121    (ocidOutPutString's appendString:(strIntG))
122    (ocidOutPutString's appendString:("\t"))
123    (ocidOutPutString's appendString:(strIntB))
124    (ocidOutPutString's appendString:("\t"))
125    (ocidOutPutString's appendString:(strIntA))
126  else if numColorSpace = 2 then
127    set strColorSpace to ("CMYK") as text
128    set strIntC to ocidItemColor's cyanComponent as text
129    set strIntM to ocidItemColor's magentaComponent as text
130    set strIntY to ocidItemColor's yellowComponent as text
131    set strIntK to ocidItemColor's blackComponent as text
132    set strIntA to ocidItemColor's alphaComponent as text
133    
134    (ocidOutPutString's appendString:("\t"))
135    (ocidOutPutString's appendString:(strColorSpace))
136    (ocidOutPutString's appendString:("\t"))
137    (ocidOutPutString's appendString:(strIntC))
138    (ocidOutPutString's appendString:("\t"))
139    (ocidOutPutString's appendString:(strIntM))
140    (ocidOutPutString's appendString:("\t"))
141    (ocidOutPutString's appendString:(strIntY))
142    (ocidOutPutString's appendString:("\t"))
143    (ocidOutPutString's appendString:(strIntK))
144    (ocidOutPutString's appendString:("\t"))
145    (ocidOutPutString's appendString:(strIntA))
146  end if
147  #行くギリの改行
148  (ocidOutPutString's appendString:("\n"))
149  set numLineNo to numLineNo + 1 as integer
150end repeat
151
152
153#テキストで保存
154set listDone to ocidOutPutString's writeToURL:(ocidSaveFilePathURL) atomically:(true) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
155if (item 1 of listDone) is true then
156  return "正常終了"
157else if (item 1 of listDone) is false then
158  log (item 2 of listDone)'s localizedDescription() as text
159  return "保存に失敗しました"
160end if
161
162
163
164
AppleScriptで生成しました

|

[NSColorList]カラーリストCLRファイルを作成する(JSON2CLR)




ダウンロード - json2clr.zip




AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003# com.cocolog-nifty.quicktimer.icefloe
004#
005----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
006use AppleScript version "2.8"
007use framework "Foundation"
008use framework "AppKit"
009use scripting additions
010
011property refMe : a reference to current application
012
013####################
014#入力ファイルパス
015set aliasPathToMe to (path to me) as alias
016tell application "Finder"
017  set aliasContainerDirPath to (container of aliasPathToMe) as alias
018  set alisDataDirPath to (folder "Data" of folder aliasContainerDirPath) as alias
019  set aliasFilePath to (file "ntc.json" of folder alisDataDirPath) as alias
020end tell
021set strFilePath to (POSIX path of aliasFilePath) as text
022set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
023set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
024set ocidFilePathURL to refMe's NSURL's fileURLWithPath:(ocidFilePath)
025
026####################
027#出力ファイルパス
028set ocidDataDirPathURL to ocidFilePathURL's URLByDeletingLastPathComponent()
029set ocidContainerDirPathURL to ocidDataDirPathURL's URLByDeletingLastPathComponent()
030set ocidSaveDirPathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:("CLR") isDirectory:(true)
031#保存先フォルダを作っておく
032set appFileManager to refMe's NSFileManager's defaultManager()
033set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
034ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
035set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
036if (item 1 of listDone) is true then
037  log "正常処理"
038else if (item 2 of listDone) ≠ (missing value) then
039  set strErrorNO to (item 2 of listDone)'s code() as text
040  set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
041  refMe's NSLog("■:" & strErrorNO & strErrorMes)
042  return "エラーしました" & strErrorNO & strErrorMes
043end if
044#パス
045set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
046set ocidBaseFileName to ocidBaseFilePathURL's lastPathComponent()
047set ocidBaseSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidBaseFileName) isDirectory:(false)
048set ocidSaveFilePathURL to ocidBaseSaveFilePathURL's URLByAppendingPathExtension:("RGB.clr")
049
050####################
051#NADATA
052set listResponse to refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(refMe's NSDataReadingMappedIfSafe) |error| :(reference)
053if (item 2 of listResponse) = (missing value) then
054  log "正常処理"
055  set ocidReadData to (item 1 of listResponse)
056else if (item 2 of listResponse) ≠ (missing value) then
057  set strErrorNO to (item 2 of listResponse)'s code() as text
058  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
059  refMe's NSLog("■:" & strErrorNO & strErrorMes)
060  return "エラーしました" & strErrorNO & strErrorMes
061end if
062
063####################
064#NSJSONSerialization
065set ocidOption to (refMe's NSJSONReadingMutableContainers)
066set listResponse to (refMe's NSJSONSerialization's JSONObjectWithData:(ocidReadData) options:(ocidOption) |error| :(reference))
067if (item 2 of listResponse) = (missing value) then
068  log "正常処理"
069  set ocidJsonDict to (item 1 of listResponse)
070else if (item 2 of listResponse) ≠ (missing value) then
071  set strErrorNO to (item 2 of listResponse)'s code() as text
072  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
073  refMe's NSLog("■:" & strErrorNO & strErrorMes)
074  return "エラーしました" & strErrorNO & strErrorMes
075end if
076#キー一覧
077set ocidAllKeyArray to ocidJsonDict's allKeys()
078#ソートしておく(色名順)
079set ocidSortedKeyArray to ocidAllKeyArray's sortedArrayUsingSelector:("localizedStandardCompare:")
080
081########################
082#ファイル名でCOLORLISTを作っておく
083set strSetValue to ((ocidBaseFileName as text) & "(RGB)") as text
084set ocidColorListRGB to refMe's NSColorList's alloc()'s initWithName:(strSetValue)
085
086########################
087log "カラーデータ作成開始1分ほどかかります"
088
089repeat with itemKey in ocidSortedKeyArray
090  #JSONからキー値で値を取り出して
091  set ocidSetValue to (ocidJsonDict's valueForKey:(itemKey))
092  #キーの最初に2文字
093  set ocidGetRange to refMe's NSRange's NSMakeRange(0, 2)
094  set ocid1stSeg to (itemKey's substringWithRange:(ocidGetRange))
095  set ocid1stSeg8Bit to doHexTo8Bit(ocid1stSeg)
096  set ocid1stSegFloat to do8Bit2Float(ocid1stSeg8Bit)
097  #キーの真ん中の2文字
098  set ocidGetRange to refMe's NSRange's NSMakeRange(2, 2)
099  set ocid2ndSeg to (itemKey's substringWithRange:(ocidGetRange))
100  set ocid2ndSeg8Bit to doHexTo8Bit(ocid2ndSeg)
101  set ocid2ndSegFloat to do8Bit2Float(ocid2ndSeg8Bit)
102  #キーの最後の2文字
103  set ocidGetRange to refMe's NSRange's NSMakeRange(4, 2)
104  set ocid3rdSeg to (itemKey's substringWithRange:(ocidGetRange))
105  set ocid3rdSeg8Bit to doHexTo8Bit(ocid3rdSeg)
106  set ocid3rdSegFloat to do8Bit2Float(ocid3rdSeg8Bit)
107  #色を作って
108  set ocidSetColor to (refMe's NSColor's colorWithRed:(ocid1stSegFloat) green:(ocid2ndSegFloat) blue:(ocid3rdSegFloat) alpha:(1.0))
109  #セット
110  (ocidColorListRGB's setColor:(ocidSetColor) forKey:(ocidSetValue))
111  
112end repeat
113
114##出来上がった色数を数えて 0じゃなければ保存する
115set numCntRGBList to (ocidColorListRGB's allKeys())'s |count|()
116
117####################
118#保存 RGB
119if (numCntRGBList as integer) > 0 then
120  set listDone to ocidColorListRGB's writeToURL:(ocidSaveFilePathURL) |error| :(reference)
121  if (item 1 of listDone) is true then
122    log "正常処理"
123  else if (item 2 of listDone) ≠ (missing value) then
124    set strErrorNO to (item 2 of listDone)'s code() as text
125    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
126    refMe's NSLog("■:" & strErrorNO & strErrorMes)
127    log "エラーしました" & strErrorNO & strErrorMes
128    return false
129  end if
130end if
131
132########################
133#保存先を開く
134set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
135set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
136if boolDone is true then
137  log "正常処理"
138else if boolDone is false then
139  set strErrorNO to (item 2 of listDone)'s code() as text
140  set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
141  refMe's NSLog("■:" & strErrorNO & strErrorMes)
142  return "エラーしました" & strErrorNO & strErrorMes
143end if
144
145########################
146#RGB変換
147to do8Bit2Float(arg8Bit)
148  set str8Bit to arg8Bit as text
149  set ocid8Bit to refMe's NSDecimalNumber's alloc()'s initWithString:(str8Bit)
150  set ocidDivNo to refMe's NSDecimalNumber's alloc()'s initWithString:("255")
151  #割り算
152  set ocidFloatRaw to (ocid8Bit's decimalNumberByDividingBy:(ocidDivNo))
153  #小数点4位まで
154  set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
155  ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundCeiling)
156  ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle)
157  #ocidFormatter's setUsesGroupingSeparator:(false)
158  ocidFormatter's setMinimumFractionDigits:(1)
159  ocidFormatter's setMaximumFractionDigits:(4)
160  set ocidRoundCeiling to ocidFormatter's stringFromNumber:(ocidFloatRaw)
161  #戻り値はテキストで戻す
162  set strDecimalNo to ocidRoundCeiling as text
163  return strDecimalNo
164  
165end do8Bit2Float
166
167
168####################
169#HEXto8BITサブ
170
171property recordHexTo8Bit : {|00|:"0", |01|:"1", |02|:"2", |03|:"3", |04|:"4", |05|:"5", |06|:"6", |07|:"7", |08|:"8", |09|:"9", |0A|:"10", |0B|:"11", |0C|:"12", |0D|:"13", |0E|:"14", |0F|:"15", |10|:"16", |11|:"17", |12|:"18", |13|:"19", |14|:"20", |15|:"21", |16|:"22", |17|:"23", |18|:"24", |19|:"25", |1A|:"26", |1B|:"27", |1C|:"28", |1D|:"29", |1E|:"30", |1F|:"31", |20|:"32", |21|:"33", |22|:"34", |23|:"35", |24|:"36", |25|:"37", |26|:"38", |27|:"39", |28|:"40", |29|:"41", |2A|:"42", |2B|:"43", |2C|:"44", |2D|:"45", |2E|:"46", |2F|:"47", |30|:"48", |31|:"49", |32|:"50", |33|:"51", |34|:"52", |35|:"53", |36|:"54", |37|:"55", |38|:"56", |39|:"57", |3A|:"58", |3B|:"59", |3C|:"60", |3D|:"61", |3E|:"62", |3F|:"63", |40|:"64", |41|:"65", |42|:"66", |43|:"67", |44|:"68", |45|:"69", |46|:"70", |47|:"71", |48|:"72", |49|:"73", |4A|:"74", |4B|:"75", |4C|:"76", |4D|:"77", |4E|:"78", |4F|:"79", |50|:"80", |51|:"81", |52|:"82", |53|:"83", |54|:"84", |55|:"85", |56|:"86", |57|:"87", |58|:"88", |59|:"89", |5A|:"90", |5B|:"91", |5C|:"92", |5D|:"93", |5E|:"94", |5F|:"95", |60|:"96", |61|:"97", |62|:"98", |63|:"99", |64|:"100", |65|:"101", |66|:"102", |67|:"103", |68|:"104", |69|:"105", |6A|:"106", |6B|:"107", |6C|:"108", |6D|:"109", |6E|:"110", |6F|:"111", |70|:"112", |71|:"113", |72|:"114", |73|:"115", |74|:"116", |75|:"117", |76|:"118", |77|:"119", |78|:"120", |79|:"121", |7A|:"122", |7B|:"123", |7C|:"124", |7D|:"125", |7E|:"126", |7F|:"127", |80|:"128", |81|:"129", |82|:"130", |83|:"131", |84|:"132", |85|:"133", |86|:"134", |87|:"135", |88|:"136", |89|:"137", |8A|:"138", |8B|:"139", |8C|:"140", |8D|:"141", |8E|:"142", |8F|:"143", |90|:"144", |91|:"145", |92|:"146", |93|:"147", |94|:"148", |95|:"149", |96|:"150", |97|:"151", |98|:"152", |99|:"153", |9A|:"154", |9B|:"155", |9C|:"156", |9D|:"157", |9E|:"158", |9F|:"159", |A0|:"160", |A1|:"161", |A2|:"162", |A3|:"163", |A4|:"164", |A5|:"165", |A6|:"166", |A7|:"167", |A8|:"168", |A9|:"169", |AA|:"170", |AB|:"171", |AC|:"172", |AD|:"173", |AE|:"174", |AF|:"175", |B0|:"176", |B1|:"177", |B2|:"178", |B3|:"179", |B4|:"180", |B5|:"181", |B6|:"182", |B7|:"183", |B8|:"184", |B9|:"185", |BA|:"186", |BB|:"187", |BC|:"188", |BD|:"189", |BE|:"190", |BF|:"191", |C0|:"192", |C1|:"193", |C2|:"194", |C3|:"195", |C4|:"196", |C5|:"197", |C6|:"198", |C7|:"199", |C8|:"200", |C9|:"201", |CA|:"202", |CB|:"203", |CC|:"204", |CD|:"205", |CE|:"206", |CF|:"207", |D0|:"208", |D1|:"209", |D2|:"210", |D3|:"211", |D4|:"212", |D5|:"213", |D6|:"214", |D7|:"215", |D8|:"216", |D9|:"217", |DA|:"218", |DB|:"219", |DC|:"220", |DD|:"221", |DE|:"222", |DF|:"223", |E0|:"224", |E1|:"225", |E2|:"226", |E3|:"227", |E4|:"228", |E5|:"229", |E6|:"230", |E7|:"231", |E8|:"232", |E9|:"233", |EA|:"234", |EB|:"235", |EC|:"236", |ED|:"237", |EE|:"238", |EF|:"239", |F0|:"240", |F1|:"241", |F2|:"242", |F3|:"243", |F4|:"244", |F5|:"245", |F6|:"246", |F7|:"247", |F8|:"248", |F9|:"249", |FA|:"250", |FB|:"251", |FC|:"252", |FD|:"253", |FE|:"254", |FF|:"255"} as record
172
173
174to doHexTo8Bit(argText)
175  set ocid8Bit2HexDict to refMe's NSMutableDictionary's alloc()'s initWithDictionary:(recordHexTo8Bit)
176  set ocidValue to ocid8Bit2HexDict's valueForKey:(argText)
177  return ocidValue
178end doHexTo8Bit
179
180return
AppleScriptで生成しました

|

[NSColorList]カラーリストCLRファイルを作成する(XML2CLR)




スポット - xml2clr.zip



プロセス - xml2clrprocess.zip




AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(* XMLをAppleのカラーファイルCLRに変換します
004XML2CLR 初回リリース 20240705 v1
005
006同封の
007カラーピッカー起動で
008Color Pickerを起動できます
009
010XMLファイルのサンプル入りデータはこちら
011https://quicktimer.cocolog-nifty.com/icefloe/files/xml2clr.zip
012パントンのデータがあります
013*)
014#com.cocolog-nifty.quicktimer.icefloe
015----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
016use AppleScript version "2.8"
017use framework "Foundation"
018use framework "AppKit"
019use framework "UniformTypeIdentifiers"
020use scripting additions
021
022property refMe : a reference to current application
023
024
025######################
026#CSVファイル読み込み
027set aliasPathToMe to (path to me) as alias
028tell application "Finder"
029  set aliasContainerDirPath to (container of aliasPathToMe) as alias
030  set alisDataDirPath to (folder "Data" of folder aliasContainerDirPath) as alias
031end tell
032set strContainerDirPath to (POSIX path of aliasContainerDirPath) as text
033set ocidContainerDirPathStr to refMe's NSString's stringWithString:(strContainerDirPath)
034set ocidContainerDirPath to ocidContainerDirPathStr's stringByStandardizingPath()
035set ocidContainerDirPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidContainerDirPath) isDirectory:(true)
036#出来上がりファイル保存先確保
037set ocidSaveDirPathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:("CLR") isDirectory:(true)
038set appFileManager to refMe's NSFileManager's defaultManager()
039set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
040ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
041set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
042if (item 1 of listDone) is true then
043  log "正常処理"
044else if (item 2 of listDone) ≠ (missing value) then
045  set strErrorNO to (item 2 of listDone)'s code() as text
046  set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
047  refMe's NSLog("■:" & strErrorNO & strErrorMes)
048  return "エラーしました" & strErrorNO & strErrorMes
049end if
050#ダイアログ
051set strName to (name of current application) as text
052if strName is "osascript" then
053  tell application "Finder" to activate
054else
055  tell current application to activate
056end if
057set listUTI to {"public.xml"}
058set strMes to ("XMLファイルを選んでください") as text
059set strPrompt to ("XMLファイルを選んでください") as text
060try
061  set aliasFilePath to (choose file strMes with prompt strPrompt default location (alisDataDirPath) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
062on error
063  log "エラーしました"
064  return "エラーしました"
065end try
066#入力ファイル
067set strFilePath to (POSIX path of aliasFilePath) as text
068set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
069set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
070set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:(false)
071#ファイル名
072set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
073set ocidBaseFileName to ocidBaseFilePathURL's lastPathComponent()
074#保存ファイルパス
075set ocidBaseSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidBaseFileName) isDirectory:(false)
076#RGB
077set ocidSaveFilePathURLRGB to ocidBaseSaveFilePathURL's URLByAppendingPathExtension:("RGB.clr")
078#sRGB
079set ocidSaveFilePathURLsRGB to ocidBaseSaveFilePathURL's URLByAppendingPathExtension:("sRGB.clr")
080#AdobeRGB
081set ocidSaveFilePathURLAdobeRGB to ocidBaseSaveFilePathURL's URLByAppendingPathExtension:("AdobeRGB.clr")
082#CMYK
083set ocidSaveFilePathURLCMYK to ocidBaseSaveFilePathURL's URLByAppendingPathExtension:("CMYK.clr")
084
085
086######################
087#NSDATA
088set ocidOption to (refMe's NSDataReadingMappedIfSafe)
089set listResponse to (refMe's NSData's alloc()'s initWithContentsOfURL:(ocidFilePathURL) options:(ocidOption) |error| :(reference))
090if (item 2 of listResponse) = (missing value) then
091  log "正常処理"
092  set ocidReadData to (item 1 of listResponse)
093else if (item 2 of listResponse) ≠ (missing value) then
094  log (item 2 of listResponse)'s code() as text
095  log (item 2 of listResponse)'s localizedDescription() as text
096  return "ダウンロードエラーしました"
097end if
098
099######################
100#XML
101set ocidOption to (refMe's NSXMLNodePreserveAll) + (refMe's NSXMLDocumentTidyXML)
102set listResponse to refMe's NSXMLDocument's alloc()'s initWithData:(ocidReadData) options:(ocidOption) |error| :(reference)
103if (item 2 of listResponse) = (missing value) then
104  log "正常処理"
105  set ocidXMLDoc to (item 1 of listResponse)
106else if (item 2 of listResponse) ≠ (missing value) then
107  log (item 2 of listResponse)'s code() as text
108  log (item 2 of listResponse)'s localizedDescription() as text
109  log "NSXMLDocumentエラー 警告がありました"
110  set ocidXMLDoc to (item 1 of listResponse)
111end if
112#ROOT
113set ocidRootElement to ocidXMLDoc's rootElement()
114set ocidColorspacesArray to ocidRootElement's elementsForName:("colorspaces")
115set ocidColorspaces to ocidColorspacesArray's firstObject()
116#リストに含まれる項目数
117set numCntChild to ocidColorspaces's childCount()
118
119########################
120#ファイル名でCOLORLISTを作っておく
121set strSetValue to ((ocidBaseFileName as text) & "(RGB)") as text
122set ocidColorListRGB to refMe's NSColorList's alloc()'s initWithName:(strSetValue)
123set strSetValue to ((ocidBaseFileName as text) & "(sRGB)") as text
124set ocidColorListsRGB to refMe's NSColorList's alloc()'s initWithName:(strSetValue)
125set strSetValue to ((ocidBaseFileName as text) & "(AdobeRGB)") as text
126set ocidColorListAdobeRGB to refMe's NSColorList's alloc()'s initWithName:(strSetValue)
127set strSetValue to ((ocidBaseFileName as text) & "(CMYK)") as text
128set ocidColorListCMYK to refMe's NSColorList's alloc()'s initWithName:(strSetValue)
129
130########################
131log "カラーデータ作成開始1分ほどかかります"
132#リスト毎に処理する
133repeat with itemNo from 0 to (numCntChild - 1) by 1
134  #CSエレメントを取り出して
135  set ocidCSelement to (ocidColorspaces's childAtIndex:(itemNo))
136  set ocidCSname to (ocidCSelement's attributeForName:("name"))'s stringValue()
137  set numCntCsChild to ocidCSelement's childCount()
138  repeat with itemCsNo from 0 to (numCntCsChild - 1) by 1
139    set ocidColorElement to (ocidCSelement's childAtIndex:(itemCsNo))
140    set ocidColorSpace to (ocidColorElement's attributeForName:("cs"))'s stringValue()
141    set ocidColorTints to (ocidColorElement's attributeForName:("tints"))'s stringValue()
142    ##tintsをカンマ区切りでリストにする
143    set ocidTintsArray to (ocidColorTints's componentsSeparatedByString:(","))
144    if (ocidColorSpace as text) is "CMYK" then
145      #値の収集
146      set strColorName to ((ocidCSname as text) & "(CMYK)") as text
147      set ocidColorC to (ocidTintsArray's objectAtIndex:(0))
148      set ocidColorM to (ocidTintsArray's objectAtIndex:(1))
149      set ocidColorY to (ocidTintsArray's objectAtIndex:(2))
150      set ocidColorK to (ocidTintsArray's objectAtIndex:(3))
151      set ocidSetColor to (refMe's NSColor's colorWithDeviceCyan:(ocidColorC) magenta:(ocidColorM) yellow:(ocidColorY) black:(ocidColorK) alpha:(1.0))
152      #セット
153      (ocidColorListCMYK's setColor:(ocidSetColor) forKey:(strColorName))
154    else if (ocidColorSpace as text) is "RGB" then
155      #値の収集
156      set strColorName to ((ocidCSname as text) & "(RGB)") as text
157      set ocidColorR to (ocidTintsArray's objectAtIndex:(0))
158      set ocidColorG to (ocidTintsArray's objectAtIndex:(1))
159      set ocidColorB to (ocidTintsArray's objectAtIndex:(2))
160      set ocidSetColor to (refMe's NSColor's colorWithRed:(ocidColorR) green:(ocidColorG) blue:(ocidColorB) alpha:(1.0))
161      #セット
162      (ocidColorListRGB's setColor:(ocidSetColor) forKey:(strColorName))
163    else if (ocidColorSpace as text) is "sRGB" then
164      #値の収集
165      set strColorName to ((ocidCSname as text) & "(sRGB)") as text
166      set ocidColorR to (ocidTintsArray's objectAtIndex:(0))
167      set ocidColorG to (ocidTintsArray's objectAtIndex:(1))
168      set ocidColorB to (ocidTintsArray's objectAtIndex:(2))
169      set ocidSetColor to (refMe's NSColor's colorWithSRGBRed:(ocidColorR) green:(ocidColorG) blue:(ocidColorB) alpha:(1.0))
170      #セット
171      (ocidColorListsRGB's setColor:(ocidSetColor) forKey:(strColorName))
172    else if (ocidColorSpace as text) is "AdobeRGB" then
173      #値の収集
174      set strColorName to ((ocidCSname as text) & "(AdobeRGB)") as text
175      set ocidColorR to (ocidTintsArray's objectAtIndex:(0))
176      set ocidColorG to (ocidTintsArray's objectAtIndex:(1))
177      set ocidColorB to (ocidTintsArray's objectAtIndex:(2))
178      set ocidSetColor to (refMe's NSColor's colorWithCalibratedRed:(ocidColorR) green:(ocidColorG) blue:(ocidColorB) alpha:(1.0))
179      #セット
180      (ocidColorListAdobeRGB's setColor:(ocidSetColor) forKey:(strColorName))
181      
182    else if (ocidColorSpace as text) is "HksRGB" then
183      #値の収集
184      set strColorName to ((ocidCSname as text) & "(HksRGB)") as text
185      set ocidColorR to (ocidTintsArray's objectAtIndex:(0))
186      set ocidColorG to (ocidTintsArray's objectAtIndex:(1))
187      set ocidColorB to (ocidTintsArray's objectAtIndex:(2))
188      set ocidSetColor to (refMe's NSColor's colorWithCalibratedRed:(ocidColorR) green:(ocidColorG) blue:(ocidColorB) alpha:(1.0))
189      #セットocidColorListRGBにしたのは間違いじゃないです
190      (ocidColorListRGB's setColor:(ocidSetColor) forKey:(strColorName))
191      
192    end if
193  end repeat
194  
195end repeat
196
197##出来上がった色数を数えて 0じゃなければ保存する
198set numCntRGBList to (ocidColorListRGB's allKeys())'s |count|()
199set numCntsRGBList to (ocidColorListsRGB's allKeys())'s |count|()
200set numCntAdobeRGBList to (ocidColorListAdobeRGB's allKeys())'s |count|()
201set numCntCMYKList to (ocidColorListCMYK's allKeys())'s |count|()
202
203########################
204#保存 RGB
205if (numCntRGBList as integer) > 0 then
206  set listDone to ocidColorListRGB's writeToURL:(ocidSaveFilePathURLRGB) |error| :(reference)
207  if (item 1 of listDone) is true then
208    log "正常処理"
209  else if (item 2 of listDone) ≠ (missing value) then
210    set strErrorNO to (item 2 of listDone)'s code() as text
211    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
212    refMe's NSLog("■:" & strErrorNO & strErrorMes)
213    log "エラーしました" & strErrorNO & strErrorMes
214    return false
215  end if
216end if
217########################
218#保存 sRGB
219if (numCntsRGBList as integer) > 0 then
220  set listDone to ocidColorListsRGB's writeToURL:(ocidSaveFilePathURLsRGB) |error| :(reference)
221  if (item 1 of listDone) is true then
222    log "正常処理"
223  else if (item 2 of listDone) ≠ (missing value) then
224    set strErrorNO to (item 2 of listDone)'s code() as text
225    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
226    refMe's NSLog("■:" & strErrorNO & strErrorMes)
227    log "エラーしました" & strErrorNO & strErrorMes
228    return false
229  end if
230end if
231
232########################
233#保存 AdobeRGB
234if (numCntAdobeRGBList as integer) > 0 then
235  set listDone to ocidColorListAdobeRGB's writeToURL:(ocidSaveFilePathURLAdobeRGB) |error| :(reference)
236  if (item 1 of listDone) is true then
237    log "正常処理"
238  else if (item 2 of listDone) ≠ (missing value) then
239    set strErrorNO to (item 2 of listDone)'s code() as text
240    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
241    refMe's NSLog("■:" & strErrorNO & strErrorMes)
242    log "エラーしました" & strErrorNO & strErrorMes
243    return false
244  end if
245end if
246
247########################
248#保存 CMYK
249if (numCntCMYKList as integer) > 0 then
250  set listDone to ocidColorListCMYK's writeToURL:(ocidSaveFilePathURLCMYK) |error| :(reference)
251  if (item 1 of listDone) is true then
252    log "正常処理"
253  else if (item 2 of listDone) ≠ (missing value) then
254    set strErrorNO to (item 2 of listDone)'s code() as text
255    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
256    refMe's NSLog("■:" & strErrorNO & strErrorMes)
257    log "エラーしました" & strErrorNO & strErrorMes
258    return false
259  end if
260end if
261
262########################
263#保存先を開く
264set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
265set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
266if boolDone is true then
267  log "正常処理"
268else if boolDone is false then
269  set strErrorNO to (item 2 of listDone)'s code() as text
270  set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
271  refMe's NSLog("■:" & strErrorNO & strErrorMes)
272  return "エラーしました" & strErrorNO & strErrorMes
273end if
274
275########################
276#RGB変換
277to do8Bit2Float(arg8Bit)
278  set str8Bit to arg8Bit as text
279  set ocid8Bit to refMe's NSDecimalNumber's alloc()'s initWithString:(str8Bit)
280  set ocidDivNo to refMe's NSDecimalNumber's alloc()'s initWithString:("255")
281  #割り算
282  set ocidFloatRaw to (ocid8Bit's decimalNumberByDividingBy:(ocidDivNo))
283  #小数点4位まで
284  set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
285  ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundCeiling)
286  ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle)
287  #ocidFormatter's setUsesGroupingSeparator:(false)
288  ocidFormatter's setMinimumFractionDigits:(1)
289  ocidFormatter's setMaximumFractionDigits:(4)
290  set ocidRoundCeiling to ocidFormatter's stringFromNumber:(ocidFloatRaw)
291  #戻り値はテキストで戻す
292  set strDecimalNo to ocidRoundCeiling as text
293  return strDecimalNo
294  
295end do8Bit2Float
296
297########################
298#CMYK変換
299to doHundred2Float(argStrHundred)
300  set strHundred to argStrHundred as text
301  set ocidHundred to refMe's NSDecimalNumber's alloc()'s initWithString:(strHundred)
302  set ocidDivNo to refMe's NSDecimalNumber's alloc()'s initWithString:("100")
303  #割り算
304  set ocidFloatRaw to (ocidHundred's decimalNumberByDividingBy:(ocidDivNo))
305  #小数点4位まで
306  set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
307  ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundCeiling)
308  ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle)
309  #ocidFormatter's setUsesGroupingSeparator:(false)
310  ocidFormatter's setMinimumFractionDigits:(1)
311  ocidFormatter's setMaximumFractionDigits:(4)
312  set ocidRoundCeiling to ocidFormatter's stringFromNumber:(ocidFloatRaw)
313  #戻り値はテキストで戻す
314  set strDecimalNo to ocidRoundCeiling as text
315  return strDecimalNo
316  
317end doHundred2Float
AppleScriptで生成しました

|

[NSColorList]カラーリストCLRファイルを作成する(CSV2CLR)




ダウンロード - csv2clr.zip




AppleScript サンプルコード

【スクリプトエディタで開く】 |

AppleScript サンプルソース(参考)
行番号ソース
001#! /usr/bin/env osascript
002----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
003(* カンマ区切りテキストをAppleのカラーファイルCLRに変換します
004CSV2CLR 初回リリース 20240705 v1
005
006同封の
007カラーピッカー起動で
008Color Pickerを起動できます
009
010CSVファイルのサンプル入りデータはこちら
011https://quicktimer.cocolog-nifty.com/icefloe/files/csv2clr.zip
012パントンのデータがあります
013*)
014#com.cocolog-nifty.quicktimer.icefloe
015----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
016use AppleScript version "2.8"
017use framework "Foundation"
018use framework "AppKit"
019use framework "UniformTypeIdentifiers"
020use scripting additions
021
022property refMe : a reference to current application
023
024
025######################
026#CSVファイル読み込み
027set aliasPathToMe to (path to me) as alias
028tell application "Finder"
029  set aliasContainerDirPath to (container of aliasPathToMe) as alias
030  set alisDataDirPath to (folder "Data" of folder aliasContainerDirPath) as alias
031end tell
032set strContainerDirPath to (POSIX path of aliasContainerDirPath) as text
033set ocidContainerDirPathStr to refMe's NSString's stringWithString:(strContainerDirPath)
034set ocidContainerDirPath to ocidContainerDirPathStr's stringByStandardizingPath()
035set ocidContainerDirPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidContainerDirPath) isDirectory:(true)
036#出来上がりファイル保存先確保
037set ocidSaveDirPathURL to ocidContainerDirPathURL's URLByAppendingPathComponent:("CLR") isDirectory:(true)
038set appFileManager to refMe's NSFileManager's defaultManager()
039set ocidAttrDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
040ocidAttrDict's setValue:(448) forKey:(refMe's NSFilePosixPermissions)
041set listDone to appFileManager's createDirectoryAtURL:(ocidSaveDirPathURL) withIntermediateDirectories:true attributes:(ocidAttrDict) |error| :(reference)
042if (item 1 of listDone) is true then
043  log "正常処理"
044else if (item 2 of listDone) ≠ (missing value) then
045  set strErrorNO to (item 2 of listDone)'s code() as text
046  set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
047  refMe's NSLog("■:" & strErrorNO & strErrorMes)
048  return "エラーしました" & strErrorNO & strErrorMes
049end if
050#ダイアログ
051set strName to (name of current application) as text
052if strName is "osascript" then
053  tell application "Finder" to activate
054else
055  tell current application to activate
056end if
057set listUTI to {"public.text", "public.delimited-values-text", "public.comma-separated-values-text"}
058set strMes to ("CSVファイルを選んでください") as text
059set strPrompt to ("CSVファイルを選んでください") as text
060try
061  set aliasFilePath to (choose file strMes with prompt strPrompt default location (alisDataDirPath) of type listUTI with invisibles and showing package contents without multiple selections allowed) as alias
062on error
063  log "エラーしました"
064  return "エラーしました"
065end try
066#入力ファイル
067set strFilePath to (POSIX path of aliasFilePath) as text
068set ocidFilePathStr to refMe's NSString's stringWithString:(strFilePath)
069set ocidFilePath to ocidFilePathStr's stringByStandardizingPath()
070set ocidFilePathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:(false)
071#ファイル名
072set ocidBaseFilePathURL to ocidFilePathURL's URLByDeletingPathExtension()
073set ocidBaseFileName to ocidBaseFilePathURL's lastPathComponent()
074#保存ファイルパス
075set ocidBaseSaveFilePathURL to ocidSaveDirPathURL's URLByAppendingPathComponent:(ocidBaseFileName) isDirectory:(false)
076#RGB
077set ocidSaveFilePathURLRGB to ocidBaseSaveFilePathURL's URLByAppendingPathExtension:("RGB.clr")
078#CMYK
079set ocidSaveFilePathURLCMYK to ocidBaseSaveFilePathURL's URLByAppendingPathExtension:("CMYK.clr")
080
081
082######################
083#NSSTRING
084set listResponse to refMe's NSString's alloc()'s initWithContentsOfURL:(ocidFilePathURL) encoding:(refMe's NSUTF8StringEncoding) |error| :(reference)
085if (item 2 of listResponse) = (missing value) then
086  log "正常処理"
087  set ocidReadString to (item 1 of listResponse)
088else if (item 2 of listResponse) ≠ (missing value) then
089  set strErrorNO to (item 2 of listResponse)'s code() as text
090  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
091  refMe's NSLog("■:" & strErrorNO & strErrorMes)
092  return "エラーしました" & strErrorNO & strErrorMes
093end if
094
095######################
096#改行コードをUNIXに強制
097set ocidCRChar to refMe's NSString's stringWithString:("\r")
098set ocidLFChar to refMe's NSString's stringWithString:("\n")
099set ocidCRLFChar to refMe's NSString's stringWithString:("\r\n")
100set ocidTempString to ocidReadString's stringByReplacingOccurrencesOfString:(ocidCRLFChar) withString:(ocidLFChar)
101set ocidReadStringLF to ocidTempString's stringByReplacingOccurrencesOfString:(ocidCRChar) withString:(ocidLFChar)
102
103########################
104#2重改行=空行を削除
105#正規表現生成
106set ocidOption to (refMe's NSRegularExpressionCaseInsensitive)
107set listResponse to refMe's NSRegularExpression's regularExpressionWithPattern:("(?m)^\\s*$\n?") options:(ocidOption) |error| :(reference)
108if (item 2 of listResponse) = (missing value) then
109  # log "正常処理"
110  set ocidRegex to (item 1 of listResponse)
111else if (item 2 of listResponse) ≠ (missing value) then
112  set strErrorNO to (item 2 of listResponse)'s code() as text
113  set strErrorMes to (item 2 of listResponse)'s localizedDescription() as text
114  refMe's NSLog("■:" & strErrorNO & strErrorMes)
115  return "エラーしました" & strErrorNO & strErrorMes
116end if
117#置換
118set ocidSetLength to ocidReadStringLF's |length|()
119set ocidSetRange to refMe's NSRange's NSMakeRange(0, ocidSetLength)
120set ocidOption to (refMe's NSMatchingReportProgress)
121set ocidReadStrings to ocidRegex's stringByReplacingMatchesInString:(ocidReadStringLF) options:(ocidOption) range:(ocidSetRange) withTemplate:("")
122########################
123#文末が改行終わりの場合の文末改行を削除
124set boolContain to (ocidReadStrings's hasSuffix:("\n")) as boolean
125if boolContain is true then
126  set ocidSetLength to ocidReadStrings's |length|()
127  set ocidSetStrings to ocidReadStrings's substringToIndex:(ocidSetLength - 1)
128else if boolContain is false then
129  set ocidSetStrings to ocidReadStrings
130end if
131########################
132#改行毎でリストに1行目しかない場合を考慮
133set boolLine to (ocidSetStrings's containsString:("\n")) as boolean
134if boolLine is true then
135  set ocidReadArray to ocidSetStrings's componentsSeparatedByString:("\n")
136else if boolLine is false then
137  set ocidReadArray to refMe's NSArray's arrayWithObject:(ocidSetStrings)
138end if
139#リストに含まれる項目数
140set numCntArray to ocidReadArray's |count|()
141########################
142#ファイル名でCOLORLISTを作っておく
143set strSetValue to ((ocidBaseFileName as text) & "(RGB)") as text
144set ocidColorListRGB to refMe's NSColorList's alloc()'s initWithName:(strSetValue)
145set strSetValue to ((ocidBaseFileName as text) & "(CMYK)") as text
146set ocidColorListCMYK to refMe's NSColorList's alloc()'s initWithName:(strSetValue)
147########################
148log "カラーデータ作成開始1分ほどかかります"
149#リスト毎に処理する
150repeat with itemNo from 0 to (numCntArray - 1) by 1
151  #
152  set strItemText to (ocidReadArray's objectAtIndex:(itemNo))
153  ##カンマ区切りでリストにする
154  set ocidLineArray to (strItemText's componentsSeparatedByString:(","))
155  #CMYKの値もあるか?チェック
156  set numCntLineArray to ocidLineArray's |count|() as integer
157  #値の収集
158  set ocidColorName to (ocidLineArray's objectAtIndex:(0))
159  set ocidColorR to (ocidLineArray's objectAtIndex:(1))
160  set ocidColorG to (ocidLineArray's objectAtIndex:(2))
161  set ocidColorB to (ocidLineArray's objectAtIndex:(3))
162  #CMYKデータがある場合
163  if numCntLineArray > 4 then
164    set ocidColorC to (ocidLineArray's objectAtIndex:(4))
165    set ocidColorM to (ocidLineArray's objectAtIndex:(5))
166    set ocidColorY to (ocidLineArray's objectAtIndex:(6))
167    set ocidColorK to (ocidLineArray's objectAtIndex:(7))
168  end if
169  #色の値をFLOATに
170  set ocidColorRf to do8Bit2Float(ocidColorR)
171  set ocidColorGf to do8Bit2Float(ocidColorG)
172  set ocidColorBf to do8Bit2Float(ocidColorB)
173  #値の作成 RGB
174  set strSetString to ((ocidColorName as text) & "(sRGB)") as text
175  set ocidSetColor to (refMe's NSColor's colorWithSRGBRed:(ocidColorRf) green:(ocidColorGf) blue:(ocidColorBf) alpha:(1.0))
176  #セット
177  (ocidColorListRGB's setColor:(ocidSetColor) forKey:(strSetString))
178  #色の値をFLOATに
179  if numCntLineArray > 4 then
180    set ocidColorCf to doHundred2Float(ocidColorC)
181    set ocidColorMf to doHundred2Float(ocidColorM)
182    set ocidColorYf to doHundred2Float(ocidColorY)
183    set ocidColorKf to doHundred2Float(ocidColorK)
184    #値の作成CMYK
185    set strSetString to ((ocidColorName as text) & "(CMYK)") as text
186    set ocidSetColor to (refMe's NSColor's colorWithDeviceCyan:(ocidColorCf) magenta:(ocidColorMf) yellow:(ocidColorYf) black:(ocidColorKf) alpha:(1.0))
187    #セット
188    (ocidColorListCMYK's setColor:(ocidSetColor) forKey:(strSetString))
189  end if
190  
191end repeat
192
193########################
194#保存 RGB
195set listDone to ocidColorListRGB's writeToURL:(ocidSaveFilePathURLRGB) |error| :(reference)
196if (item 1 of listDone) is true then
197  log "正常処理"
198else if (item 2 of listDone) ≠ (missing value) then
199  set strErrorNO to (item 2 of listDone)'s code() as text
200  set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
201  refMe's NSLog("■:" & strErrorNO & strErrorMes)
202  log "エラーしました" & strErrorNO & strErrorMes
203  return false
204end if
205########################
206#保存 CMYK
207if numCntLineArray > 4 then
208  set listDone to ocidColorListCMYK's writeToURL:(ocidSaveFilePathURLCMYK) |error| :(reference)
209  if (item 1 of listDone) is true then
210    log "正常処理"
211  else if (item 2 of listDone) ≠ (missing value) then
212    set strErrorNO to (item 2 of listDone)'s code() as text
213    set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
214    refMe's NSLog("■:" & strErrorNO & strErrorMes)
215    log "エラーしました" & strErrorNO & strErrorMes
216    return false
217  end if
218end if
219
220########################
221#保存先を開く
222set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
223set boolDone to appSharedWorkspace's openURL:(ocidSaveDirPathURL)
224if boolDone is true then
225  log "正常処理"
226else if boolDone is false then
227  set strErrorNO to (item 2 of listDone)'s code() as text
228  set strErrorMes to (item 2 of listDone)'s localizedDescription() as text
229  refMe's NSLog("■:" & strErrorNO & strErrorMes)
230  return "エラーしました" & strErrorNO & strErrorMes
231end if
232
233########################
234#RGB変換
235to do8Bit2Float(arg8Bit)
236  set str8Bit to arg8Bit as text
237  set ocid8Bit to refMe's NSDecimalNumber's alloc()'s initWithString:(str8Bit)
238  set ocidDivNo to refMe's NSDecimalNumber's alloc()'s initWithString:("255")
239  #割り算
240  set ocidFloatRaw to (ocid8Bit's decimalNumberByDividingBy:(ocidDivNo))
241  #小数点4位まで
242  set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
243  ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundCeiling)
244  ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle)
245  #ocidFormatter's setUsesGroupingSeparator:(false)
246  ocidFormatter's setMinimumFractionDigits:(1)
247  ocidFormatter's setMaximumFractionDigits:(4)
248  set ocidRoundCeiling to ocidFormatter's stringFromNumber:(ocidFloatRaw)
249  #戻り値はテキストで戻す
250  set strDecimalNo to ocidRoundCeiling as text
251  return strDecimalNo
252  
253end do8Bit2Float
254
255########################
256#CMYK変換
257to doHundred2Float(argStrHundred)
258  set strHundred to argStrHundred as text
259  set ocidHundred to refMe's NSDecimalNumber's alloc()'s initWithString:(strHundred)
260  set ocidDivNo to refMe's NSDecimalNumber's alloc()'s initWithString:("100")
261  #割り算
262  set ocidFloatRaw to (ocidHundred's decimalNumberByDividingBy:(ocidDivNo))
263  #小数点4位まで
264  set ocidFormatter to refMe's NSNumberFormatter's alloc()'s init()
265  ocidFormatter's setRoundingMode:(refMe's NSNumberFormatterRoundCeiling)
266  ocidFormatter's setNumberStyle:(refMe's NSNumberFormatterDecimalStyle)
267  #ocidFormatter's setUsesGroupingSeparator:(false)
268  ocidFormatter's setMinimumFractionDigits:(1)
269  ocidFormatter's setMaximumFractionDigits:(4)
270  set ocidRoundCeiling to ocidFormatter's stringFromNumber:(ocidFloatRaw)
271  #戻り値はテキストで戻す
272  set strDecimalNo to ocidRoundCeiling as text
273  return strDecimalNo
274  
275end doHundred2Float
AppleScriptで生成しました

|

Pantone Color Swatch

同封12種類
PANTONE Color Bridge Coated V5
PANTONE Color Bridge Uncoated V5
PANTONE Formula Guide Solid Coated V5
PANTONE Formula Guide Solid Uncoated V5
PANTONE GoeBridge Coated
PANTONE GoeGuide Coated
PANTONE GoeGuide Uncoated
PANTONE Plus CMYK Coated
PANTONE Plus CMYK Uncoated
PANTONE Plus Metallics coated
PANTONE Plus Pastels and Neons Coated
PANTONE Plus Pastels and Neons Uncoated



ダウンロード - pantone.zip




面倒でも開くから1づつ読み込んだ方いいようです
20240302070555_1176x552


擬似スポット用
HTML

PANTONE Color Bridge Coated V5


PANTONE Color Bridge Uncoated V5


PANTONE Plus CMYK Uncoated

PANTONE GoeBridge Coated


PANTONE Plus CMYK Coated

|

[NSColorList] colorWithKey

#!/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.8"
use framework "Foundation"
use scripting additions
use framework "AppKit"

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString
property objNSColorList : a reference to objMe's NSColorList

property objNSNotFound : a reference to 9.22337203685477E+18 + 5807



set ocidColorListArray to objNSColorList's colorListNamed:"Crayons"
log ocidColorListArray as list
log className() of ocidColorListArray as text


set ocidColorListKeyArray to ocidColorListArray's allKeys()
log ocidColorListKeyArray as list
log className() of ocidColorListKeyArray as text


repeat with ocidColorListKey in ocidColorListKeyArray
set strColorName to ocidColorListKey as text
set ocidColorProperty to contents of ocidColorListKey
set ocidColorContents to (ocidColorListArray's colorWithKey:strColorName)
log strColorName
log "R:" & ocidColorContents's redComponent()
log "G:" & ocidColorContents's greenComponent()
log "B:" & ocidColorContents's blueComponent()
log "A:" & ocidColorContents's alphaComponent()

end repeat


#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

[NSColorList] colorListNamed

#!/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.8"
use framework "Foundation"
use scripting additions
use framework "AppKit"

######ログ表示
doLogView()

property objMe : a reference to current application
property objNSString : a reference to objMe's NSString
property objNSMutableString : a reference to objMe's NSMutableString
property objNSColorList : a reference to objMe's NSColorList

property objNSNotFound : a reference to 9.22337203685477E+18 + 5807




set ocidColorListArray to objNSColorList's colorListNamed:"Crayons"
log ocidColorListArray as list
log className() of ocidColorListArray as text


set ocidColorListKeyArray to ocidColorListArray's allKeys()
log ocidColorListKeyArray as list
log className() of ocidColorListKeyArray as text


repeat with ocidColorListKey in ocidColorListKeyArray
log ocidColorListKey as text
end repeat


#########################ログ表示
to doLogView()

tell application "System Events"
set listAppList to title of (every process where background only is false)
end tell
repeat with objAppList in listAppList
set strAppList to objAppList as text
if strAppList is "スクリプトエディタ" then
tell application "Script Editor"
if frontmost is true then
try
tell application "System Events" to click menu item "ログを表示" of menu "表示" of menu bar item "表示" of menu bar 1 of application process "Script Editor"
end try
end if
end tell
end if
end repeat

end doLogView
#########################

|

その他のカテゴリー

Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom