2012年10月12日金曜日

やり残しのはじめの一歩

DTPに戻れるはずなどなく、かといって警備で骨を埋める覚悟もできず、相変わらず宙ぶらりんな日々を過ごしてます。

CLさんがDTPから離れたのを機に諦めがつきましたが、それでもここへきてやり残したことがいくつかあったので。

最初に見たときから能力的に無理と放置してた事例が、ほぼ5年前のネタ

掲示板に神の啓示  
Illustratorに貼り込まれた画像のサイズをリスト化する処理が必要となり、先週末からいろいろとトライしている。オブジェクトのプロパティからは幅と高さが参照できるのだが、どうやら回転がかかった場合は回転がかかった時の幅と高さになる模様。つまりオブジェクトの本来の幅と高さではなく、相対的な幅と高さということになる。
対応策としては「回転を外した状態にしてから幅と高さを求める」というのが素直な考えだが、残念ながら回転の値が存在しない。IllustratorのオブジェクトはInDesignやQuarkXPressのようにボックスの左上を基準とした座標値や回転値などから場所を割り出すのではなく、6つのマトリックスを用いた方法で表現しているようで、ここらへんになってくるとお手上げだった。
答えは
(DTPtechNote:1750) Re: Illustratorのオブジェクト情報

かと思いきや、イケッチさんのBBSで修正されているのでメモ

13 イラストレータ変形率を返すルーチン

投稿者:イケッチ 投稿日:2008/03/03(Mon) 23:31
せいぞーさんのBBSに書き込んだ者に誤りがあったので修正

on get_henkei_of_link_info(thePlacedItem)
tell application “Adobe Illustrator”
set theClass to class of thePlacedItem
if theClass is not placed item and theClass is not raster item then return 0
set theMatrix to matrix of thePlacedItem
set _a to mvalue_a of theMatrix
set _b to mvalue_b of theMatrix
set _c to mvalue_c of theMatrix
set _d to mvalue_d of theMatrix
set theRad to do javascript “Math.atan2(” & _b & “,” & _a & “);”
set tateRad to do javascript “Math.atan2(” & _d & “,” & _c & “);”
set tateRatio to do javascript “Math.cos(” & theRad - tateRad - 0.5 * pi & “);”
if tateRatio < 0 then
set tateRatio to -tateRatio
end if
set tateRatio to ((tateRatio * ((_c ^ 2 + _d ^ 2) ^ 0.5) + 5.0E-6) div 1.0E-5) * 1.0E-3
set yokoRatio to (((_a ^ 2 + _b ^ 2) ^ 0.5 + 5.0E-6) div 1.0E-5) * 1.0E-3
set theAngle to theRad * 180 / pi
if theAngle < 0 then
set theAngle to -((theAngle - 5.0E-4) div 1.0E-3) * 1.0E-3
else
set theAngle to -((theAngle + 5.0E-4) div 1.0E-3) * 1.0E-3
end if
return {yoko:yokoRatio, tate:tateRatio, kaiten:-theAngle}
end tell
end get_henkei_of_link_info

tell application “Adobe Illustrator”
my get_henkei_of_link_info(item 1 of selection of document 1)
end tell


三角関数の復習と理解から始めなくてはなりませんので苦労してます(^^;

しばらく三角関数の入門メモ書きが続きますので分かる人は無視してください。

といっても、このblogを読んでる人は7人くらいのもので断る必要もないのですが。。。

0 件のコメント:

コメントを投稿