AppleScript Color

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

|

[8BIT2HEX]8bitカラー値をhex値に変換

8bitカラー値をhex値に変換
record--> NSDictionaryから値を参照する方式(現時点で一番速い
https://quicktimer.cocolog-nifty.com/icefloe/2024/03/post-c6e523.html

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

set strRno to "0"
set strGno to "128"
set strBno to "255"

# printfを使う
set strCommandText to ("/usr/bin/printf \"%02X\" \"" & strRno & "\"") as text
set strRhex to (do shell script strCommandText)
set strCommandText to ("/usr/bin/printf \"%02X\" \"" & strGno & "\"") as text
set strGhex to (do shell script strCommandText)
set strCommandText to ("/usr/bin/printf \"%02X\" \"" & strBno & "\"") as text
set strBhex to (do shell script strCommandText)
set strColorHex to (strRhex & strGhex & strBhex) as text
-->"0080FF"

# printfを使う
set strCommandText to ("/usr/bin/printf \"%02X%02X%02X\" `/bin/echo \"" & strRno & " " & strGno & " " & strBno & "\"`") as text
set strBhex to (do shell script strCommandText)
--> "0080FF"

# perlを使う
set strCommandText to ("/usr/bin/perl -e 'printf(\"%02X\"," & strRno & ")'") as text
set strRhex to (do shell script strCommandText) as text
set strCommandText to ("/usr/bin/perl -e 'printf(\"%02X\"," & strGno & ")'") as text
set strGhex to (do shell script strCommandText) as text
set strCommandText to ("/usr/bin/perl -e 'printf(\"%02X\"," & strBno & ")'") as text
set strBhex to (do shell script strCommandText) as text
set strColorHex to (strRhex & strGhex & strBhex) as text
-->"0080FF"

# python3を使う
set strRGB8Bit to (strRno & strGno & strBno) as text
set strCommandText to ("/usr/bin/python3 -c \"print('%02X%02X%02X' % (" & strRno & "," & strGno & "," & strBno & "))\"") as text
set strRGBHEX to (do shell script strCommandText) as text
-->"0080FF"

|

8bitカラー値をhex値に変換


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
(*
com.cocolog-nifty.quicktimer.icefloe


*)
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application


log getHex(0)
-->(*00*)
log getHex(128)
-->(*80*)
log getHex(255)
-->(*FF*)


##############################
#サブ
##############################
to getHex(arg8BitNum)
  set record8Bit2Hex to {|0|:"00", |1|:"01", |2|:"02", |3|:"03", |4|:"04", |5|:"05", |6|:"06", |7|:"07", |8|:"08", |9|:"09", |10|:"0A", |11|:"0B", |12|:"0C", |13|:"0D", |14|:"0E", |15|:"0F", |16|:"10", |17|:"11", |18|:"12", |19|:"13", |20|:"14", |21|:"15", |22|:"16", |23|:"17", |24|:"18", |25|:"19", |26|:"1A", |27|:"1B", |28|:"1C", |29|:"1D", |30|:"1E", |31|:"1F", |32|:"20", |33|:"21", |34|:"22", |35|:"23", |36|:"24", |37|:"25", |38|:"26", |39|:"27", |40|:"28", |41|:"29", |42|:"2A", |43|:"2B", |44|:"2C", |45|:"2D", |46|:"2E", |47|:"2F", |48|:"30", |49|:"31", |50|:"32", |51|:"33", |52|:"34", |53|:"35", |54|:"36", |55|:"37", |56|:"38", |57|:"39", |58|:"3A", |59|:"3B", |60|:"3C", |61|:"3D", |62|:"3E", |63|:"3F", |64|:"40", |65|:"41", |66|:"42", |67|:"43", |68|:"44", |69|:"45", |70|:"46", |71|:"47", |72|:"48", |73|:"49", |74|:"4A", |75|:"4B", |76|:"4C", |77|:"4D", |78|:"4E", |79|:"4F", |80|:"50", |81|:"51", |82|:"52", |83|:"53", |84|:"54", |85|:"55", |86|:"56", |87|:"57", |88|:"58", |89|:"59", |90|:"5A", |91|:"5B", |92|:"5C", |93|:"5D", |94|:"5E", |95|:"5F", |96|:"60", |97|:"61", |98|:"62", |99|:"63", |100|:"64", |101|:"65", |102|:"66", |103|:"67", |104|:"68", |105|:"69", |106|:"6A", |107|:"6B", |108|:"6C", |109|:"6D", |110|:"6E", |111|:"6F", |112|:"70", |113|:"71", |114|:"72", |115|:"73", |116|:"74", |117|:"75", |118|:"76", |119|:"77", |120|:"78", |121|:"79", |122|:"7A", |123|:"7B", |124|:"7C", |125|:"7D", |126|:"7E", |127|:"7F", |128|:"80", |129|:"81", |130|:"82", |131|:"83", |132|:"84", |133|:"85", |134|:"86", |135|:"87", |136|:"88", |137|:"89", |138|:"8A", |139|:"8B", |140|:"8C", |141|:"8D", |142|:"8E", |143|:"8F", |144|:"90", |145|:"91", |146|:"92", |147|:"93", |148|:"94", |149|:"95", |150|:"96", |151|:"97", |152|:"98", |153|:"99", |154|:"9A", |155|:"9B", |156|:"9C", |157|:"9D", |158|:"9E", |159|:"9F", |160|:"A0", |161|:"A1", |162|:"A2", |163|:"A3", |164|:"A4", |165|:"A5", |166|:"A6", |167|:"A7", |168|:"A8", |169|:"A9", |170|:"AA", |171|:"AB", |172|:"AC", |173|:"AD", |174|:"AE", |175|:"AF", |176|:"B0", |177|:"B1", |178|:"B2", |179|:"B3", |180|:"B4", |181|:"B5", |182|:"B6", |183|:"B7", |184|:"B8", |185|:"B9", |186|:"BA", |187|:"BB", |188|:"BC", |189|:"BD", |190|:"BE", |191|:"BF", |192|:"C0", |193|:"C1", |194|:"C2", |195|:"C3", |196|:"C4", |197|:"C5", |198|:"C6", |199|:"C7", |200|:"C8", |201|:"C9", |202|:"CA", |203|:"CB", |204|:"CC", |205|:"CD", |206|:"CE", |207|:"CF", |208|:"D0", |209|:"D1", |210|:"D2", |211|:"D3", |212|:"D4", |213|:"D5", |214|:"D6", |215|:"D7", |216|:"D8", |217|:"D9", |218|:"DA", |219|:"DB", |220|:"DC", |221|:"DD", |222|:"DE", |223|:"DF", |224|:"E0", |225|:"E1", |226|:"E2", |227|:"E3", |228|:"E4", |229|:"E5", |230|:"E6", |231|:"E7", |232|:"E8", |233|:"E9", |234|:"EA", |235|:"EB", |236|:"EC", |237|:"ED", |238|:"EE", |239|:"EF", |240|:"F0", |241|:"F1", |242|:"F2", |243|:"F3", |244|:"F4", |245|:"F5", |246|:"F6", |247|:"F7", |248|:"F8", |249|:"F9", |250|:"FA", |251|:"FB", |252|:"FC", |253|:"FD", |254|:"FE", |255|:"FF"} as record
  set ocid8Bit2HexDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocid8Bit2HexDict's setDictionary:(record8Bit2Hex)
  set str8BitNum to arg8BitNum as string
  set ocidValue to (ocid8Bit2HexDict's valueForKey:(str8BitNum))
  set strValue to ocidValue as text
return strValue
end getHex

|

カラーモード判定


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()


set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
###ダイアログ
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set listUTI to {"public.image"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set listAliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles, showing package contents and multiple selections allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try

set numCntFile to (count of listAliasFilePath) as integer
tell application "Image Events" to activate
repeat with itemIntNo from 1 to numCntFile by 1
  tell application "Image Events"
    set objImage to open item numCntFile of listAliasFilePath
    set strColorSpace to (color space of objImage) as text
    if strColorSpace is "RGB" then
log "カラーは" & strColorSpace & "です"
      
    else if strColorSpace is "CMYK" then
log "カラーは" & strColorSpace & "です"
      
    end if
close objImage
  end tell
end repeat



#!/bin/bash
#com.cocolog-nifty.quicktimer.icefloe
#################################################

STR_FILE_PATH="/Library/User Pictures/Fun/Medal.heic"

STR_RESPONSE=$(/usr/bin/sips --getProperty space "$STR_FILE_PATH")
/bin/echo "$STR_RESPONSE"

if [[ "$STR_RESPONSE" == *CMYK* ]]; then
/bin/echo "CMYK画像です"

elif [[ "$STR_RESPONSE" == *RGB* ]]; then
/bin/echo "RGB画像です"

fi

exit 0


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property refMe : a reference to current application
set appFileManager to refMe's NSFileManager's defaultManager()


set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDesktopDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDesktopDirPathURL to ocidURLsArray's firstObject()
set aliasDefaultLocation to (ocidDesktopDirPathURL's absoluteURL()) as alias
###ダイアログ
tell current application
  set strName to name as text
end tell
####スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set listUTI to {"public.image"}
set strMes to ("ファイルを選んでください") as text
set strPrompt to ("ファイルを選んでください") as text
try
  ### ファイル選択時
  set listAliasFilePath to (choose file strMes with prompt strPrompt default location (aliasDefaultLocation) of type listUTI with invisibles, showing package contents and multiple selections allowed) as list
on error
log "エラーしました"
return "エラーしました"
end try

repeat with itemAliasFilePath in listAliasFilePath
  set aliasFilePath to itemAliasFilePath as alias
  set strFilePath to (POSIX path of aliasFilePath) as text
  set strCommandText to ("/usr/bin/sips --getProperty space \"" & strFilePath & "\"")
  set strResponse to (do shell script strCommandText) as text
  if strResponse contains "RGB" then
log "カラーはRGBです"
    
  else if strResponse contains "CMYK" then
log "カラーはCMYKです"
    
  end if
end repeat


|

HEXカラー値を取得する

色々やったけど、結局この方法が一番速いような『気がする』ので

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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "UniformTypeIdentifiers"
use framework "AppKit"
use scripting additions
property refMe : a reference to current application


#####RGB16bitColorに16bitRGB値を格納
#####ダイアログを前面に
##############################
tell current application
  set strName to name as text
end tell
###スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set the listRGB16bitColor to (choose color default color {65535, 55535, 0, 0.5}) as list
##########Color Picker Value 16Bit
set numRcolor to item 1 of listRGB16bitColor as number
set numGcolor to item 2 of listRGB16bitColor as number
set numBcolor to item 3 of listRGB16bitColor as number
set numAcolor to 65535 as number

set intRcolor to ((numRcolor / 65535) * 255) as integer
set intGcolor to ((numGcolor / 65535) * 255) as integer
set intBcolor to ((numBcolor / 65535) * 255) as integer
set intAcolor to ((numAcolor / 65535) * 255) as integer

set strHexR to getHex(intRcolor)
set strHexG to getHex(intGcolor)
set strHexB to getHex(intBcolor)

#戻すテキスト ここは工夫次第
set strDisptext to ("#" & strHexR & strHexG & strHexB & "\ncolor:" & "#" & strHexR & strHexG & strHexB & "\ncolor:rgb(" & intRcolor & "," & intGcolor & "," & intBcolor & ")") as text

------ダイアログ表示用のテキスト
set theRGB8bitColor to "R:" & intRcolor & " G:" & intGcolor & " B:" & intBcolor as text
##############################
#####ダイアログを前面に
tell current application
  set strName to name as text
end tell
###スクリプトメニューから実行したら
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
set aliasIconPath to POSIX file "/System/Applications/Utilities/Digital Color Meter.app/Contents/Resources/AppIcon.icns" as alias
set strTitle to ("コードをコピーしてください") as text
set strMes to ("" & theRGB8bitColor & " のHexColorが\n出来ました\nコピーして使って下さい。") as text
set recordResult to (display dialog strMes default answer the strDisptext with icon aliasIconPath with title strTitle buttons {"クリップボードにコピー", "OK", "キャンセル"} default button "OK" cancel button "キャンセル" giving up after 20 without hidden answer) as record

if button returned of recordResult is "クリップボードにコピー" then
  try
    set strText to text returned of recordResult as text
    ####ペーストボード宣言
    set appPasteboard to refMe's NSPasteboard's generalPasteboard()
    set ocidText to (refMe's NSString's stringWithString:(strText))
appPasteboard's clearContents()
appPasteboard's setString:(ocidText) forType:(refMe's NSPasteboardTypeString)
  on error
    tell application "Finder"
      set the clipboard to strTitle as text
    end tell
  end try
end if


property record8Bit2Hex : {|0|:"00", |1|:"01", |2|:"02", |3|:"03", |4|:"04", |5|:"05", |6|:"06", |7|:"07", |8|:"08", |9|:"09", |10|:"0A", |11|:"0B", |12|:"0C", |13|:"0D", |14|:"0E", |15|:"0F", |16|:"10", |17|:"11", |18|:"12", |19|:"13", |20|:"14", |21|:"15", |22|:"16", |23|:"17", |24|:"18", |25|:"19", |26|:"1A", |27|:"1B", |28|:"1C", |29|:"1D", |30|:"1E", |31|:"1F", |32|:"20", |33|:"21", |34|:"22", |35|:"23", |36|:"24", |37|:"25", |38|:"26", |39|:"27", |40|:"28", |41|:"29", |42|:"2A", |43|:"2B", |44|:"2C", |45|:"2D", |46|:"2E", |47|:"2F", |48|:"30", |49|:"31", |50|:"32", |51|:"33", |52|:"34", |53|:"35", |54|:"36", |55|:"37", |56|:"38", |57|:"39", |58|:"3A", |59|:"3B", |60|:"3C", |61|:"3D", |62|:"3E", |63|:"3F", |64|:"40", |65|:"41", |66|:"42", |67|:"43", |68|:"44", |69|:"45", |70|:"46", |71|:"47", |72|:"48", |73|:"49", |74|:"4A", |75|:"4B", |76|:"4C", |77|:"4D", |78|:"4E", |79|:"4F", |80|:"50", |81|:"51", |82|:"52", |83|:"53", |84|:"54", |85|:"55", |86|:"56", |87|:"57", |88|:"58", |89|:"59", |90|:"5A", |91|:"5B", |92|:"5C", |93|:"5D", |94|:"5E", |95|:"5F", |96|:"60", |97|:"61", |98|:"62", |99|:"63", |100|:"64", |101|:"65", |102|:"66", |103|:"67", |104|:"68", |105|:"69", |106|:"6A", |107|:"6B", |108|:"6C", |109|:"6D", |110|:"6E", |111|:"6F", |112|:"70", |113|:"71", |114|:"72", |115|:"73", |116|:"74", |117|:"75", |118|:"76", |119|:"77", |120|:"78", |121|:"79", |122|:"7A", |123|:"7B", |124|:"7C", |125|:"7D", |126|:"7E", |127|:"7F", |128|:"80", |129|:"81", |130|:"82", |131|:"83", |132|:"84", |133|:"85", |134|:"86", |135|:"87", |136|:"88", |137|:"89", |138|:"8A", |139|:"8B", |140|:"8C", |141|:"8D", |142|:"8E", |143|:"8F", |144|:"90", |145|:"91", |146|:"92", |147|:"93", |148|:"94", |149|:"95", |150|:"96", |151|:"97", |152|:"98", |153|:"99", |154|:"9A", |155|:"9B", |156|:"9C", |157|:"9D", |158|:"9E", |159|:"9F", |160|:"A0", |161|:"A1", |162|:"A2", |163|:"A3", |164|:"A4", |165|:"A5", |166|:"A6", |167|:"A7", |168|:"A8", |169|:"A9", |170|:"AA", |171|:"AB", |172|:"AC", |173|:"AD", |174|:"AE", |175|:"AF", |176|:"B0", |177|:"B1", |178|:"B2", |179|:"B3", |180|:"B4", |181|:"B5", |182|:"B6", |183|:"B7", |184|:"B8", |185|:"B9", |186|:"BA", |187|:"BB", |188|:"BC", |189|:"BD", |190|:"BE", |191|:"BF", |192|:"C0", |193|:"C1", |194|:"C2", |195|:"C3", |196|:"C4", |197|:"C5", |198|:"C6", |199|:"C7", |200|:"C8", |201|:"C9", |202|:"CA", |203|:"CB", |204|:"CC", |205|:"CD", |206|:"CE", |207|:"CF", |208|:"D0", |209|:"D1", |210|:"D2", |211|:"D3", |212|:"D4", |213|:"D5", |214|:"D6", |215|:"D7", |216|:"D8", |217|:"D9", |218|:"DA", |219|:"DB", |220|:"DC", |221|:"DD", |222|:"DE", |223|:"DF", |224|:"E0", |225|:"E1", |226|:"E2", |227|:"E3", |228|:"E4", |229|:"E5", |230|:"E6", |231|:"E7", |232|:"E8", |233|:"E9", |234|:"EA", |235|:"EB", |236|:"EC", |237|:"ED", |238|:"EE", |239|:"EF", |240|:"F0", |241|:"F1", |242|:"F2", |243|:"F3", |244|:"F4", |245|:"F5", |246|:"F6", |247|:"F7", |248|:"F8", |249|:"F9", |250|:"FA", |251|:"FB", |252|:"FC", |253|:"FD", |254|:"FE", |255|:"FF"} as record

##############################
#
##############################
to getHex(arg8BitNum)
  set ocid8Bit2HexDict to refMe's NSMutableDictionary's alloc()'s initWithCapacity:0
ocid8Bit2HexDict's setDictionary:(record8Bit2Hex)
  set str8BitNum to arg8BitNum as string
  set ocidValue to (ocid8Bit2HexDict's valueForKey:(str8BitNum))
  set strValue to ocidValue as text
return strValue
end getHex

|

ホワイトポイント

Screen_1



D50は、暖色系の光源に近いため「暖色温度」色温度が5004K
D65は「標準昼光」または「昼光光源」色温度が6504K
D75は「寒色昼光」の標準光源 色温度が7504K

|

[PDF]イメージPDFでカラーパッチを作成する


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "CoreImage"
use scripting additions

property refMe : a reference to current application


##############################
#####ダイアログ
##############################
##前面に出す
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###カラーピッカー
try
  set the listRGB16bitColor to (choose color) as list
on error
return "キャンセルしました"
end try

##########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
##########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 strRcolor8Bit to numRcolor8Bit as text
set strGcolor8Bit to numGcolor8Bit as text
set strBcolor8Bit to numBcolor8Bit as text
##########NSColorValue Float
set numRcolorFloat to numRcolor8Bit / 255 as number
set numGcolorFloat to numGcolor8Bit / 255 as number
set numBcolorFloat to numBcolor8Bit / 255 as number
###
set strRGB8Bit to ((strRcolor8Bit) & "," & (strGcolor8Bit) & "," & (strBcolor8Bit)) as text
###
set strCommandText to ("/usr/bin/perl -e 'printf(\"%02X%02X%02X\"," & strRGB8Bit & ")'") as text
set strRGBHEX to (do shell script strCommandText) as text
set strRGBHEXenc to ("%23" & strRGBHEX) as text
set strRGBHEX to ("#" & strRGBHEX) as text
################################################
###画像サイズ
set intWidthPx to 720 as integer
set intHightPx to 960 as integer

###################################################
##【1】カラーチップ用画像生成
set ocidBitmapFormat to refMe's NSBitmapFormatAlphaFirst
set ocidColorSpaceName to refMe's NSDeviceRGBColorSpace
set ocidNSBitmapImageFileType to refMe's NSBitmapImageFileTypeTIFF
set ocidColorBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(intWidthPx) pixelsHigh:(intWidthPx) bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
###初期化
refMe's NSGraphicsContext's saveGraphicsState()
###Context
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidColorBoardRep))
###生成された画像でNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###塗り色
set ocidSetColor to (refMe's NSColor's colorWithDeviceRed:(numRcolorFloat) green:(numGcolorFloat) blue:(numBcolorFloat) alpha:1)
ocidSetColor's |set|()
##画像にする
refMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:intWidthPx, height:intWidthPx}})
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()

###################################################
##【2】アートボード画像生成開始
set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(intWidthPx) pixelsHigh:(intHightPx) bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
###初期化
refMe's NSGraphicsContext's saveGraphicsState()
###Context
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
###生成された画像でNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###塗り色
set ocidSetColor to (refMe's NSColor's colorWithDeviceRed:(1) green:(1) blue:(1) alpha:1)
ocidSetColor's |set|()
##画像にする
refMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:intWidthPx, height:intHightPx}})
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()

###################################################
##【3】テキスト生成
###設定用のレコード
set ocidTextAttr to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
###################
###文字色
set ocidTextColor to (refMe's NSColor's colorWithSRGBRed:(numRcolorFloat) green:(numGcolorFloat) blue:(numBcolorFloat) alpha:(1))
(ocidTextAttr's setObject:(ocidTextColor) forKey:(refMe's NSForegroundColorAttributeName))
###################
##行間
set ocidStyle to refMe's NSParagraphStyle's defaultParagraphStyle
(ocidTextAttr's setObject:(ocidStyle) forKey:(refMe's NSParagraphStyleAttributeName))
###################
##カーニング
set ocidKern to 0
(ocidTextAttr's setObject:(ocidKern) forKey:(refMe's NSKernAttributeName))
##ドロップシャドウ
set ocidShadow to refMe's NSShadow's alloc()'s init()
set ocidShadowColor to (refMe's NSColor's colorWithDeviceRed:0 green:0 blue:0 alpha:0.5)
(ocidShadow's setShadowColor:(ocidShadowColor))
(ocidShadow's setShadowOffset:(refMe's NSMakeSize(1, -1)))
(ocidShadow's setShadowBlurRadius:4)
(ocidTextAttr's setObject:(ocidShadow) forKey:(refMe's NSShadowAttributeName))
###描画するテキスト
set ocidTextHEX to (refMe's NSString's stringWithString:(strRGBHEX))
##フォント サイズ
set ocidFont to (refMe's NSFont's fontWithName:("Helvetica-Bold") |size|:144)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
####描画されるテキストボックスのサイズ
set ocidTextSizeHEX to (ocidTextHEX's sizeWithAttributes:(ocidTextAttr))
set ocidTextCgPointHEX to refMe's NSMakePoint(20, 100)

###################################
#####テキスト描画 本処理 HEX
####NSGraphicsContextは2で作ったアートボード
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
###初期化
refMe's NSGraphicsContext's saveGraphicsState()
###透明アートボードでNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###テキスト描画する
(ocidTextHEX's drawAtPoint:(ocidTextCgPointHEX) withAttributes:(ocidTextAttr))
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()
#####################
###描画するテキスト
set ocidTextRGB to (refMe's NSString's stringWithString:("rgb(" & strRcolor8Bit & ", " & strGcolor8Bit & ", " & strBcolor8Bit & ")"))
##フォント サイズ
set ocidFont to (refMe's NSFont's fontWithName:("Helvetica-Bold") |size|:72)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
####描画されるテキストボックスのサイズ
set ocidTextSizeRGB to (ocidTextRGB's sizeWithAttributes:(ocidTextAttr))
set ocidTextCgPointRGB to refMe's NSMakePoint(20, 20)
###################################
#####テキスト描画 本処理 RGB
####NSGraphicsContextは2で作ったアートボード
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
###初期化
refMe's NSGraphicsContext's saveGraphicsState()
###透明アートボードでNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###テキスト描画する
(ocidTextRGB's drawAtPoint:(ocidTextCgPointRGB) withAttributes:(ocidTextAttr))
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()


###################################################
##【4】1で作った色画像を2で作ったアートボードにペーストNSCompositeSourceOver
###初期化 CodeBase
refMe's NSGraphicsContext's saveGraphicsState()
###Context
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
###生成された画像でNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###出来上がった画像にQRバーコードをCompositeSourceOverする
ocidColorBoardRep's drawInRect:{origin:{x:(0), y:(240)}, |size|:{width:(intWidthPx), Hight:(intWidthPx)}} fromRect:{origin:{x:0, y:0}, |size|:{width:(intWidthPx), height:(intWidthPx)}} operation:(refMe's NSCompositeSourceOver) fraction:1.0 respectFlipped:true hints:(missing value)
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()

#############################
### 【5】画像データ
#############################
####TIFF用の圧縮プロパティ
set ocidNSSingleEntryDictionary to refMe's NSDictionary's dictionaryWithObject:1 forKey:(refMe's NSImageCompressionMethod)
#####出力イメージへ変換
set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypeTIFF) |properties|:ocidNSSingleEntryDictionary)


#############################
### 【6】PDF
#############################
set ocidOutPutData to (refMe's NSImage's alloc()'s initWithData:ocidNSInlineData)
set ocidPDFDocument to refMe's PDFDocument's alloc()'s init()
set ocidPdfPage to refMe's PDFPage's alloc()'s initWithImage:(ocidOutPutData)
(ocidPDFDocument's insertPage:(ocidPdfPage) atIndex:0)

#####################
### 保存先 NSDownloadsDirectory
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDownloadsDirPathURL to ocidURLsArray's firstObject()
###保存ファイル名
set strSaveFileName to (strRGBHEX & ".pdf") as text
set ocidSaveFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strSaveFileName)
### 保存
###PDFの保存オプション
set ocidOptionDict to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
ocidOptionDict's setValue:(false) forKey:(refMe's PDFDocumentOptimizeImagesForScreenOption)
ocidOptionDict's setValue:(false) forKey:(refMe's PDFDocumentSaveImagesAsJPEGOption)

set boolDone to ocidPDFDocument's writeToURL:(ocidSaveFilePathURL) withOptions:(ocidOptionDict)
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias


##################
##リンクさせる場合(レスポンシブ)
set strHTML to ("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>" & strRGBHEX & "</title><style>body{background-color: #FFFFF;}</style></head><body><img src=\"./" & strRGBHEXenc & ".pdf\" style=\"height: 82vh; margin-top: 9vh; margin-left: 9vh\"><p>" & strRGBHEX & "</p><p>" & "rgb(" & strRcolor8Bit & ", " & strGcolor8Bit & ", " & strBcolor8Bit & ")" & "</p></body></html>") as text


##データにして
set ocidSaveHTML to refMe's NSString's stringWithString:(strHTML)
##保存
set strFileName to (strRGBHEX & ".html") as text
set ocidHTMLFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strFileName)
set listDone to (ocidSaveHTML's writeToURL:(ocidHTMLFilePathURL) atomically:(refMe's NSNumber's numberWithBool:true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))


###
set appSharedWorkSpave to refMe's NSWorkspace's sharedWorkspace()
set boolDone to appSharedWorkSpave's selectFile:(ocidSaveFilePathURL's |path|) inFileViewerRootedAtPath:(ocidDownloadsDirPathURL's |path|)



|

[PNG]PNGイメージファイルのカラーパッチを作成する


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use framework "CoreImage"
use scripting additions

property refMe : a reference to current application


##############################
#####ダイアログ
##############################
##前面に出す
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###カラーピッカー
try
  set the listRGB16bitColor to (choose color) as list
on error
return "キャンセルしました"
end try

##########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
##########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 strRcolor8Bit to numRcolor8Bit as text
set strGcolor8Bit to numGcolor8Bit as text
set strBcolor8Bit to numBcolor8Bit as text
##########NSColorValue Float
set numRcolorFloat to numRcolor8Bit / 255 as number
set numGcolorFloat to numGcolor8Bit / 255 as number
set numBcolorFloat to numBcolor8Bit / 255 as number
###
set strRGB8Bit to ((strRcolor8Bit) & "," & (strGcolor8Bit) & "," & (strBcolor8Bit)) as text
###
set strCommandText to ("/usr/bin/perl -e 'printf(\"%02X%02X%02X\"," & strRGB8Bit & ")'") as text
set strRGBHEX to (do shell script strCommandText) as text
set strRGBHEXenc to ("%23" & strRGBHEX) as text
set strRGBHEX to ("#" & strRGBHEX) as text
################################################
###画像サイズ
set intWidthPx to 720 as integer
set intHightPx to 960 as integer

###################################################
##【1】カラーチップ用画像生成
set ocidBitmapFormat to refMe's NSBitmapFormatAlphaFirst
set ocidColorSpaceName to refMe's NSDeviceRGBColorSpace
set ocidNSBitmapImageFileType to refMe's NSBitmapImageFileTypePNG
set ocidColorBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(intWidthPx) pixelsHigh:(intWidthPx) bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
###初期化
refMe's NSGraphicsContext's saveGraphicsState()
###Context
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidColorBoardRep))
###生成された画像でNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###塗り色
set ocidSetColor to (refMe's NSColor's colorWithDeviceRed:(numRcolorFloat) green:(numGcolorFloat) blue:(numBcolorFloat) alpha:1)
ocidSetColor's |set|()
##画像にする
refMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:intWidthPx, height:intWidthPx}})
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()

###################################################
##【2】アートボード画像生成開始
set ocidArtBoardRep to (refMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:(intWidthPx) pixelsHigh:(intHightPx) bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(ocidColorSpaceName) bitmapFormat:(ocidBitmapFormat) bytesPerRow:0 bitsPerPixel:32)
###初期化
refMe's NSGraphicsContext's saveGraphicsState()
###Context
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
###生成された画像でNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###塗り色
set ocidSetColor to (refMe's NSColor's colorWithDeviceRed:(1) green:(1) blue:(1) alpha:1)
ocidSetColor's |set|()
##画像にする
refMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:intWidthPx, height:intHightPx}})
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()

###################################################
##【3】テキスト生成
###設定用のレコード
set ocidTextAttr to (refMe's NSMutableDictionary's alloc()'s initWithCapacity:0)
###################
###文字色
set ocidTextColor to (refMe's NSColor's colorWithSRGBRed:(numRcolorFloat) green:(numGcolorFloat) blue:(numBcolorFloat) alpha:(1))
(ocidTextAttr's setObject:(ocidTextColor) forKey:(refMe's NSForegroundColorAttributeName))
###################
##行間
set ocidStyle to refMe's NSParagraphStyle's defaultParagraphStyle
(ocidTextAttr's setObject:(ocidStyle) forKey:(refMe's NSParagraphStyleAttributeName))
###################
##カーニング
set ocidKern to 0
(ocidTextAttr's setObject:(ocidKern) forKey:(refMe's NSKernAttributeName))
##ドロップシャドウ
set ocidShadow to refMe's NSShadow's alloc()'s init()
set ocidShadowColor to (refMe's NSColor's colorWithDeviceRed:0 green:0 blue:0 alpha:0.5)
(ocidShadow's setShadowColor:(ocidShadowColor))
(ocidShadow's setShadowOffset:(refMe's NSMakeSize(1, -1)))
(ocidShadow's setShadowBlurRadius:4)
(ocidTextAttr's setObject:(ocidShadow) forKey:(refMe's NSShadowAttributeName))
###描画するテキスト
set ocidTextHEX to (refMe's NSString's stringWithString:(strRGBHEX))
##フォント サイズ
set ocidFont to (refMe's NSFont's fontWithName:("Helvetica-Bold") |size|:144)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
####描画されるテキストボックスのサイズ
set ocidTextSizeHEX to (ocidTextHEX's sizeWithAttributes:(ocidTextAttr))
set ocidTextCgPointHEX to refMe's NSMakePoint(20, 100)

###################################
#####テキスト描画 本処理 HEX
####NSGraphicsContextは2で作ったアートボード
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
###初期化
refMe's NSGraphicsContext's saveGraphicsState()
###透明アートボードでNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###テキスト描画する
(ocidTextHEX's drawAtPoint:(ocidTextCgPointHEX) withAttributes:(ocidTextAttr))
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()
#####################
###描画するテキスト
set ocidTextRGB to (refMe's NSString's stringWithString:("rgb(" & strRcolor8Bit & ", " & strGcolor8Bit & ", " & strBcolor8Bit & ")"))
##フォント サイズ
set ocidFont to (refMe's NSFont's fontWithName:("Helvetica-Bold") |size|:72)
(ocidTextAttr's setObject:(ocidFont) forKey:(refMe's NSFontAttributeName))
####描画されるテキストボックスのサイズ
set ocidTextSizeRGB to (ocidTextRGB's sizeWithAttributes:(ocidTextAttr))
set ocidTextCgPointRGB to refMe's NSMakePoint(20, 20)
###################################
#####テキスト描画 本処理 RGB
####NSGraphicsContextは2で作ったアートボード
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
###初期化
refMe's NSGraphicsContext's saveGraphicsState()
###透明アートボードでNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###テキスト描画する
(ocidTextRGB's drawAtPoint:(ocidTextCgPointRGB) withAttributes:(ocidTextAttr))
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()


###################################################
##【4】1で作った色画像を2で作ったアートボードにペーストNSCompositeSourceOver
###初期化 CodeBase
refMe's NSGraphicsContext's saveGraphicsState()
###Context
set ocidContext to (refMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:(ocidArtBoardRep))
###生成された画像でNSGraphicsContext初期化
(refMe's NSGraphicsContext's setCurrentContext:(ocidContext))
###出来上がった画像にQRバーコードをCompositeSourceOverする
ocidColorBoardRep's drawInRect:{origin:{x:(0), y:(240)}, |size|:{width:(intWidthPx), Hight:(intWidthPx)}} fromRect:{origin:{x:0, y:0}, |size|:{width:(intWidthPx), height:(intWidthPx)}} operation:(refMe's NSCompositeSourceOver) fraction:1.0 respectFlipped:true hints:(missing value)
####画像作成終了
refMe's NSGraphicsContext's restoreGraphicsState()

#############################
### 【5】画像データ保存
### 4で生成された画像に対を
### 指定のフォルダに保存する
#############################
####PNG用の圧縮プロパティ
set ocidNSSingleEntryDictionary to refMe's NSDictionary's dictionaryWithObject:true forKey:(refMe's NSImageInterlaced)
#####出力イメージへ変換
set ocidNSInlineData to (ocidArtBoardRep's representationUsingType:(refMe's NSBitmapImageFileTypePNG) |properties|:ocidNSSingleEntryDictionary)
#####################
### 保存先 NSDownloadsDirectory
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDownloadsDirPathURL to ocidURLsArray's firstObject()
###保存ファイル名
set strSaveFileName to (strRGBHEX & ".png") as text
set ocidSaveFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strSaveFileName)
### 保存
set ocidOption to (refMe's NSDataWritingAtomic)
set boolDone to ocidNSInlineData's writeToURL:(ocidSaveFilePathURL) options:(ocidOption) |error|:(reference)
set aliasSaveFilePath to (ocidSaveFilePathURL's absoluteURL()) as alias



##################
##リンクさせる場合(レスポンシブ)
set strHTML to ("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>" & strRGBHEX & "</title><style>body{background-color: #FFFFF;}</style></head><body><img src=\"./" & strRGBHEXenc & ".png\" style=\"height: 82vh; margin-top: 9vh; margin-left: 9vh\"><p>" & strRGBHEX & "</p><p>" & "rgb(" & strRcolor8Bit & ", " & strGcolor8Bit & ", " & strBcolor8Bit & ")" & "</p></body></html>") as text


##データにして
set ocidSaveHTML to refMe's NSString's stringWithString:(strHTML)
##保存
set strFileName to (strRGBHEX & ".html") as text
set ocidHTMLFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strFileName)
set listDone to (ocidSaveHTML's writeToURL:(ocidHTMLFilePathURL) atomically:(refMe's NSNumber's numberWithBool:true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))

###保存先を開く
set appSharedWorkSpave to refMe's NSWorkspace's sharedWorkspace()
set boolDone to appSharedWorkSpave's selectFile:(ocidSaveFilePathURL's |path|) inFileViewerRootedAtPath:(ocidDownloadsDirPathURL's |path|)



|

[SVG]SVGからPDFのカラーチップを作る


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
(*
クロームの印刷機能を使いますので
Google Chromeのインストールが必須です
*)
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


##############################
#####ダイアログ
##############################
##前面に出す
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###カラーピッカー
try
  set the listRGB16bitColor to (choose color) as list
on error
return "キャンセルしました"
end try

##########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
##########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 strRcolor8Bit to numRcolor8Bit as text
set strGcolor8Bit to numGcolor8Bit as text
set strBcolor8Bit to numBcolor8Bit as text
##########NSColorValue Float
set numRcolorFloat to numRcolor8Bit / 255 as number
set numGcolorFloat to numGcolor8Bit / 255 as number
set numBcolorFloat to numBcolor8Bit / 255 as number
###
set strRGB8Bit to ((strRcolor8Bit) & "," & (strGcolor8Bit) & "," & (strBcolor8Bit)) as text
###
set strCommandText to ("/usr/bin/perl -e 'printf(\"%02X%02X%02X\"," & strRGB8Bit & ")'") as text
set strRGBHEX to (do shell script strCommandText) as text
set strRGBHEXenc to ("%23" & strRGBHEX) as text
set strRGBHEX to ("#" & strRGBHEX) as text
##
set strSVG to ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg height=\"960.0px\" stroke-miterlimit=\"10\" style=\"background-color: #ffffff;fill-rule:nonzero;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;\" version=\"1.1\" viewBox=\"0 0 720 960\" width=\"720.0px\" xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><path d=\"M0 0L720 0L720 960L0 960L0 0Z\" fill=\"#ffffff\" fill-rule=\"nonzero\" opacity=\"1\" stroke=\"none\"/><clipPath id=\"ArtboardFrame\"><rect height=\"960\" width=\"720\" x=\"0\" y=\"0\"/></clipPath><g clip-path=\"url(#ArtboardFrame)\" id=\"" & strRGBHEX & "\"><path d=\"M-1.13687e-13 0L720 0L720 720L-1.13687e-13 720L-1.13687e-13 0Z\" fill=\"" & strRGBHEX & "\" fill-rule=\"nonzero\" opacity=\"1\" stroke=\"none\"/><text fill=\"" & strRGBHEX & "\" font-family=\"Helvetica-Bold\" font-size=\"144\" opacity=\"1\" stroke=\"none\" text-anchor=\"start\" transform=\"matrix(1 0 0 1 36 720)\" x=\"0\" y=\"0\"><tspan textLength=\"620\" x=\"0\" y=\"140\">" & strRGBHEX & "</tspan></text><text fill=\"" & strRGBHEX & "\" font-family=\"Helvetica-Bold\" font-size=\"36\" opacity=\"1\" stroke=\"none\" text-anchor=\"start\" transform=\"matrix(1 0 0 1 36 881.244)\" x=\"0\" y=\"0\"><tspan textLength=\"520\" x=\"0\" y=\"35\">rgb(" & strRcolor8Bit & ", " & strGcolor8Bit & ", " & strBcolor8Bit & ")</tspan></text></g></svg>") as text

###ダウンロードフォルダ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDownloadsDirPathURL to ocidURLsArray's firstObject()
###ファイル名はHEX値
set strFileName to (strRGBHEX & ".svg") as text
set ocidSaveFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strFileName)
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
##データにして
set ocidSaveSVG to refMe's NSString's stringWithString:(strSVG)
##保存
set listDone to (ocidSaveSVG's writeToURL:(ocidSaveFilePathURL) atomically:(refMe's NSNumber's numberWithBool:true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
##################
##HTML出力
##リンクさせる場合(レスポンシブ)
set strHTML to ("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>" & strRGBHEX & "</title><style>body{background-color: #FFFFF;}</style></head><body><img src=\"./" & strRGBHEXenc & ".svg\" style=\"height: 96vh; margin-top: 2vh; margin-bottom: 2vh;margin-left: 2vh\"></body></html>") as text
##埋め込む場合
## set strHTML to ("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>" & strRGBHEX & "</title><style>body{background-color: #FFFFF;}</style></head><body>" & strSVG & "</body></html>") as text

##データにして
set ocidSaveHTML to refMe's NSString's stringWithString:(strHTML)
##保存
set strFileName to (strRGBHEX & ".html") as text
set ocidHTMLFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strFileName)
set listDone to (ocidSaveHTML's writeToURL:(ocidHTMLFilePathURL) atomically:(refMe's NSNumber's numberWithBool:true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
##################
##PDF出力
##クロームのインストール先URLを取得
set strBundleID to "com.google.Chrome" as text
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
set appSharedWorkspace to refMe's NSWorkspace's sharedWorkspace()
set ocidAppBundle to (refMe's NSBundle's bundleWithIdentifier:(strBundleID))
if ocidAppBundle ≠ (missing value) then
  set ocidAppPathURL to ocidAppBundle's bundleURL()
else if ocidAppBundle = (missing value) then
  set ocidAppPathURL to (appSharedWorkspace's URLForApplicationWithBundleIdentifier:(strBundleID))
end if
if ocidAppPathURL = (missing value) then
  tell application "Finder"
    try
      set aliasAppApth to (application file id strBundleID) as alias
    on error
return "アプリケーションが見つかりませんでした"
    end try
  end tell
  set strAppPath to POSIX path of aliasAppApth as text
  set strAppPathStr to refMe's NSString's stringWithString:(strAppPath)
  set strAppPath to strAppPathStr's stringByStandardizingPath()
  set ocidAppPathURL to refMe's NSURL's alloc()'s initFileURLWithPath:(ocidFilePath) isDirectory:true
end if
###PDFの保存先パス
set strFileName to (strRGBHEX & ".pdf") as text
set ocidPDFFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strFileName)
set strPdfFilePathURL to ocidPDFFilePathURL's |path| as text
set ocidBinPathURL to ocidAppPathURL's URLByAppendingPathComponent:("Contents/MacOS/Google Chrome")
set strBinPath to ocidBinPathURL's |path|() as text
###コマンド整形
set strCommandText to ("\"" & strBinPath & "\" --headless --disable-gpu --print-to-pdf=\"" & strPdfFilePathURL & "\" --print-to-pdf-no-header \"" & strSaveFilePath & "\"") as text
###コマンド実行
set strRGBHEX to (do shell script strCommandText) as text
###保存先を開く
set appSharedWorkSpave to refMe's NSWorkspace's sharedWorkspace()
set boolDone to appSharedWorkSpave's selectFile:(ocidSaveFilePathURL's |path|) inFileViewerRootedAtPath:(ocidDownloadsDirPathURL's |path|)



|

[SVG]SVGでカラーチップを作る


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

#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use framework "AppKit"
use scripting additions

property refMe : a reference to current application


##############################
#####ダイアログ
##############################
##前面に出す
set strName to (name of current application) as text
if strName is "osascript" then
  tell application "Finder" to activate
else
  tell current application to activate
end if
###カラーピッカー
try
  set the listRGB16bitColor to (choose color) as list
on error
return "キャンセルしました"
end try

##########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
##########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 strRcolor8Bit to numRcolor8Bit as text
set strGcolor8Bit to numGcolor8Bit as text
set strBcolor8Bit to numBcolor8Bit as text
##########NSColorValue Float
set numRcolorFloat to numRcolor8Bit / 255 as number
set numGcolorFloat to numGcolor8Bit / 255 as number
set numBcolorFloat to numBcolor8Bit / 255 as number
###
set strRGB8Bit to ((strRcolor8Bit) & "," & (strGcolor8Bit) & "," & (strBcolor8Bit)) as text
###
set strCommandText to ("/usr/bin/perl -e 'printf(\"%02X%02X%02X\"," & strRGB8Bit & ")'") as text
set strRGBHEX to (do shell script strCommandText) as text
set strRGBHEXenc to ("%23" & strRGBHEX) as text
set strRGBHEX to ("#" & strRGBHEX) as text
##
set strSVG to ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\"><svg height=\"960.0px\" stroke-miterlimit=\"10\" style=\"background-color: #ffffff;fill-rule:nonzero;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;\" version=\"1.1\" viewBox=\"0 0 720 960\" width=\"720.0px\" xml:space=\"preserve\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"><defs/><path d=\"M0 0L720 0L720 960L0 960L0 0Z\" fill=\"#ffffff\" fill-rule=\"nonzero\" opacity=\"1\" stroke=\"none\"/><clipPath id=\"ArtboardFrame\"><rect height=\"960\" width=\"720\" x=\"0\" y=\"0\"/></clipPath><g clip-path=\"url(#ArtboardFrame)\" id=\"" & strRGBHEX & "\"><path d=\"M-1.13687e-13 0L720 0L720 720L-1.13687e-13 720L-1.13687e-13 0Z\" fill=\"" & strRGBHEX & "\" fill-rule=\"nonzero\" opacity=\"1\" stroke=\"none\"/><text fill=\"" & strRGBHEX & "\" font-family=\"Helvetica-Bold\" font-size=\"144\" opacity=\"1\" stroke=\"none\" text-anchor=\"start\" transform=\"matrix(1 0 0 1 36 720)\" x=\"0\" y=\"0\"><tspan textLength=\"620\" x=\"0\" y=\"140\">" & strRGBHEX & "</tspan></text><text fill=\"" & strRGBHEX & "\" font-family=\"Helvetica-Bold\" font-size=\"36\" opacity=\"1\" stroke=\"none\" text-anchor=\"start\" transform=\"matrix(1 0 0 1 36 881.244)\" x=\"0\" y=\"0\"><tspan textLength=\"520\" x=\"0\" y=\"35\">rgb(" & strRcolor8Bit & ", " & strGcolor8Bit & ", " & strBcolor8Bit & ")</tspan></text></g></svg>") as text

###ダウンロードフォルダ
set appFileManager to refMe's NSFileManager's defaultManager()
set ocidURLsArray to (appFileManager's URLsForDirectory:(refMe's NSDownloadsDirectory) inDomains:(refMe's NSUserDomainMask))
set ocidDownloadsDirPathURL to ocidURLsArray's firstObject()
###ファイル名はHEX値
set strFileName to (strRGBHEX & ".svg") as text
set ocidSaveFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strFileName)
set strSaveFilePath to ocidSaveFilePathURL's |path| as text
##データにして
set ocidSaveSVG to refMe's NSString's stringWithString:(strSVG)
##保存
set listDone to (ocidSaveSVG's writeToURL:(ocidSaveFilePathURL) atomically:(refMe's NSNumber's numberWithBool:true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))
##################
##リンクさせる場合(レスポンシブ)
set strHTML to ("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>" & strRGBHEX & "</title><style>body{background-color: #FFFFF;}</style></head><body><img src=\"./" & strRGBHEXenc & ".svg\" style=\"height: 82vh; margin-top: 9vh; margin-left: 9vh\"><p>" & strRGBHEX & "</p><p>" & "rgb(" & strRcolor8Bit & ", " & strGcolor8Bit & ", " & strBcolor8Bit & ")" & "</p></body></html>") as text
##埋め込む場合
# set strHTML to ("<!DOCTYPE html><html><head><meta charset=\"UTF-8\"><title>" & strRGBHEX & "</title><style>body{background-color: #FFFFF;}</style></head><body>" & strSVG & "</body></html>") as text

##HTML をデータにして
set ocidSaveHTML to refMe's NSString's stringWithString:(strHTML)
##保存 HTML
set strFileName to (strRGBHEX & ".html") as text
set ocidHTMLFilePathURL to ocidDownloadsDirPathURL's URLByAppendingPathComponent:(strFileName)
set listDone to (ocidSaveHTML's writeToURL:(ocidHTMLFilePathURL) atomically:(refMe's NSNumber's numberWithBool:true) encoding:(refMe's NSUTF8StringEncoding) |error|:(reference))

###保存先を開く
set appSharedWorkSpave to refMe's NSWorkspace's sharedWorkspace()
set boolDone to appSharedWorkSpave's selectFile:(ocidSaveFilePathURL's |path|) inFileViewerRootedAtPath:(ocidDownloadsDirPathURL's |path|)



|

その他のカテゴリー

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