Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

カテゴリー: Color

画像中の色の置き換え

Posted on 4月 7, 2018 by Takaaki Naganoya

指定画像中の指定色を置き換えるAppleScriptです。

replaceColorKit.framework (To ~/Library/Frameworks/)


▲Color Replaced Image & Original (Yellow)

AppleScript名:画像中の色の置き換え
— Created 2017-04-23 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "replaceColorKit" –https://github.com/braginets/NSImage-replace-color
use framework "AppKit"

set aThreshold to 0.2

set aFile to POSIX path of (choose file of type {"public.image"})
set anImage to (current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile)

set aColor to makeNSColorFromRGBA255val(246, 253, 0, 255) of me
set bColor to makeNSColorFromRGBA255val(154, 154, 154, 255) of me

set bImage to (anImage’s replaceColor:aColor withColor:bColor withThreshold:aThreshold)

set aDesktopPath to ((current application’s NSProcessInfo’s processInfo()’s environment()’s objectForKey:("HOME"))’s stringByAppendingString:"/Desktop/")
set savePath to (aDesktopPath’s stringByAppendingString:((current application’s NSString’s stringWithString:(aThreshold as string))’s stringByAppendingString:".png"))
set fRes to saveNSImageAtPathAsPNG(bImage, savePath) of me

–0〜255の数値でNSColorを作成する
on makeNSColorFromRGBA255val(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer)
  set aRedCocoa to (redValue / 255) as real
  
set aGreenCocoa to (greenValue / 255) as real
  
set aBlueCocoa to (blueValue / 255) as real
  
set aAlphaCocoa to (alphaValue / 255) as real
  
set aColor to current application’s NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBA255val

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
  
return aRes
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in Color file Image | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

単色画像(アルファ値必要)に色を指定して塗りつぶし

Posted on 4月 7, 2018 by Takaaki Naganoya

単色画像に色を指定して塗りつぶしを行うAppleScriptです。


▲Original Image


▲Result Image

AppleScript名:単色画像(アルファ値必要)に色を指定して塗りつぶし
— Created 2017-04-24 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "QuartzCore"
–http://piyocast.com/as/archives/4615

set aFile to POSIX path of (choose file of type "public.image")
set aColor to makeNSColorFromRGBA255val(0, 0, 255, 255) of me
set aColoredImage to fillColorWithImage(aFile, aColor) of me

set aDesktopPath to ((current application’s NSProcessInfo’s processInfo()’s environment()’s objectForKey:("HOME"))’s stringByAppendingString:"/Desktop/")
set savePath to (aDesktopPath’s stringByAppendingString:((current application’s NSString’s stringWithString:"testOverlay")’s stringByAppendingString:".png"))
set fRes to saveNSImageAtPathAsPNG(aColoredImage, savePath) of me

on fillColorWithImage(aFile, aColor)
  set anImage to (current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile)
  
set aSize to anImage’s |size|()
  
set aWidth to (aSize’s width)
  
set aHeight to (aSize’s height)
  
set colordImage to makeNSImageWithFilledWithColor(aWidth, aHeight, aColor) of me
  
colordImage’s lockFocus()
  
anImage’s drawAtPoint:{0, 0} fromRect:(current application’s NSZeroRect) operation:(current application’s NSCompositeDestinationIn) fraction:1.0
  
colordImage’s unlockFocus()
  
return colordImage
end fillColorWithImage

–指定サイズの画像を作成し、指定色で塗ってファイル書き出し
on makeNSImageWithFilledWithColor(aWidth, aHeight, fillColor)
  set anImage to current application’s NSImage’s alloc()’s initWithSize:(current application’s NSMakeSize(aWidth, aHeight))
  
anImage’s lockFocus()
  
—
  
set theRect to {{x:0, y:0}, {height:aHeight, width:aWidth}}
  
set theNSBezierPath to current application’s NSBezierPath’s bezierPath
  
theNSBezierPath’s appendBezierPathWithRect:theRect
  
—
  
fillColor’s |set|() –色設定
  
theNSBezierPath’s fill() –ぬりつぶし
  
—
  
anImage’s unlockFocus()
  
—
  
return anImage
end makeNSImageWithFilledWithColor

on makeNSColorFromRGBA255val(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer)
  set aRedCocoa to (redValue / 255) as real
  
set aGreenCocoa to (greenValue / 255) as real
  
set aBlueCocoa to (blueValue / 255) as real
  
set aAlphaCocoa to (alphaValue / 255) as real
  
set aColor to current application’s NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBA255val

–NSImageを指定パスにPNG形式で保存
on saveNSImageAtPathAsPNG(anImage, outPath)
  set imageRep to anImage’s TIFFRepresentation()
  
set aRawimg to current application’s NSBitmapImageRep’s imageRepWithData:imageRep
  
set pathString to current application’s NSString’s stringWithString:outPath
  
set newPath to pathString’s stringByExpandingTildeInPath()
  
set myNewImageData to (aRawimg’s representationUsingType:(current application’s NSPNGFileType) |properties|:(missing value))
  
set aRes to (myNewImageData’s writeToFile:newPath atomically:true) as boolean
  
return aRes –成功ならtrue、失敗ならfalseが返る
end saveNSImageAtPathAsPNG

★Click Here to Open This Script 

Posted in Color file Image | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

AppleScriptの構文色分けカラーフォーマットをplistから読み込む

Posted on 3月 7, 2018 by Takaaki Naganoya

AppleScriptの構文色分けフォーマットをplistから読み込むAppleScriptです。

ただし、本Scriptで取得した色情報はスクリプトエディタ上で設定した内容と若干RGB値が異なるため、色情報をもとに構文要素を判定するような処理に本Scriptをそのまま用いることは推奨しません。

AppleScript名:AppleScriptの構文色分けカラーフォーマットをplistから読み込む
— Created 2013-11-11 by Shane Stanley
— Changed 2014-12-14 by Takaaki Naganoya
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set cList to getAppleScriptSourceColors() of me
–> {​​​​​{​​​​​​​redValue:37265, ​​​​​​​greenValue:10280, ​​​​​​​blueValue:37008, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:15672, ​​​​​​​greenValue:3071, ​​​​​​​blueValue:15832, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:3598, ​​​​​​​greenValue:15934, ​​​​​​​blueValue:64507, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:30840, ​​​​​​​greenValue:13364, ​​​​​​​blueValue:52171, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:64764, ​​​​​​​greenValue:10794, ​​​​​​​blueValue:7196, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:0, ​​​​​​​greenValue:0, ​​​​​​​blueValue:0, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:37265, ​​​​​​​greenValue:21074, ​​​​​​​blueValue:4369, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:0, ​​​​​​​greenValue:0, ​​​​​​​blueValue:0, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:10023, ​​​​​​​greenValue:51657, ​​​​​​​blueValue:51657, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:3855, ​​​​​​​greenValue:15934, ​​​​​​​blueValue:64507, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:7967, ​​​​​​​greenValue:46774, ​​​​​​​blueValue:64764, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:33153, ​​​​​​​greenValue:14906, ​​​​​​​blueValue:55769, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:23901, ​​​​​​​greenValue:13878, ​​​​​​​blueValue:37522, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:47484, ​​​​​​​greenValue:3164, ​​​​​​​blueValue:32926, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:6491, ​​​​​​​greenValue:47213, ​​​​​​​blueValue:32320, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:40001, ​​​​​​​greenValue:37149, ​​​​​​​blueValue:1331, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:20379, ​​​​​​​greenValue:0, ​​​​​​​blueValue:35059, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}, ​​​​​{​​​​​​​redValue:4539, ​​​​​​​greenValue:35536, ​​​​​​​blueValue:35798, ​​​​​​​fontName:"Osaka", ​​​​​​​fontSize:13.0​​​​​}​​​}

–AppleScriptの構文色分けのカラー値をRGBで取得する
on getAppleScriptSourceColors()
  
  
— get the info as a dictionary
  
set thePath to current application’s NSString’s stringWithString:"~/Library/Preferences/com.apple.applescript.plist"
  
set thePath to thePath’s stringByExpandingTildeInPath()
  
set theInfo to current application’s NSDictionary’s dictionaryWithContentsOfFile:thePath
  
  
— extract relevant part and loop through
  
set theArray to (theInfo’s valueForKey:"AppleScriptSourceAttributes") as list
  
  
set colList to {}
  
  
repeat with i from 1 to count of theArray
    set anEntry to item i of theArray
    
log anEntry
    
    
set colorData to NSColor of anEntry
    
set theColor to (current application’s NSUnarchiver’s unarchiveObjectWithData:colorData)
    
    
set {rVal, gVal, bVal} to retColListFromNSColor(theColor, 65535) of me
    
    
set fontData to NSFont of anEntry
    
set theFont to (current application’s NSUnarchiver’s unarchiveObjectWithData:fontData)
    
    
set aFontName to theFont’s displayName() as text
    
set aFontSize to theFont’s pointSize()
    
    
set aColRec to {redValue:rVal, greenValue:gVal, blueValue:bVal, fontName:aFontName, fontSize:aFontSize}
    
    
set the end of colList to aColRec
  end repeat
  
  
return colList
end getAppleScriptSourceColors

–NSColorからRGBの値を取り出す
on retColListFromNSColor(aCol, aMAX as integer)
  set aRed to round ((aCol’s redComponent()) * aMAX) rounding as taught in school
  
set aGreen to round ((aCol’s greenComponent()) * aMAX) rounding as taught in school
  
set aBlue to round ((aCol’s blueComponent()) * aMAX) rounding as taught in school
  
  
if aRed > aMAX then set aRed to aMAX
  
if aGreen > aMAX then set aGreen to aMAX
  
if aBlue > aMAX then set aBlue to aMAX
  
  
return {aRed, aGreen, aBlue}
end retColListFromNSColor

★Click Here to Open This Script 

Posted in Color OSA System | Tagged 10.11savvy 10.12savvy 10.13savvy Script Editor | 3 Comments

指定パスのAppleScript書類がコンパイル済みかどうかチェック

Posted on 3月 7, 2018 by Takaaki Naganoya
AppleScript名:指定パスのAppleScript書類がコンパイル済みかどうかチェック
— Created 2014-12-16 by Takaaki Naganoya
— 2014 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "OSAKit"

property |NSURL| : a reference to current application’s |NSURL|
property OSAScript : a reference to current application’s OSAScript

–指定AppleScriptがコンパイルずみ(中間コードへの翻訳の意)かどうかをしらべる
set a to (choose file of type {"com.apple.applescript.script-bundle", "com.apple.applescript.script", "com.apple.applescript.text"})
set asRes to chkAScompiled(a) as list of string or string
–> true or false

–指定のAppleScriptファイルがコンパイル(構文確認+中間言語化)ずみかどうかを取得する
on chkAScompiled(anAlias as {alias, string})
  set aURL to |NSURL|’s fileURLWithPath:(POSIX path of anAlias)
  
set asO to OSAScript’s alloc()’s initWithContentsOfURL:aURL |error|:(missing value)
  
  
try
    set compF to asO’s isCompiled() as boolean
    
return compF
  on error
    return false
  end try
end chkAScompiled

★Click Here to Open This Script 

Posted in Color OSA System | Tagged 10.11savvy 10.12savvy 10.13savvy Script Editor | Leave a comment

nameを指定してOSA言語のインスタンスを生成する

Posted on 3月 6, 2018 by Takaaki Naganoya

name(名称)を指定してOSA言語のインスタンスを生成するテストを行うAppleScriptです。

このあたりの話は、スクリプトエディタ上では直接取得できますし、コマンドラインからだとosalangコマンドを実行すれば名称一覧を取得できます。Cocoa経由でどの程度の情報が取得できるのか、ちょっと試してながらく放置したままになっていました。

再度、OSAKit系の情報を探してみても……見当たらない(ーー;

以前にAppleEvent Managerのドキュメントをまるごとオフラインにしていた前科があるので、担当に「(オフラインになっていて)見えないんだけど?」と確認したところ………

 「何が見えないんだ? 最初からそんなもんないぞ。これまでにドキュメントを作ったこともない」

と言われる始末。余計悪いわ(ーー;;;

というわけで、Web上にドキュメントが掲載されていないOSAKit系の情報については、Xcode上から、以下のように操作してヘッダーファイルの内容を確認することが必要なようです。

AppleScript名:nameを指定してOSA言語のインスタンスを生成する
— Created 2018-03-05 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "OSAKit"

property OSALanguage : a reference to current application’s OSALanguage
property OSALanguageInstance : a reference to current application’s OSALanguageInstance

set anOSALanguageInstance to OSALanguageInstance’s languageInstanceWithLanguage:(OSALanguage’s defaultLanguage())
set aLanguage to anOSALanguageInstance’s |language|()’s |name|() as string
–> "AppleScript"

set bLanguage to OSALanguage’s languageForName:"AppleScript"
set bName to bLanguage’s |name|() as string
–> "AppleScript"

set cLanguage to OSALanguage’s languageForName:"JavaScript"
set cName to cLanguage’s |name|() as string
–> "JavaScript"

set langArray to (OSALanguage’s availableLanguages()’s valueForKeyPath:"name") as list
–> {"AppleScript", "JavaScript"}

★Click Here to Open This Script 

Posted in Color OSA System | Tagged 10.11savvy 10.12savvy 10.13savvy Script Editor | Leave a comment

Script Editorをコントロールして各構文要素の色情報を取得する v5

Posted on 3月 5, 2018 by Takaaki Naganoya

Script Editorをコントロールして、AppleScriptの各構文要素の色情報を取得するAppleScriptです。

AppleScriptの構文要素の色分けを取得するのに、当初はplistファイルから読み込んでいたのですが、途中から(Mac OS X 10.5あたり?)plistファイルのフォーマットがテキスト形式からバイナリ形式に変更になり、AppleScriptから読み込んでも判定できない内容になりました(Cocoaの機能を使うと読み取れるのですが)。

そこで、「プログラム的には意味はないが、対象の構文要素が入っているテキスト」でAppleScriptを新規ドキュメントを作成してコンパイル(構文確認)を実行。新規ドキュメントからリッチテキストとして書式情報を取得し、想定した文字の位置から指定構文要素に対応する色情報を取得します。

plistの保存形式が途中で変更されたのとは別に、書式つきテキスト(attribute runs)の挙動もOSバージョンによって微妙に変わってきました。

同じデータを与えても、書式の区切りが微妙に変わって、書式(色)情報を固定の箇所から読み取っていてはそのようなOSバージョン変更に伴う挙動の微妙な変更に対応し切れませんでした。そのため、文字列をサーチして毎回動的にデータ位置を検出するように書き換えた経緯があります。

本ルーチンは、変数名のリネーム用に作成したので構文要素確認用のダミーテキストは最低限のものだけを含んでいますが、その気になればすべての構文要素の色情報を取得可能です。

これとは別に、Cocoaの機能を用いてplistから構文書式情報を取得するAppleScriptも存在するものの、計算して微妙に色情報が合わないので、9年前に作成した本ルーチンを使い続けています(当時)。

→ さすがに重要なルーチンなので、Cocoa系の機能を使って処理するように書き換えました。いまはCocoa系ルーチンを使っています

AppleScript名:Script Editorをコントロールして各構文要素の色情報を取得する v5
— Created 2009-06-01 by Takaaki Naganoya
— 2009-2018 Piyomaru Software

set scList to getRexicalColorOfScriptEditor() of me
–> {{32053, 4213, 32213}, {15672, 3071, 15831}, {2841, 6963, 64125}, {8259, 42547, 64473}, {0, 0, 0}, {32202, 16452, 3889}}
–色書式データ。先頭から順番に、、、
–新規テキスト, 演算子など, スクリプティング予約語, コマンド名, 値(数値、データ), 変数およびサブルーチン名

–スクリプトエディタの各構文要素の指定色を返す
–v5の変更点:Leopard以降のStyle runsの挙動変化(スペースを分離する/しない)に対応し、動的にサンプル文を走査するようにした
–v4の変更点:構文要素検出時のテンポラリウィンドウ作成時にScript Editorを隠す
–v3の変更点:重複時のエラー検出を追加
on getRexicalColorOfScriptEditor()
  set aRes to setVisibleOfSpecifiedProcess("Script Editor", false) of me
  
  
set rexList to {"+", "set", "application", "Comment", "1", "a"} –文中から検索するテキスト要素
  
set colList to {} –色情報を入れるリスト
  
  
  
tell application "Script Editor"
    
    
set aDoc to make new document
    
tell front document
      set aName to name
      
–end tell
      
      
–tell document aName
      
–未コンパイル時のテキストを取得
      
set contents to "aaaaa"
      
set rexItem1 to (color of attribute runs)
      
set rexItem1 to contents of (item 1 of rexItem1)
      
      
set colList to {rexItem1}
      
      
      
–各種構文要素を含む文字を入れる
      
set contents to "1 + 1
set a to \"abc\"
tell application \"Finder\"
end tell
–Comment
"

      –追加する場合には、テキストを後ろに追加すること
      
      
try
        compile
      on error
        close without saving
        
return false
      end try
      
      
set rex1 to attribute runs
      
set rex2 to color of attribute runs
      
      
repeat with i in rexList
        set j to contents of i
        
set rC to 1
        
repeat with ii in rex1
          set jj to contents of ii
          
set jj to replaceText(jj, " ", "") of me –スペースを削除する
          
if j = jj then
            set the end of colList to contents of item rC of rex2
            
exit repeat –抜けていた
          end if
          
set rC to rC + 1
        end repeat
      end repeat
      
      
close without saving
    end tell
    
  end tell
  
  
–Script Editorの再表示
  
set aRes to setVisibleOfSpecifiedProcess("Script Editor", true) of me
  
  
–要素の重複検出
  
set aRes to detectDuplicationSimple(colList) of me
  
if aRes = false then
    return false
  else
    return colList
  end if
  
end getRexicalColorOfScriptEditor

–リスト中の重複検出
on detectDuplicationSimple(cList)
  copy cList to ccList
  
  
set j to length of ccList
  
  
repeat with i from 2 to j
    set first_item to item 1 of ccList
    
set ccList to rest of ccList
    
if first_item is in ccList then
      return false
    end if
  end repeat
  
  
return true
end detectDuplicationSimple

–指定プロセスの可視/不可視切り替え
on setVisibleOfSpecifiedProcess(aProc, aBoolean)
  tell application "System Events"
    if exists process aProc then
      set visible of process aProc to aBoolean
      
set resF to true
    else
      set resF to false
    end if
  end tell
  
return resF
end setVisibleOfSpecifiedProcess

–任意のデータから特定の文字列を置換
on replaceText(origData, origText, repText)
  set curDelim to AppleScript’s text item delimiters
  
set AppleScript’s text item delimiters to {origText}
  
set origData to text items of origData
  
set AppleScript’s text item delimiters to {repText}
  
set origData to origData as text
  
set AppleScript’s text item delimiters to curDelim
  
return origData
end replaceText

★Click Here to Open This Script 

Posted in Color OSA System | Tagged 10.11savvy 10.12savvy 10.13savvy Script Editor | 1 Comment

Crayon Pickerの色をKeynote上に赤、青、その他で判定して表にする

Posted on 2月 27, 2018 by Takaaki Naganoya

「クレヨンピッカー」の色を赤、青、その他で判定してKeynoteの表にプロットするAppleScriptです。

–> Demo Movie

AppleScript名:Crayon Pickerの色をKeynote上に赤、青、その他で判定して表にする
— Created 2018-02-27 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSColor : a reference to current application’s NSColor

–Crayon Picker Color Data
set crayonPickerList to {{0, 0, 0}, {6425, 6425, 6425}, {13107, 13107, 13107}, {19532, 19532, 19532}, {26214, 26214, 26214}, {32639, 32639, 32639}, {32896, 32896, 32896}, {39321, 39321, 39321}, {46003, 46003, 46003}, {52428, 52428, 52428}, {59110, 59110, 59110}, {65535, 65535, 65535}, ¬
  {32896, 0, 0}, {32896, 16448, 0}, {32896, 32896, 0}, {16448, 32896, 0}, {0, 32896, 0}, {0, 32896, 16448}, {0, 32896, 32896}, {0, 16448, 32896}, {0, 0, 32896}, {16448, 0, 32896}, {32896, 0, 32896}, {32896, 0, 16448}, ¬
  {
65535, 0, 0}, {65535, 32896, 0}, {65535, 65535, 0}, {32896, 65535, 0}, {0, 65535, 0}, {0, 65535, 32896}, {0, 65535, 65535}, {0, 32896, 65535}, {0, 0, 65535}, {32896, 0, 65535}, {65535, 0, 65535}, {65535, 0, 32896}, ¬
  {
65535, 26214, 26214}, {65535, 52428, 26214}, {65535, 65535, 26214}, {52428, 65535, 26214}, {26214, 65535, 26214}, {26214, 65535, 52428}, {26214, 65535, 65535}, {26214, 52428, 65535}, {26214, 26214, 65535}, {52428, 26214, 65535}, {65535, 26214, 65535}, {65535, 28527, 53199} ¬
  }

tell application "Keynote"
  activate
  
set newDoc to make new document with properties {document theme:theme "ホワイト"} — theme name is *Localized*. This is "White" in Japanese
  
  
tell window 1
    –set {x1, y1, x2, y2} to bounds
    
    
set bounds to {0, 0, 1500, 900}
  end tell
  
  
tell newDoc
    set blankSlide to master slide "空白" –master slide name is *Localized*. This is "Blank" in Japanese
    
    
tell slide 1
      set base slide to blankSlide
      
      
delete every table
      
set tRes to make new table
      
      
tell tRes
        set row count to 12
        
set column count to 8
        
set background color of every cell to {65535, 65535, 65535}
        
set header column count to 0
        
set header row count to 0
        
set footer row count to 0
        
        
repeat with i from 0 to (length of crayonPickerList) – 1
          set a1Num to (i mod 12) + 1
          
set b1Num to ((i div 12) + 1) * 2 – 1
          
set b2Num to b1Num + 1
          
set aCol to contents of item (i + 1) of crayonPickerList
          
          
tell column b1Num
            tell cell a1Num
              ignoring application responses
                set background color to aCol
              end ignoring
            end tell
          end tell
          
          
—————————————————————————————————–
          
copy aCol to {rCol, gCol, bCol}
          
set aColor to makeNSColorFromRGBAval(rCol, gCol, bCol, 65535, 65535) of me
          
set cdnStr to retColorIsRedOrBlueFromNSColor(aColor) of me –red, blue, other
          
—————————————————————————————————–
          
          
if cdnStr = "red" then
            set textCol to {65535, 0, 0}
          else if cdnStr = "blue" then
            set textCol to {0, 0, 65535}
          else
            set textCol to {0, 0, 0}
          end if
          
          
tell column b2Num
            tell cell a1Num
              ignoring application responses
                set value to cdnStr
                
set text color to textCol
              end ignoring
            end tell
          end tell
          
        end repeat
        
      end tell
      
    end tell
  end tell
  
end tell

on retColorIsRedOrBlueFromNSColor(aColor)
  set aColDomain to retColorDomainNameFromNSColor(aColor) of me
  
if aColDomain is in {"magenta", "purple", "orange", "red"} then
    return "red"
  else if aColDomain is in {"green", "cyan", "blue"} then
    return "blue"
  else
    return "other"
  end if
end retColorIsRedOrBlueFromNSColor

on retColorDomainNameFromNSColor(aCol)
  set hueVal to aCol’s hueComponent()
  
set satVal to aCol’s saturationComponent()
  
set brightVal to aCol’s brightnessComponent()
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
set colName to ""
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colName to "black"
    else if (brightVal > 0.95) then
      set colName to "white"
    else
      set colName to "gray"
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colName to "red"
    else if hueVal ≤ (45.0 / 360) then
      set colName to "orange"
    else if hueVal < (70.0 / 360) then
      set colName to "yellow"
    else if hueVal < (150.0 / 360) then
      set colName to "green"
    else if hueVal < (190.0 / 360) then
      set colName to "cyan"
    else if (hueVal < 250.0 / 360.0) then
      set colName to "blue"
    else if (hueVal < 290.0 / 360.0) then
      set colName to "purple"
    else
      set colName to "magenta"
    end if
  end if
  
  
return colName
end retColorDomainNameFromNSColor

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

★Click Here to Open This Script 

Keynote Control 1

Keynote Control 2

Posted in Color | Tagged 10.11savvy 10.12savvy 10.13savvy Keynote | Leave a comment

色が赤系統か青系統かを判定する

Posted on 2月 27, 2018 by Takaaki Naganoya

指定の色が赤系統か青系統かその他かを判定するAppleScriptです。

パラメータをRTFから取得するプログラムで、テキストを青、データベースから取得して差し込む値を赤、コメント類を黒などで記述するようにしてみたため、赤/青/その他を判定するプログラムを作成してみました。

AppleScript名:色が赤系統か青系統かを判定する
— Created 2018-02-27 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSColor : a reference to current application’s NSColor

set {rCol, gCol, bCol} to choose color
set aColor to makeNSColorFromRGBAval(rCol, gCol, bCol, 65535, 65535) of me

–Detect the color is red or blue (or other)
set cdnStr to retColorIsRedOrBlueFromNSColor(aColor) of me
–> "red" / "blue" / "ohter"

on retColorIsRedOrBlueFromNSColor(aColor)
  set aColDomain to retColorDomainNameFromNSColor(aColor) of me
  
if aColDomain is in {"magenta", "purple", "orange", "red"} then
    return "red"
  else if aColDomain is in {"green", "cyan", "blue"} then
    return "blue"
  else
    return "other"
  end if
end retColorIsRedOrBlueFromNSColor

on retColorDomainNameFromNSColor(aCol)
  set hueVal to aCol’s hueComponent()
  
set satVal to aCol’s saturationComponent()
  
set brightVal to aCol’s brightnessComponent()
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
set colName to ""
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colName to "black"
    else if (brightVal > 0.95) then
      set colName to "white"
    else
      set colName to "gray"
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colName to "red"
    else if hueVal ≤ (45.0 / 360) then
      set colName to "orange"
    else if hueVal < (70.0 / 360) then
      set colName to "yellow"
    else if hueVal < (150.0 / 360) then
      set colName to "green"
    else if hueVal < (190.0 / 360) then
      set colName to "cyan"
    else if (hueVal < 250.0 / 360.0) then
      set colName to "blue"
    else if (hueVal < 290.0 / 360.0) then
      set colName to "purple"
    else
      set colName to "magenta"
    end if
  end if
  
  
return colName
end retColorDomainNameFromNSColor

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

★Click Here to Open This Script 

Posted in Color | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

ANSI Colorの色名称でTerminalの文字色を変更

Posted on 2月 27, 2018 by Takaaki Naganoya

ANSI Colorの名称一覧から名前をえらんで、Terminalの文字色を変更するAppleScriptです。

これにどの程度の意味があるのかさっぱり分からないのですが、ANSI Colorで文字色を指定する趣味の人もいるということで、世界の広さを感じます。

–> Demo Movie


▲Select ANSI color name


▲Before


▲After

AppleScript名:ANSI Colorの色名称でTerminalの文字色を変更
— Created 2018-02-06 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

–Dark
–set ansiColTable to {{colName:"Black", colVal:{0, 0, 0}}, {colName:"Red", colVal:{34166, 0, 712}}, {colName:"Green", colVal:{5182, 39392, 620}}, {colName:"Yellow", colVal:{34811, 35431, 1086}}, {colName:"Blue", colVal:{0, 0, 39429}}, {colName:"White", colVal:{49207, 49511, 49827}}, {colName:"Magenta", colVal:{41397, 0, 41833}}, {colName:"Cyan", colVal:{4997, 38685, 41818}}}

–Light
set ansiColTable to {{colName:"Black", colVal:{21352, 21356, 21351}}, {colName:"Red", colVal:{56616, 0, 1392}}, {colName:"Green", colVal:{7241, 55116, 1162}}, {colName:"Yellow", colVal:{57396, 58567, 2377}}, {colName:"Blue", colVal:{0, 0, 65416}}, {colName:"White", colVal:{49207, 49511, 49827}}, {colName:"Magenta", colVal:{56440, 0, 57441}}, {colName:"Cyan", colVal:{7416, 58001, 57206}}}

set tmpColorList to filterAnAttribute(ansiColTable, "colName") of me
set aTargColor to choose from list tmpColorList with prompt "choose ANSI color name"
if aTargColor = {} or aTargColor = false then return

set targColorName to contents of first item of aTargColor

set aRes to filterListUsingPredicate(ansiColTable, "colName ==[c] %@", targColorName)
if aRes = missing value then return

set colList to colVal of aRes

tell application "Terminal"
  set normal text color of window 1 to colList
  
–set background color of window 1 to colList
end tell

on filterListUsingPredicate(aList as list, aPredicateStr as string, targStr as string)
  set setKey to current application’s NSMutableSet’s setWithArray:aList
  
set aPredicate to current application’s NSPredicate’s predicateWithFormat_(aPredicateStr, targStr)
  
set aRes to (setKey’s filteredSetUsingPredicate:aPredicate)
  
return (aRes’s allObjects()) as list of string or string
end filterListUsingPredicate

on filterAnAttribute(aList as list, anAttr as string)
  set anArray to current application’s NSArray’s arrayWithArray:aList
  
set valList to anArray’s valueForKeyPath:anAttr
  
return valList as list of string or string –as anything
end filterAnAttribute

★Click Here to Open This Script 

Posted in Color | Tagged 10.11savvy 10.12savvy 10.13savvy Terminal | Leave a comment

Numbers上のデータにもとづいてセル上で色プレビュー

Posted on 2月 25, 2018 by Takaaki Naganoya

–> Demo Movie

AppleScript名:Numbers上のデータにもとづいてセル上で色プレビュー

tell application "Numbers"
  tell front document
    tell active sheet
      tell table 1
        set hCount to header row count
        
set fCount to footer row count
        
        
set aRange to address of row of cell range
        
set bRange to items (1 + hCount) thru ((length of aRange) – fCount) of aRange
        
–> {2, 3, 4, 5, 6}
        
        
repeat with i in bRange
          tell row i
            set vList to value of cells 1 thru 3
            
if vList does not contain missing value then
              set bList to chengeColor255to65535(vList) of me
              
              
ignoring application responses
                tell cell 4
                  set background color to bList
                end tell
              end ignoring
              
            end if
          end tell
        end repeat
      end tell
    end tell
  end tell
end tell

on chengeColor255to65535(aColList)
  set aTmpList to {}
  
repeat with i in aColList
    set the end of aTmpList to i * 256
  end repeat
  
return aTmpList
end chengeColor255to65535

★Click Here to Open This Script 

Posted in Color | Tagged 10.11savvy 10.12savvy 10.13savvy Numbers | Leave a comment

Colorsで色バリエーション展開を計算して表示 v2

Posted on 2月 24, 2018 by Takaaki Naganoya

Coloursをフレームワーク化したcolorsKit.frameworkを呼び出して、指定のRGB色のカラーバリエーションを計算するAppleScriptです。

–> colorsKit.framework

AppleScript名:Colorsで色バリエーション展開を計算して表示 v2
— Created 2017-12-20 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "colorsKit" –https://github.com/bennyguitar/Colours

property NSView : a reference to current application’s NSView
property NSColor : a reference to current application’s NSColor
property NSString : a reference to current application’s NSString
property NSScreen : a reference to current application’s NSScreen
property NSButton : a reference to current application’s NSButton
property NSWindow : a reference to current application’s NSWindow
property NSColorWell : a reference to current application’s NSColorWell
property NSWindowController : a reference to current application’s NSWindowController

property windisp : false

set aWidth to 500
set aHeight to 250

set {rVal, gVal, bVal} to choose color
set aNSCol to makeNSColorFromRGBAval(rVal, gVal, bVal, 65536, 65536) of me

dispCustomView(aWidth, aHeight, "Color Variation Result", "OK", 180, aNSCol) of me

on dispCustomView(aWidth as integer, aHeight as integer, aTitle as text, aButtonMSG as text, timeOutSecs as number, aNSCol)
  
  
–Check If this script runs in foreground
  
if not (current application’s NSThread’s isMainThread()) as boolean then
    error "This script must be run from the main thread (Command-Control-R in Script Editor)."
  end if
  
  
set (my windisp) to true
  
  
  
–Buttonをつくる
  
set bButton to (NSButton’s alloc()’s initWithFrame:(current application’s NSMakeRect(aWidth / 4, 0, aWidth / 2, 40)))
  
bButton’s setTitle:aButtonMSG
  
bButton’s setButtonType:(current application’s NSMomentaryLightButton)
  
bButton’s setBezelStyle:(current application’s NSRoundedBezelStyle)
  
bButton’s setKeyEquivalent:(return)
  
bButton’s setTarget:me
  
bButton’s setAction:("clicked:")
  
  
–NSViewをつくる
  
set aNSV to NSView’s alloc()’s initWithFrame:(current application’s NSMakeRect(0, 0, aHeight, aWidth))
  
aNSV’s addSubview:bButton
  
aNSV’s setNeedsDisplay:true
  
  
–NSColorWellをつくる
  
repeat with ii from 0 to 3 by 1
    set colorArray1 to (aNSCol’s colorSchemeOfType:ii) as list
    
set the beginning of colorArray1 to aNSCol
    
set tmpLen to (length of colorArray1)
    
set aStep to 0
    
repeat with i in colorArray1
      set aColorWell to (NSColorWell’s alloc()’s initWithFrame:(current application’s NSMakeRect((100 * aStep), (((3 – ii) * 50) + 40), 100, 40)))
      (
aColorWell’s setColor:i)
      (
aColorWell’s setBordered:true)
      (
aNSV’s addSubview:aColorWell)
      
set aStep to aStep + 1
    end repeat
  end repeat
  
  
set aWin to makeWinWithView(aNSV, aWidth, aHeight, aTitle, 1.0)
  
  
set wController to NSWindowController’s alloc()
  
wController’s initWithWindow:aWin
  
wController’s showWindow:me
  
  
aWin’s makeKeyAndOrderFront:me
  
  
set aCount to timeOutSecs * 10 –timeout seconds * 10
  
repeat aCount times
    if (my windisp) = false then
      exit repeat
    end if
    
delay 0.1
  end repeat
  
  
my closeWin:aWin
  
end dispCustomView

–Button Clicked Event Handler
on clicked:aSender
  set (my windisp) to false
end clicked:

–make Window for Input
on makeWinWithView(aView, aWinWidth, aWinHeight, aTitle, alphaV)
  set aScreen to NSScreen’s mainScreen()
  
set aFrame to {{0, 0}, {aWinWidth, aWinHeight}}
  
set aBacking to current application’s NSTitledWindowMask
  
set aDefer to current application’s NSBackingStoreBuffered
  
  
— Window
  
set aWin to NSWindow’s alloc()
  (
aWin’s initWithContentRect:aFrame styleMask:aBacking backing:aDefer defer:false screen:aScreen)
  
  
aWin’s setTitle:aTitle
  
aWin’s setDelegate:me
  
aWin’s setDisplaysWhenScreenProfileChanges:true
  
aWin’s setHasShadow:true
  
aWin’s setIgnoresMouseEvents:false
  
aWin’s setLevel:(current application’s NSNormalWindowLevel)
  
aWin’s setOpaque:false
  
aWin’s setAlphaValue:alphaV –append
  
aWin’s setReleasedWhenClosed:true
  
aWin’s |center|()
  
aWin’s makeKeyAndOrderFront:(me)
  
  
— Set Custom View
  
aWin’s setContentView:aView
  
  
return aWin
end makeWinWithView

–close win
on closeWin:aWindow
  repeat with n from 10 to 1 by -1
    (aWindow’s setAlphaValue:n / 10)
    
delay 0.02
  end repeat
  
aWindow’s |close|()
end closeWin:

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

★Click Here to Open This Script 

Posted in Color GUI Require Control-Command-R to run | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

TextEdit本文色に応じて青っぽい色は男性の音声で、赤っぽい色は女性の音声で読み上げ

Posted on 2月 16, 2018 by Takaaki Naganoya

TextEditの本文内で文字色が青っぽい色の文字は男性の音声で、赤っぽい色の文字は女性の音声で読み上げる(sayコマンド)AppleScriptです。

実行時には日本語読み上げ音声のKyokoとOtoyaをインストールしてある必要があります。インストールしてあるかどうか、対象の言語、性別で検出を行い、存在していなかった場合には読み上げを行いません。

AppleScript名:TextEdit本文色に応じて青っぽい色は男性の音声で、赤っぽい色は女性の音声で読み上げ
— Created 2018-02-15 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

property NSColor : a reference to current application’s NSColor
property NSArray : a reference to current application’s NSArray
property NSSortDescriptor : a reference to current application’s NSSortDescriptor

–TTS音声情報を取得する
set curLang to "ja_JP"

set v1List to getTTSVoiceNameWithLanguageAndGender(curLang, "Male") of me
if length of v1List = 0 then return
set v1 to contents of item 1 of v1List –Male Voice

set v2List to getTTSVoiceNameWithLanguageAndGender(curLang, "Female") of me
if length of v2List = 0 then return
set v2 to contents of item 1 of v2List –Female Voice

–TextEditの書類から情報を取得
set aResRec to (getTextStrAndColor() of me)
set colList to colorDat of aResRec
set strList to strList of aResRec

set aLen to length of strList

repeat with i from 1 to aLen
  set curColor to contents of item i of colList
  
set curStr to contents of item i of strList
  
set aColor to retColorDomainNameFromList(curColor, 65535) of me
  
  
if aColor = "blue" then
    –Read by Male Voice
    
say curStr using v1
  else if aColor = "red" then
    –Read by Female Voice  
    
say curStr using v2
  end if
  
end repeat

on getTextStrAndColor()
  tell application "TextEdit"
    if (count every document) = 0 then error "No Document"
    
    
tell front document
      set colList to (color of every attribute run)
      
set attList to every attribute run
    end tell
    
return {colorDat:colList, strList:attList}
  end tell
  
end getTextStrAndColor

on retCocoaColorList(aColorList, aMax)
  set cocoaColorList to {}
  
repeat with i in aColorList
    set the end of cocoaColorList to i / aMax
  end repeat
  
set the end of cocoaColorList to 1.0 –Alpha
  
return cocoaColorList
end retCocoaColorList

–数値の1D List with Recordをソート
on sort1DRecList(aList as list, aKey as string, ascendingF as boolean)
  set aArray to NSArray’s arrayWithArray:aList
  
set desc1 to NSSortDescriptor’s sortDescriptorWithKey:aKey ascending:ascendingF selector:"compare:"
  
set bList to (aArray’s sortedArrayUsingDescriptors:{desc1}) as list
  
return bList
end sort1DRecList

on getTTSVoiceNameWithLanguageAndGender(voiceLang, aGen)
  if aGen = "Male" then
    set aGender to "VoiceGenderMale"
  else if aGen = "Female" then
    set aGender to "VoiceGenderFemale"
  end if
  
  
set outArray to current application’s NSMutableArray’s new()
  
  
–Make Installed Voice List
  
set aList to current application’s NSSpeechSynthesizer’s availableVoices()
  
set bList to aList as list
  
  
repeat with i in bList
    set j to contents of i
    
set aDIc to (current application’s NSSpeechSynthesizer’s attributesForVoice:j)
    (
outArray’s addObject:aDIc)
  end repeat
  
  
set aPredicate to current application’s NSPredicate’s predicateWithFormat_("VoiceLocaleIdentifier == %@ && VoiceGender== %@", voiceLang, aGender)
  
set filteredArray to outArray’s filteredArrayUsingPredicate:aPredicate
  
set aResList to (filteredArray’s valueForKey:"VoiceName") as list
  
  
return aResList
end getTTSVoiceNameWithLanguageAndGender

on retColorDomainNameFromList(aColList as list, aColMax as integer)
  set {rNum, gNum, bNum, aNum} to retCocoaColorList(aColList, aColMax) of me
  
set aCol to NSColor’s colorWithCalibratedRed:rNum green:gNum blue:bNum alpha:aNum
  
return retColorDomainNameFronNSColor(aCol) of me
end retColorDomainNameFromList

on retColorDomainNameFronNSColor(aCol)
  set hueVal to aCol’s hueComponent()
  
set satVal to aCol’s saturationComponent()
  
set brightVal to aCol’s brightnessComponent()
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
set colName to ""
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colName to "black"
    else if (brightVal > 0.95) then
      set colName to "white"
    else
      set colName to "gray"
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colName to "red"
    else if hueVal ≤ (45.0 / 360) then
      set colName to "orange"
    else if hueVal < (70.0 / 360) then
      set colName to "yellow"
    else if hueVal < (150.0 / 360) then
      set colName to "green"
    else if hueVal < (190.0 / 360) then
      set colName to "light blue" –cyan
    else if (hueVal < 250.0 / 360.0) then
      set colName to "blue"
    else if (hueVal < 290.0 / 360.0) then
      set colName to "purple"
    else
      set colName to "pink" –magenta
    end if
  end if
  
  
return colName
end retColorDomainNameFronNSColor

★Click Here to Open This Script 

Posted in Color Sound Text | Tagged 10.11savvy 10.12savvy 10.13savvy Sorting TextEdit | Leave a comment

RTF本文内の色を置換 v2

Posted on 2月 11, 2018 by Takaaki Naganoya

指定のRTF書類の本文中の色を置換するAppleScriptです。

指定のRTF書類内のカラーをざっくりとした色に分類し、同じくざっくりとした色名で置換対象を指定し(blue, green)、指定色(black)に色置換。結果をデスクトップ上に別名で保存します。

AppleScript名:RTF本文内の色を置換 v2
— Created 2018-01-13 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSData : a reference to current application’s NSData
property NSUUID : a reference to current application’s NSUUID
property NSColor : a reference to current application’s NSColor
property NSString : a reference to current application’s NSString
property NSPredicate : a reference to current application’s NSPredicate
property NSDictionary : a reference to current application’s NSDictionary
property NSMutableArray : a reference to current application’s NSMutableArray
property NSMutableAttributedString : a reference to current application’s NSMutableAttributedString
property NSForegroundColorAttributeName : a reference to current application’s NSForegroundColorAttributeName
property NSDocumentTypeDocumentAttribute : a reference to current application’s NSDocumentTypeDocumentAttribute

set targFilePath to POSIX path of (choose file of type {"public.rtf"})
set targColorNameList to {"blue", "green"} –replace target color names
set toColor to NSColor’s blackColor() –to color
set aRes to replaceRTFColorsByColorName(targFilePath, targColorNameList, toColor, 65535) of me

–指定RTF書類本文中、名称で指定した色の該当箇所を指定色(NSColor)に置換する(複数色)
on replaceRTFColorsByColorName(targFilePath as string, targColorNameList as list, toColor, aColorMax as integer)
  script spd
    property hitList : {}
  end script
  
  
set (hitList of spd) to {}
  
set aFilePath to NSString’s stringWithString:(targFilePath)
  
set aData to NSData’s dataWithContentsOfFile:aFilePath options:0 |error|:(missing value)
  
set theStyledText to NSMutableAttributedString’s alloc()’s initWithData:aData options:(missing value) documentAttributes:(missing value) |error|:(missing value)
  
  
set attrList to getAttributeRunsFromAttrString(theStyledText, aColorMax) of me
  
set attrArray to NSMutableArray’s arrayWithArray:attrList
  
  
theStyledText’s beginEditing() ——
  
repeat with ii in targColorNameList
    set jj to contents of ii
    
set thePred to NSPredicate’s predicateWithFormat_("colorName == %@", jj)
    
set (hitList of spd) to ((attrArray’s filteredArrayUsingPredicate:thePred)’s valueForKey:"rangeVal") as list
    
    
repeat with i in (hitList of spd)
      (theStyledText’s addAttribute:(NSForegroundColorAttributeName) value:toColor range:(contents of i))
    end repeat
    
  end repeat
  
theStyledText’s endEditing() ——
  
  
–Save RTF to desktop
  
set targFol to current application’s NSHomeDirectory()’s stringByAppendingPathComponent:"Desktop"
  
set aRes to saveStyledTextAsRTF(targFol, theStyledText) of me
  
return aRes as boolean
end replaceRTFColorsByColorName

–AttributedStringを書式でlist of record化
on getAttributeRunsFromAttrString(theStyledText, aColorMax)
  script aSpd
    property styleList : {}
  end script
  
  
set (styleList of aSpd) to {} —for output
  
  
set thePureString to theStyledText’s |string|() –pure string from theStyledText
  
  
set theLength to theStyledText’s |length|()
  
set startIndex to 0
  
  
repeat until (startIndex = theLength)
    set {theAtts, theRange} to theStyledText’s attributesAtIndex:startIndex longestEffectiveRange:(reference) inRange:{startIndex, theLength – startIndex}
    
    
–String
    
set aText to (thePureString’s substringWithRange:theRange) as string
    
    
–Color
    
set aColor to (theAtts’s valueForKeyPath:"NSColor")
    
if aColor is not equal to missing value then
      set aSpace to aColor’s colorSpace()
      
      
set aRed to (aColor’s redComponent()) * aColorMax
      
set aGreen to (aColor’s greenComponent()) * aColorMax
      
set aBlue to (aColor’s blueComponent()) * aColorMax
      
      
set colList to {aRed as integer, aGreen as integer, aBlue as integer} –for comparison
      
set colStrForFind to (aRed as integer as string) & " " & (aGreen as integer as string) & " " & (aBlue as integer as string) –for filtering
    else
      set colList to {0, 0, 0}
      
set colStrForFind to "0 0 0"
    end if
    
    
–Color Name
    
set cName to retColorName(aRed, aGreen, aBlue, aColorMax) of me
    
    
–Font
    
set aFont to (theAtts’s valueForKeyPath:"NSFont")
    
if aFont is not equal to missing value then
      set aDFontName to aFont’s displayName()
      
set aDFontSize to aFont’s pointSize()
    end if
    
    
set the end of (styleList of aSpd) to {stringVal:aText, colorStr:colStrForFind, colorVal:colList, fontName:aDFontName as string, fontSize:aDFontSize, rangeVal:theRange, colorName:cName}
    
    
set startIndex to current application’s NSMaxRange(theRange)
    
  end repeat
  
  
return (styleList of aSpd)
end getAttributeRunsFromAttrString

–RGB値から色名称(だいたいの色)を計算する
on retColorName(rCol as integer, gCol as integer, bCol as integer, aColMax as integer)
  set aCol to makeNSColorFromRGBAval(rCol, gCol, bCol, aColMax, aColMax) of me
  
set hueVal to aCol’s hueComponent() as real
  
set satVal to aCol’s saturationComponent() as real
  
set brightVal to aCol’s brightnessComponent() as real
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colName to "black"
    else if (brightVal > 0.95) then
      set colName to "white"
    else
      set colName to "gray"
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colName to "red"
    else if hueVal ≤ (45.0 / 360) then
      set colName to "orange"
    else if hueVal < (70.0 / 360) then
      set colName to "yellow"
    else if hueVal < (150.0 / 360) then
      set colName to "green"
    else if hueVal < (190.0 / 360) then
      set colName to "cyan"
    else if (hueVal < 250.0 / 360.0) then
      set colName to "blue"
    else if (hueVal < 290.0 / 360.0) then
      set colName to "purple"
    else
      set colName to "magenta"
    end if
  end if
  
  
return colName
end retColorName

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

–スタイル付きテキストを指定フォルダ(POSIX path)にRTFで書き出し
on saveStyledTextAsRTF(targFol, aStyledString)
  set bstyledLength to aStyledString’s |string|()’s |length|()
  
set bDict to NSDictionary’s dictionaryWithObject:"NSRTFTextDocumentType" forKey:(NSDocumentTypeDocumentAttribute)
  
set bRTF to aStyledString’s RTFFromRange:(current application’s NSMakeRange(0, bstyledLength)) documentAttributes:bDict
  
  
set theName to (NSUUID’s UUID()’s UUIDString())
  
set thePath to NSString’s stringWithString:targFol
  
set thePath to (thePath’s stringByAppendingPathComponent:theName)’s stringByAppendingPathExtension:"rtf"
  
return (bRTF’s writeToFile:thePath atomically:true) as boolean
end saveStyledTextAsRTF

★Click Here to Open This Script 

Posted in Color RTF Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

RTFを読み込んで書式をDictionary化 v3.0

Posted on 2月 11, 2018 by Takaaki Naganoya

指定のRTF書類の内容を読み取って、書式情報をNSDictionaryに変換するAppleScriptです。

  stringVal:文字列データ
  colorStr:RGBの色データを文字列化したもの
  colorVal:RGBの色データの数値list
  colorDomainName:おおまかな色名称
  fontName:フォント名
  fontSize:フォントサイズ

書式情報で抽出しやすくしてあります。複数要素(例:フォント名+色)を一緒にまとめて格納しておくことで、検索パフォーマンスを稼げるはずです。

AppleScript名:RTFを読み込んで書式をDictionary化 v3.0
— Created 2017-12-10 by Takaaki Naganoya
— Modified 2017-12-11 by Shane Stanley
— Modified 2017-12-11 by Nigel Garvey
— Modified 2017-12-12 by Takaaki Naganoya
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSData : a reference to current application’s NSData
property NSString : a reference to current application’s NSString
property NSAttributedString : a reference to current application’s NSAttributedString

set fRes to choose file of type {"public.rtf"}

set aFilePath to NSString’s stringWithString:(POSIX path of fRes)
set aData to NSData’s dataWithContentsOfFile:aFilePath options:0 |error|:(missing value)
set theStyledText to NSAttributedString’s alloc()’s initWithData:aData options:(missing value) documentAttributes:(missing value) |error|:(missing value)

set attrRes to getAttributeRunsFromAttrString(theStyledText) of me
(*
–>  {​​​​​{​​​​​​​stringVal:"■■■■■■■", ​​​​​​​colorStr:"0 0 0", ​​​​​​​colorVal:{​​​​​​​​​0, ​​​​​​​​​0, ​​​​​​​​​0​​​​​​​}, ​​​​​​​colorDomainName:"black", ​​​​​​​fontName:"ヒラギノ角ゴ ProN W6", ​​​​​​​fontSize:12.0​​​​​}, ​​​​​{​​​​​​​stringVal:"Xxxxxxx", ​​​​​​​colorStr:"217 11 0", ​​​​​​​colorVal:{​​​​​​​​​217, ​​​​​​​​​11, ​​​​​​​​​0​​​​​​​}, ​​​​​​​colorDomainName:"red", ​​​​​​​fontName:"ヒラギノ角ゴ ProN W6", ​​​​​​​fontSize:12.0​​​​​}, …
*)

on getAttributeRunsFromAttrString(theStyledText)
  script aSpd
    property styleList : {}
  end script
  
  
set (styleList of aSpd) to {} —for output
  
  
set thePureString to theStyledText’s |string|() –pure string from theStyledText
  
  
set theLength to theStyledText’s |length|()
  
set startIndex to 0
  
  
repeat until (startIndex = theLength)
    set {theAtts, theRange} to theStyledText’s attributesAtIndex:startIndex longestEffectiveRange:(reference) inRange:{startIndex, theLength – startIndex}
    
    
–String  
    
set aText to (thePureString’s substringWithRange:theRange) as string
    
    
–Color
    
set aColor to (theAtts’s valueForKeyPath:"NSColor")
    
if aColor is not equal to missing value then
      set aSpace to aColor’s colorSpace()
      
      
set aRed to (aColor’s redComponent()) * 255
      
set aGreen to (aColor’s greenComponent()) * 255
      
set aBlue to (aColor’s blueComponent()) * 255
      
      
set colList to {aRed as integer, aGreen as integer, aBlue as integer} –for comparison
      
set colStrForFind to (aRed as integer as string) & " " & (aGreen as integer as string) & " " & (aBlue as integer as string) –for filtering
    else
      set colList to {0, 0, 0}
      
set colStrForFind to "0 0 0"
    end if
    
    
–Color domain name
    
set cdnStr to retColorDomainNameFromNSColor(aColor) of me
    
    
–Font
    
set aFont to (theAtts’s valueForKeyPath:"NSFont")
    
if aFont is not equal to missing value then
      set aDFontName to aFont’s displayName()
      
set aDFontSize to aFont’s pointSize()
    end if
    
    
set the end of (styleList of aSpd) to {stringVal:aText, colorStr:colStrForFind, colorVal:colList, colorDomainName:cdnStr, fontName:aDFontName as string, fontSize:aDFontSize}
    
set startIndex to current application’s NSMaxRange(theRange)
    
  end repeat
  
  
return (styleList of aSpd)
  
end getAttributeRunsFromAttrString

on retColorDomainNameFromNSColor(aCol)
  set hueVal to aCol’s hueComponent()
  
set satVal to aCol’s saturationComponent()
  
set brightVal to aCol’s brightnessComponent()
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
set colName to ""
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colName to "black"
    else if (brightVal > 0.95) then
      set colName to "white"
    else
      set colName to "gray"
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colName to "red"
    else if hueVal ≤ (45.0 / 360) then
      set colName to "orange"
    else if hueVal < (70.0 / 360) then
      set colName to "yellow"
    else if hueVal < (150.0 / 360) then
      set colName to "green"
    else if hueVal < (190.0 / 360) then
      set colName to "cyan"
    else if (hueVal < 250.0 / 360.0) then
      set colName to "blue"
    else if (hueVal < 290.0 / 360.0) then
      set colName to "purple"
    else
      set colName to "magenta"
    end if
  end if
  
  
return colName
end retColorDomainNameFromNSColor

★Click Here to Open This Script 

Posted in Color list Record RTF | Tagged 10.11savvy 10.12savvy 10.13savvy | 1 Comment

TextEditで最前面のドキュメント内で使用されている色情報を抽出して処理対象色を選択(色名の計算機能つき)v3

Posted on 2月 10, 2018 by Takaaki Naganoya

TextEditの最前面の書類本文の色情報を抽出し、ダイアログ上に色選択ポップアップを作成して処理対象色をえらび、該当する色の文字を抽出するAppleScriptです。

DBColorNames.frameworkを用いて、900色程度の色見本から近似の色名称を計算しています。

–> dbColNamesKit.framework

AppleScript名:TextEditで最前面のドキュメント内で使用されている色情報を抽出して処理対象色を選択(色名の計算機能つき)v3
— Created 2017-12-26 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "Carbon" — AEInteractWithUser() is in Carbon
use framework "dbColNamesKit" –https://github.com/daniel-beard/DBColorNames/

property NSView : a reference to current application’s NSView
property NSColor : a reference to current application’s NSColor
property NSArray : a reference to current application’s NSArray
property NSMenu : a reference to current application’s NSMenu
property NSImage : a reference to current application’s NSImage
property NSScreen : a reference to current application’s NSScreen
property NSButton : a reference to current application’s NSButton
property NSWindow : a reference to current application’s NSWindow
property NSTextField : a reference to current application’s NSTextField
property NSMenuItem : a reference to current application’s NSMenuItem
property NSBezierPath : a reference to current application’s NSBezierPath
property NSPopUpButton : a reference to current application’s NSPopUpButton
property NSSortDescriptor : a reference to current application’s NSSortDescriptor
property NSWindowController : a reference to current application’s NSWindowController
property NSTitledWindowMask : a reference to current application’s NSTitledWindowMask
property NSRoundedBezelStyle : a reference to current application’s NSRoundedBezelStyle
property NSNormalWindowLevel : a reference to current application’s NSNormalWindowLevel
property NSBackingStoreBuffered : a reference to current application’s NSBackingStoreBuffered
property NSMomentaryLightButton : a reference to current application’s NSMomentaryLightButton

property windisp : false

if current application’s AEInteractWithUser(-1, missing value, missing value) is not equal to 0 then return

tell application "TextEdit"
  set dCount to count every document
  
if dCount = 0 then return
  
tell text of front document
    set aList to color of every attribute run
  end tell
end tell

–1D/2D Listのユニーク化
set ap1List to uniquify1DList(aList, true) of me

–色選択ダイアログを表示してポップアップメニューから色選択
set aButtonMSG to "OK"
set aWindowTitle to "Choose Color"

set aVal to getPopupValues(ap1List, 65535, aButtonMSG, aWindowTitle, 180) of me

if (aVal = false) or (aVal = missing value) then
  display dialog "No Selection" buttons {"OK"} default button 1 with icon 2
  
return
end if

set targColor to item aVal of ap1List
set aRes to pickupColoredText(targColor) of me
set the clipboard to aRes –抽出結果をクリップボードへ
return aRes

on getPopupValues(ap1List, aColMax, aButtonMSG, aWindowMSG, timeOutSecs)
  
  
set (my windisp) to true
  
  
set aView to NSView’s alloc()’s initWithFrame:(current application’s NSMakeRect(0, 0, 360, 100))
  
  
–Labelをつくる
  
set a1TF to NSTextField’s alloc()’s initWithFrame:(current application’s NSMakeRect(30, 60, 80, 20))
  
a1TF’s setEditable:false
  
a1TF’s setStringValue:"Color:"
  
a1TF’s setDrawsBackground:false
  
a1TF’s setBordered:false
  
  
–Ppopup Buttonをつくる
  
set a1Button to NSPopUpButton’s alloc()’s initWithFrame:(current application’s NSMakeRect(80, 60, 200, 20)) pullsDown:false
  
a1Button’s removeAllItems()
  
  
set a1Menu to NSMenu’s alloc()’s init()
  
  
set iCount to 1
  
repeat with i in ap1List
    copy i to {rCol, gCol, bCol}
    
set j to contents of i
    
    
set aCocoaList to retCocoaColorList(j, aColMax) of me
    
set nsCol to (NSColor’s colorFromRGBAArray:aCocoaList)
    
    
set anImage to makeNSImageWithFilledWithColor(32, 20, nsCol) of me
    
    
set aColName to retColorDetailName(rCol, gCol, bCol, 65535) of me
    
set aTitle to "#" & (iCount as string) & " " & aColName
    
set aMenuItem to (NSMenuItem’s alloc()’s initWithTitle:aTitle action:"actionHandler:" keyEquivalent:"")
    (
aMenuItem’s setImage:anImage)
    (
aMenuItem’s setEnabled:true)
    (
a1Menu’s addItem:aMenuItem)
    
    
set iCount to iCount + 1
  end repeat
  
  
a1Button’s setMenu:a1Menu
  
  
  
–Buttonをつくる
  
set bButton to (NSButton’s alloc()’s initWithFrame:(current application’s NSMakeRect(80, 10, 140, 40)))
  
bButton’s setButtonType:(current application’s NSMomentaryLightButton)
  
bButton’s setBezelStyle:(current application’s NSRoundedBezelStyle)
  
bButton’s setTitle:aButtonMSG
  
bButton’s setTarget:me
  
bButton’s setAction:("clicked:")
  
bButton’s setKeyEquivalent:(return)
  
  
aView’s addSubview:a1TF
  
  
aView’s addSubview:a1Button
  
aView’s addSubview:bButton
  
aView’s setNeedsDisplay:true
  
  
–NSWindowControllerを作ってみた
  
set aWin to (my makeWinWithView(aView, 300, 100, aWindowMSG))
  
  
set wController to NSWindowController’s alloc()
  
wController’s initWithWindow:aWin
  
  
wController’s showWindow:me
  
  
set aCount to timeOutSecs * 100
  
  
set hitF to false
  
repeat aCount times
    if (my windisp) = false then
      set hitF to true
      
exit repeat
    end if
    
delay 0.01
    
set aCount to aCount – 1
  end repeat
  
  
my closeWin:aWin
  
  
if hitF = true then
    set s1Val to (a1Button’s indexOfSelectedItem() as integer) + 1
  else
    set s1Val to false
  end if
  
  
return s1Val
  
end getPopupValues

on clicked:aSender
  set (my windisp) to false
end clicked:

–make Window for Display
on makeWinWithView(aView, aWinWidth, aWinHeight, aTitle)
  set aScreen to NSScreen’s mainScreen()
  
set aFrame to {{0, 0}, {aWinWidth, aWinHeight}}
  
  
set aBacking to current application’s NSTitledWindowMask
  
  
set aDefer to current application’s NSBackingStoreBuffered
  
  
— Window
  
set aWin to NSWindow’s alloc()
  (
aWin’s initWithContentRect:aFrame styleMask:aBacking backing:aDefer defer:false screen:aScreen)
  
–aWin’s setBackgroundColor:(current application’s NSColor’s whiteColor())
  
  
aWin’s setTitle:aTitle
  
aWin’s setDelegate:me
  
aWin’s setDisplaysWhenScreenProfileChanges:true
  
aWin’s setHasShadow:true
  
aWin’s setIgnoresMouseEvents:false
  
aWin’s setLevel:(current application’s NSNormalWindowLevel)
  
aWin’s setOpaque:false
  
aWin’s setReleasedWhenClosed:true
  
aWin’s |center|()
  
–aWin’s makeKeyAndOrderFront:(me)
  
  
aWin’s setContentView:aView
  
  
return aWin
  
end makeWinWithView

–close win
on closeWin:aWindow
  repeat with n from 10 to 1 by -1
    (aWindow’s setAlphaValue:n / 10)
    
delay 0.02
  end repeat
  
aWindow’s |close|()
end closeWin:

–Popup Action Handler
on actionHandler:sender
  set aTag to tag of sender as integer
  
set aTitle to title of sender as string
end actionHandler:

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

–1D Listをユニーク化
on uniquify1DList(theList as list, aBool as boolean)
  set aArray to NSArray’s arrayWithArray:theList
  
set bArray to aArray’s valueForKeyPath:"@distinctUnionOfObjects.self"
  
set bList to bArray as list
  
return bList
end uniquify1DList

–指定サイズのNSImageを作成し、指定色で塗って返す
on makeNSImageWithFilledWithColor(aWidth, aHeight, fillColor)
  set anImage to NSImage’s alloc()’s initWithSize:(current application’s NSMakeSize(aWidth, aHeight))
  
anImage’s lockFocus()
  
—
  
set theRect to {{x:0, y:0}, {height:aHeight, width:aWidth}}
  
set theNSBezierPath to NSBezierPath’s bezierPath
  
theNSBezierPath’s appendBezierPathWithRect:theRect
  
—
  
fillColor’s |set|() –色設定
  
theNSBezierPath’s fill() –ぬりつぶし
  
—
  
anImage’s unlockFocus()
  
—
  
return anImage
end makeNSImageWithFilledWithColor

on pickupColoredText(aColList)
  set outStrList to ""
  
  
tell application "TextEdit"
    tell text of front document
      set colorList to color of every attribute run
      
set textList to characters of every attribute run
      
      
set aCount to length of colorList
      
      
repeat with i from 1 to aCount
        set aColCon to item i of colorList
        
if aColCon is equal to aColList then –指定色の箇所
          set outStrList to outStrList & ((contents of item i of textList) as string) & return
        end if
      end repeat
      
    end tell
  end tell
  
  
return outStrList
end pickupColoredText

on retColorDetailName(rCol as integer, gCol as integer, bCol as integer, aColorMax)
  set aColor to makeNSColorFromRGBAval(rCol, gCol, bCol, aColorMax, aColorMax) of me
  
set aCDB to current application’s DBColorNames’s alloc()’s init()
  
set aColorStr to (aCDB’s nameForColor:aColor) as string
  
return aColorStr
end retColorDetailName

on retCocoaColorList(aColorList as list, aMax as integer)
  set tmpList to {}
  
repeat with i in aColorList
    set j to (contents of i)
    
    
if j = 0 then
      set the end of tmpList to 0
    else
      set the end of tmpList to (j / aMax) as real
    end if
    
  end repeat
  
set the end of tmpList to 1.0
  
return tmpList
end retCocoaColorList

–数値の1D List with Recordをソート
on sort1DRecList(aList as list, aKey as string, ascendingF as boolean)
  set aArray to NSArray’s arrayWithArray:aList
  
set desc1 to NSSortDescriptor’s sortDescriptorWithKey:aKey ascending:ascendingF selector:"compare:"
  
set bList to (aArray’s sortedArrayUsingDescriptors:{desc1}) as list
  
return bList
end sort1DRecList

★Click Here to Open This Script 

Posted in Color file GUI | Tagged 10.11savvy 10.12savvy 10.13savvy TextEdit | Leave a comment

TextEditの文章のうち赤っぽい色でマークされた箇所をピックアップする v2

Posted on 2月 9, 2018 by Takaaki Naganoya

TextEditの最前面の書類本文のうち、指定の色名称の色(red)に分類できる文字を出力するAppleScriptです。

AppleScript名:TextEditの文章のうち赤っぽい色でマークされた行をカウントする v2
— Created 2018-01-08 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSColor : a reference to current application’s NSColor

set rNum to 0
set colMax to 65535

tell application "TextEdit"
  tell text of document 1
    set pCount to (count paragraphs)
    
    
repeat with i from 1 to pCount
      set {rCol, gCol, bCol} to color of paragraph i
      
set cName to retColorDomainName(rCol, gCol, bCol, colMax) of me
      
      
if cName = "red" then –{r, g, b}
        set rNum to rNum + 1
      end if
    end repeat
    
  end tell
end tell

return {pCount, rNum}

on retColorDomainName(rCol as integer, gCol as integer, bCol as integer, aColorMax)
  set aCol to makeNSColorFromRGBAval(rCol, gCol, bCol, aColorMax, aColorMax) of me
  
set hueVal to aCol’s hueComponent()
  
set satVal to aCol’s saturationComponent()
  
set brightVal to aCol’s brightnessComponent()
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
set colName to ""
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colName to "black"
    else if (brightVal > 0.95) then
      set colName to "white"
    else
      set colName to "gray"
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colName to "red"
    else if hueVal ≤ (45.0 / 360) then
      set colName to "orange"
    else if hueVal < (70.0 / 360) then
      set colName to "yellow"
    else if hueVal < (150.0 / 360) then
      set colName to "green"
    else if hueVal < (190.0 / 360) then
      set colName to "cyan"
    else if (hueVal < 250.0 / 360.0) then
      set colName to "blue"
    else if (hueVal < 290.0 / 360.0) then
      set colName to "purple"
    else
      set colName to "magenta"
    end if
  end if
  
  
return colName
end retColorDomainName

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

★Click Here to Open This Script 

Posted in Color file | Tagged 10.11savvy 10.12savvy 10.13savvy TextEdit | 2 Comments

TextEditで本文中の使用色をリストアップ(色判定つき)v3

Posted on 2月 9, 2018 by Takaaki Naganoya

TextEditの最前面のドキュメントの本文色を取得して名称に変換して返すAppleScriptです。

本文中で「だいたいこの系統の色」が使われているかをリストアップします。

–> {“blue”, “red”, “green”}

ただし、いろいろ編集していると改行文字の箇所に意図しない色がついていることがあり、見た目だけではわからない色が検出されるケースもあります。そのような場合には、TextEditの文章のうち赤っぽい色でマークされた箇所をピックアップする v2を使って指定色に該当する箇所の文字データを抽出して確認してください(ペアで使うことを前提に書いたので)。

AppleScript名:TextEditで本文中の使用色をリストアップ(色判定つき)v3
— Created 2018-02-06 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSColor : a reference to current application’s NSColor
property NSArray : a reference to current application’s NSArray
property NSSortDescriptor : a reference to current application’s NSSortDescriptor

set colMax to 65535

tell application "TextEdit"
  set dCount to count every document
  
if dCount = 0 then return
  
tell text of front document
    set aList to color of every attribute run
  end tell
end tell

set ap1List to uniquify1DList(aList, true) of me

set cList to {}
repeat with i in ap1List
  copy i to {rCol, gCol, bCol}
  
set cName to retColorDomainName(rCol, gCol, bCol, colMax) of me
  
if cName is not in cList then
    set the end of cList to cName
  end if
end repeat

return cList
–> {"blue", "red", "green"}

–1D Listをユニーク化
on uniquify1DList(theList as list, aBool as boolean)
  set aArray to NSArray’s arrayWithArray:theList
  
set bArray to aArray’s valueForKeyPath:"@distinctUnionOfObjects.self"
  
set bList to bArray as list
  
return bList
end uniquify1DList

on retColorDomainName(rCol as integer, gCol as integer, bCol as integer, aColorMax)
  set aCol to makeNSColorFromRGBAval(rCol, gCol, bCol, aColorMax, aColorMax) of me
  
set hueVal to aCol’s hueComponent()
  
set satVal to aCol’s saturationComponent()
  
set brightVal to aCol’s brightnessComponent()
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
set colName to ""
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colName to "black"
    else if (brightVal > 0.95) then
      set colName to "white"
    else
      set colName to "gray"
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colName to "red"
    else if hueVal ≤ (45.0 / 360) then
      set colName to "orange"
    else if hueVal < (70.0 / 360) then
      set colName to "yellow"
    else if hueVal < (150.0 / 360) then
      set colName to "green"
    else if hueVal < (190.0 / 360) then
      set colName to "cyan"
    else if (hueVal < 250.0 / 360.0) then
      set colName to "blue"
    else if (hueVal < 290.0 / 360.0) then
      set colName to "purple"
    else
      set colName to "magenta"
    end if
  end if
  
  
return colName
end retColorDomainName

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

–数値の1D List with Recordをソート
on sort1DRecList(aList as list, aKey as string, ascendingF as boolean)
  set aArray to NSArray’s arrayWithArray:aList
  
set desc1 to NSSortDescriptor’s sortDescriptorWithKey:aKey ascending:ascendingF selector:"compare:"
  
set bList to (aArray’s sortedArrayUsingDescriptors:{desc1}) as list
  
return bList
end sort1DRecList

★Click Here to Open This Script 

Posted in Color file | Tagged 10.11savvy 10.12savvy 10.13savvy TextEdit | Leave a comment

TextEditで本文色をポスタライズ v2

Posted on 2月 9, 2018 by Takaaki Naganoya


▲Before


▲After

AppleScript名:TextEditで本文色をポスタライズ v2
— Created 2018-01-08 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use bPlus : script "BridgePlus" –https://www.macosxautomation.com/applescript/apps/BridgePlus.html

property NSColor : a reference to current application’s NSColor
property NSArray : a reference to current application’s NSArray
property NSSortDescriptor : a reference to current application’s NSSortDescriptor

script spd
  property colList : {}
  
property attList : {}
end script

load framework

set cList to retTextEditColors() of me
set dList to {}

repeat with i in cList
  copy i to {rVal, gVal, bVal}
  
set newColList to posterizeColor(rVal, gVal, bVal, 65535) of me
  
repTextEditColor(i, newColList) of me
end repeat

on repTextEditColor(targColor, newColor)
  set hitIndex to {}
  
  
tell application "TextEdit"
    tell text of front document
      set colList to color of every attribute run
    end tell
  end tell
  
  
set hitIndex to (current application’s SMSForder’s indexesOfItem:targColor inArray:(colList) inverting:false) as list
  
  
tell application "TextEdit"
    tell text of front document
      repeat with i in hitIndex
        ignoring application responses
          set color of attribute run (i + 1) to newColor –0 based index to 1 based index conversion
        end ignoring
      end repeat
    end tell
  end tell
end repTextEditColor

on posterizeColor(rCol as integer, gCol as integer, bCol as integer, aColorMax)
  set aCol to makeNSColorFromRGBAval(rCol, gCol, bCol, aColorMax, aColorMax) of me
  
set hueVal to aCol’s hueComponent()
  
set satVal to aCol’s saturationComponent()
  
set brightVal to aCol’s brightnessComponent()
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colVal to {0, 0, 0} –Black
    else if (brightVal > 0.95) then
      set colVal to {65535, 65535, 65535} –White
    else
      set colVal to {32768, 32768, 32768} –Gray
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colVal to {65535, 0, 0} –red
    else if hueVal ≤ (45.0 / 360) then
      set colVal to {65535, 32768, 0} –orange
    else if hueVal < (70.0 / 360) then
      set colVal to {65533, 63639, 2654} –yellow
    else if hueVal < (150.0 / 360) then
      set colVal to {4626, 35488, 17789} –green
    else if hueVal < (190.0 / 360) then
      set colVal to {0, 60802, 65535} –cyan, light blue
    else if (hueVal < 250.0 / 360.0) then
      set colVal to {0, 0, 65535} –blue
    else if (hueVal < 290.0 / 360.0) then
      set colVal to {32768, 0, 32768} –purple
    else
      set colVal to {65535, 0, 65535} –magenta, pink
    end if
  end if
  
  
return colVal
end posterizeColor

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

on retTextEditColors()
  tell application "TextEdit"
    set dCount to count every document
    
if dCount = 0 then return
    
tell text of front document
      set aList to color of every character
    end tell
  end tell
  
  
set ap1List to uniquify1DList(aList, true) of me
  
set cList to {}
  
repeat with i in ap1List
    set the end of cList to contents of i
  end repeat
  
  
return cList
end retTextEditColors

–1D Listをユニーク化
on uniquify1DList(theList as list, aBool as boolean)
  set aArray to NSArray’s arrayWithArray:theList
  
set bArray to aArray’s valueForKeyPath:"@distinctUnionOfObjects.self"
  
set bList to bArray as list
  
return bList
end uniquify1DList

★Click Here to Open This Script 

Posted in Color file | Tagged 10.11savvy 10.12savvy 10.13savvy TextEdit | Leave a comment

TextEditの文章のうち赤っぽい色でマークされた行をカウントする v2

Posted on 2月 9, 2018 by Takaaki Naganoya

TextEditでオープン中の最前面のドキュメント本文の色情報にアクセスして、「赤っぽい色」でマークされた行をカウントするAppleScriptです。

TextEdit本文から色情報を抽出しただけでは、RGB色の配列データで合っているかどうか、直接の値の比較を行う程度の処理になってしまうため、色データの値がちょっとズレただけでも「赤」として認識されません。

RGB色からHSB色に変換して、おおよその色の名前を計算することで、「赤っぽい色でマークされた行」を抽出してカウントできるようにしてみました。

テストのためにTextEditで処理してみましたが、PagesでもKeynoteでも、InDesignでもIllustratorでも同様のアプローチで色を数値から「だいたいの色」に抽象化することで、高度な判定処理を行うことが可能になります。

AppleScript名:TextEditの文章のうち赤っぽい色でマークされた行をカウントする v2
— Created 2018-01-08 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSColor : a reference to current application’s NSColor

set rNum to 0
set colMax to 65535

tell application "TextEdit"
  tell text of document 1
    set pCount to (count paragraphs)
    
    
repeat with i from 1 to pCount
      set {rCol, gCol, bCol} to color of paragraph i
      
set cName to retColorDomainName(rCol, gCol, bCol, colMax) of me
      
      
if cName = "red" then –{r, g, b}
        set rNum to rNum + 1
      end if
    end repeat
    
  end tell
end tell

return {pCount, rNum}

on retColorDomainName(rCol as integer, gCol as integer, bCol as integer, aColorMax)
  set aCol to makeNSColorFromRGBAval(rCol, gCol, bCol, aColorMax, aColorMax) of me
  
set hueVal to aCol’s hueComponent()
  
set satVal to aCol’s saturationComponent()
  
set brightVal to aCol’s brightnessComponent()
  
  
if satVal ≤ 0.01 then set satVal to 0.0
  
  
set colName to ""
  
  
if satVal = 0.0 then
    if brightVal ≤ 0.2 then
      set colName to "black"
    else if (brightVal > 0.95) then
      set colName to "white"
    else
      set colName to "gray"
    end if
  else
    if hueVal ≤ (15.0 / 360) or hueVal ≥ (330 / 360) then
      set colName to "red"
    else if hueVal ≤ (45.0 / 360) then
      set colName to "orange"
    else if hueVal < (70.0 / 360) then
      set colName to "yellow"
    else if hueVal < (150.0 / 360) then
      set colName to "green"
    else if hueVal < (190.0 / 360) then
      set colName to "cyan"
    else if (hueVal < 250.0 / 360.0) then
      set colName to "blue"
    else if (hueVal < 290.0 / 360.0) then
      set colName to "purple"
    else
      set colName to "magenta"
    end if
  end if
  
  
return colName
end retColorDomainName

on makeNSColorFromRGBAval(redValue as integer, greenValue as integer, blueValue as integer, alphaValue as integer, aMaxVal as integer)
  set aRedCocoa to (redValue / aMaxVal) as real
  
set aGreenCocoa to (greenValue / aMaxVal) as real
  
set aBlueCocoa to (blueValue / aMaxVal) as real
  
set aAlphaCocoa to (alphaValue / aMaxVal) as real
  
set aColor to NSColor’s colorWithCalibratedRed:aRedCocoa green:aGreenCocoa blue:aBlueCocoa alpha:aAlphaCocoa
  
return aColor
end makeNSColorFromRGBAval

★Click Here to Open This Script 

Posted in Color file | Tagged 10.11savvy 10.12savvy 10.13savvy TextEdit | 1 Comment

ColorCubeによる頻出色の抽出

Posted on 2月 9, 2018 by Takaaki Naganoya

ColorCube.frameworkを呼び出して、指定画像の頻出色を抽出するAppleScriptです。

抽出した色数をダイアログ表示したあとに、抽出した色をchoose colorダイアログで抽出色分だけプレビューします。JPEG画像からの色抽出はうまくできましたが、透過色つきのPNG画像の演算結果は納得行かないものがありました。JPEG推奨です。

ColorCubeには除外色の指定を明示的に(flagsではなく)指定できるはずですが、NSColor’s whiteColor()などで指定してもエラーになったので、flagsによる制御を推奨します。

–> ColorCube.framework

AppleScript名:ColorCubeによる頻出色の抽出
— Created 2018-02-05 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
use framework "ColorCube" –https://github.com/pixelogik/ColorCube

property CCOnlyBrightColors : 1
property CCOnlyDarkColors : 2
property CCOnlyDistinctColors : 4
property CCOrderByBrightness : 8
property CCOrderByDarkness : 16
property CCAvoidWhite : 32
property CCAvoidBlack : 64

–List up frequent colors from image
set aFile to POSIX path of (choose file of type {"public.image"})
set targImage to current application’s NSImage’s alloc()’s initWithContentsOfFile:aFile
set colorCube to current application’s CCColorCube’s alloc()’s init()

–set imgColors to (colorCube’s extractColorsFromImage:targImage flags:(CCOnlyDistinctColors + CCAvoidWhite)) as list
set imgColors to (colorCube’s extractColorsFromImage:targImage flags:(CCAvoidWhite) |count|:4) as list

display dialog (length of imgColors) as string

repeat with i in imgColors
  set r2Val to i’s redComponent()
  
set g2Val to i’s greenComponent()
  
set b2Val to i’s blueComponent()
  
set a2Val to i’s alphaComponent()
  
  
set r2Val to r2Val * 65535
  
set g2Val to g2Val * 65535
  
set b2Val to b2Val * 65535
  
  
choose color default color {r2Val, g2Val, b2Val}
end repeat

★Click Here to Open This Script 

Posted in Color file Image | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Post navigation

  • Older posts
  • Newer posts

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • macOS 13.6.5 AS系のバグ、一切直らず
  • CotEditorで2つの書類の行単位での差分検出
  • Apple純正マウス、キーボードのバッテリー残量取得
  • macOS 15, Sequoia
  • 初心者がつまづきやすい「log」コマンド
  • 指定のWordファイルをPDFに書き出す
  • Adobe AcrobatをAppleScriptから操作してPDF圧縮
  • メキシカンハットの描画
  • 与えられた文字列の1D Listのすべての順列組み合わせパターン文字列を返す v3(ベンチマーク用)
  • Pages本執筆中に、2つの書類モード切り替えに気がついた
  • 2023年に書いた価値あるAppleScript
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • AdobeがInDesign v19.4からPOSIX pathを採用
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • Cocoa Scripting Course 続刊計画
  • Numbersで選択範囲のセルの前後の空白を削除
  • macOS 14.xでScript Menuの実行速度が大幅に下がるバグ
  • NaturalLanguage.frameworkでNLEmbeddingの処理が可能な言語をチェック
  • AppleScriptによる並列処理

Tags

10.11savvy (1102) 10.12savvy (1243) 10.13savvy (1392) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (207) 13.0savvy (177) 14.0savvy (127) 15.0savvy (104) CotEditor (64) Finder (51) iTunes (19) Keynote (115) NSAlert (61) NSArray (51) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (53) NSDictionary (28) NSFileManager (23) NSFont (21) NSImage (41) NSJSONSerialization (21) NSMutableArray (63) NSMutableDictionary (22) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (119) NSURL (98) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (74) Pages (54) Safari (44) Script Editor (27) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • Beginner
  • Benchmark
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • check sum
  • Clipboard
  • Cocoa-AppleScript Applet
  • Code Sign
  • Color
  • Custom Class
  • dialog
  • diff
  • drive
  • Droplet
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Localize
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • parallel processing
  • PDF
  • Peripheral
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2025年1月
  • 2024年12月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2024年2月
  • 2024年1月
  • 2023年12月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC