約 2,061,056 件
https://w.atwiki.jp/p-phun/pages/36.html
ThymeはPhunやAlgodooで使用されているスクリプト言語です。 Thymeスクリプトを使用すると、例えば、時間に合わせて引力の値が変化する図形を作ることができます。 目次 Thyme.cfgの内容 Scene.my.~ 関数の宣言 衝突時に呼び出す関数の宣言(onCollide) 衝突した相手の物質のタイプを得る e.normalの解説 リファレンス Thyme.cfgの内容 以下の文章は、Phunβ5.25に同梱されている、Thyme.cfgの内容を訳したものです(読みやすさのために、訳者の補足説明も地の文として表示しています)。 ThymeはAlgodooとPhunにおいて実装されている独自のスクリプト言語です。 基本となる型は4種類あります。Int型、Float型、Bool型、String型です。これらの型を組み合わせて、配列(リスト)や関数を作成することが可能です。 識別子は演算子 = を用いて宣言します。代入には = を使用してください。識別子は型付けされません。 hoge = 7; // 新しい識別子 hoge を初期値3で宣言します。 hoge = [hoge, "hello", true]; // 宣言済みの変数 hoge をリストとして再定義します。 このリストはヘテロジニアス(Heterogeneous 異種混合)です。 print hoge(1); // このコードは "hello" を返します。()で配列の要素にアクセスしています。 print hoge([0,2]); // このコードは [7, true] を返します。 isEven = (n)= { n%2==0 }; // 関数 "isEven" を宣言します。 1つの引数を受取、もし、その値が偶数ならtrueを返す関数です。 for関数が実装されています。 for関数は、Thymeにおけるシンプルなループ構造です。「再帰の上限」が存在する影響で、約50回以上ループさせると警告・もしくはエラーが出ます。 次のように使われます for(n, (i)- { ... }); ここで n は関数を呼ぶ回数です。 i は 0, 1, ..., n-2, n-1 受け取ります。 例 for(4, (n)= {print ((n+1) + " bottles of beer on the wall.")}) 出力 1 bottles of beer on the wall. 2 bottles of beer on the wall. 3 bottles of beer on the wall. 4 bottles of beer on the wall. for関数は以下のように実装されています。 for = (n, what)= { n 0 ? true { for(n - 1, what); what(n-1) } }; 他にも関数の定義例があります。 inclusive_range = (min, max)= {min max ? [] {[min] ++ inclusive_range(min + 1, max)}}; infix 2 left _ .. _ = inclusive_range; // Usage 1..5 == [1,2,3,4,5] infix は 演算子を定義します。これを定義しておくと、1..5 が [1,2,3,4,5]と同値になります。 infix 2 left は、結合の優先順位が2で、左結合という意味です。数が大きいほど優先順位が高く、演算子は強く結合します。 - Thyme.cfgの内容ここまで。 Scene.my.~ シーンデータで使う独自の変数には Scene.my.test = 1; という具合に、先頭にScene.my.を付けて宣言します。 使用する際も、Scene.my.を付けます。 変数や関数を宣言する際に、Scene.my.を付けず、 test = 1; などと定義してしまうと、testの定義がシーンファイルには保存されず、config.cfgに保存されてしまいます。 これには欠点が2つあります。 (欠点1)... 他人にシーンデータを渡しても上手く動作しない。 シーンデータに宣言した変数の情報がないため、Phunがシーンファイルを上手く解釈することができません。 (欠点2)... 管理が面倒。 config.cfgはPhunを起動する度に読み込まれる設定ファイルなので、config.cfgファイルを削除するかconfig.cfgを編集して該当箇所を取り除かない限り、宣言した変数の定義が残り続けてしまいます。逆に、config.cfgを消してしまうと、たとえシーンデータが残っていても、変数を宣言しなおす必要があります。 また、scene1.phz というシーンデータとscene2.phzで、同じ変数 test を使用していると、scene1.phzでtestの変数の値を迂闊に変更できないということになります。scene2.phzの挙動に影響するためです。 特に(欠点1)は忘れてはならない欠点です。 これらの欠点を理解し、通常は、シーンの変数にScene.my.~という識別子を使用するようにしましょう。 関数の宣言 関数は、 関数名 = (引数 [,引数2, 引数3, ...]) = {処理内容} という形式で定義することができます。 絶対値を返す関数: Scene.my.abs = (x) = {x 0 ? x -x}; 使用例 Scene.my.abs(-4) 出力 4 値を整数に丸める関数(Int型に型変換を行うわけではありません) Scene.my.floor = (x) = {x = 0 ? x - math.mod(x, 1) (math.mod(x, 1) == 0 ? x x - math.mod(x, 1) - 1)}; 使用例: Scene.my.floor(3.14) 出力 3 距離を返す関数: Scene.my.dist = (a, b)= {((a(0) - b(0)) ^ 2 + (a(1) - b(1)) ^ 2)^0.5}; 使用例: Scene.my.dist([0, 0], [3, 4]) 出力: 5 rand関数の実装例: Scene.my.next_rand = 1; Scene.my.rand = () = {Scene.my.next_rand = Scene.my.next_rand * 1103515245 + 12345; (Scene.my.next_rand / 65536) % 32768;}; Scene.my.srand = (rand_seed) = {Scene.my.next_rand = Scene.my.rand_seed}; (このrand関数は、RAND_MAX = 32767 です。) 使用例: Scene.my.rand; Scene.my.rand; 出力 16838 -27009 衝突時に呼び出す関数の宣言(onCollide) 図形の衝突時に関数を呼び出すことも可能です。onCollideという属性を利用します。 onCollide = (e)= {処理したい内容} という記述方法で、この処理内容の中では、衝突された図形および衝突した図形の属性の値を、 e.this.collideSet や e.other.color で手に入れることができます。thisはスクリプトの書かれている図形、otherは衝突した図形です。 その他、e.posで衝突した位置を、e.normalで衝突した面の向きを得ることができます。 例えば、 Scene.addBox{ onCollide = (e)= {Scene.addCircle{ radius = 0.1; collideSet = e.this.collideSet; pos = e.pos}}; } という図形(この場合はボックス)をPhunで作成すると、衝突する度に、衝突した位置に半径が0.1メートルで衝突グループが図形と同じ円(まる)が出る図形の完成です。※このスクリプトのままだと、物体が出続けてしまいます。 他に、 衝突するたびに色や密度の変化する図形 スコアボード 色の読み取り(Scene.my.で独自の変数recognitionを定義しています。) などの例があります。 純粋なシミュレーションではなく、主にゲーム目的に広く応用できそうな機能と言えるかもしれません。 衝突した相手の物質のタイプを得る 公式フォーラムより。Iggyhopper氏の投稿内容です。 (e.other + "") で衝突した物体のタイプを判断することができます。 四角形→box まる→circle 平面→plane ポリゴン→polygon 使用例 (e) = { e.this.text = e.other + "" } 使用例2 (e) = { e.other + "" == "box" ? {e.this.color = [0.5, 1, 0.5, 1]} {e.this.color = [1, 1, 0.5, 1]} } e.normalの解説 e.normalは衝突面の角度に対応したcosとsinを組み合わせた配列である。 以下のコードを利用することで角度(ラジアン)に変換することができる。 Scene.my.atan2 = (y, x)= { x == 0 ? { y 0 ? {math.pi/2} {-math.pi/2}} { x 0 ? {math.atan(y/x)} { y 0 ? {math.atan(y/x) + math.pi} {math.atan(y/x) - math.pi}}}} Scene.my.atan2(e.normal(1), e.normal(0)) このページの他、Thyme講座やThyme例文集、Thyme実例集も参考になるかもしれません。 リファレンス Gradyが使用できるコマンドをリストアップしてくれました(英語での説明付き)。 AlgodooのThymeコマンドリスト Phun β5.24のコマンドリスト その他リファレンス Phun本家Wiki Thyme Algodoo本家Wiki Thyme PhunフォーラムのThyme関連トピック一覧 ※Algodooフォーラムへの移行に伴い、凍結されました (Thyme関連トピック数 356件 / 返信数 1,924件 / 閲覧数累計 192,961 view )。 AlgodooフォーラムのThyme関連トピック一覧
https://w.atwiki.jp/1232/pages/2.html
メニュー トップページ メニュー? 更新履歴 取得中です。
https://w.atwiki.jp/p-phun/pages/66.html
Thyme講座 なにはともあれ書き方と例文 基礎的なあれこれ §いつどこでどのようにスクリプトが動くのか §値と変数 配列 §データ型 式の処理順序、データ型の優先順位 §演算子 数値を扱う場合 文字列を扱う場合 ブール限定の演算 配列に対する演算 §その他、覚えておくべきこと 使用できる変数について 実用的なお話へ §条件分岐構造と三項演算子 条件分岐構造 三項演算子 §関数 関数とは何か 作成と使用 用意されている関数 §配列の応用 大きな間違いの訂正とお詫び コメント欄 Thyme講座 Thymeは初心者やプログラム経験のない方にとってはハードルが高い。思いつきではあるが、ここにThyme講座を書きなぐっていきたいと思う。 尚思いつきかつ、筆者も独学にちかい部分があるため、不明瞭な部分や間違い等があると予想される。 そのような部分を発見した場合、コメントにて指摘いただけるとありがたい。 なにはともあれ書き方と例文 まずスクリプトがどのようなものなのか、見ていただこう。 物質のテキスト文章部分にシミュレーション開始からの経過時間を表示させるスクリプト text = { "" + sim.time }; 常に物質の色を変え続けるスクリプト color = { [ sim.time % 1.0 , sim.time * 0.5 % 1.0 , sim.time * 0.3 % 1.0 , 1.0 ] }; このような1処理分の塊を「式」という。 式1つは「○○○ = ○○○」の形をとる。 ただし、スクリプトメニューをよく見ると「text =」や「color =」は既に記述されている。 このため、1つ目を例を実際に使用したい場合は「{ "" + sim.time }」を「text =」項目の内容部分に記述すれば良い。 尚、各例文の最後についてある「;」は「式がここで終わり」という意味の記号である 1つの式のみをスクリプトメニューに記載した場合、決定した時に「;」が消えてしまうが、これはPhunの仕様である。 どうやら、「式の数にかかわらず、最後の;は省略する」というルールが存在しているようである。 この解説においては、式の数にかかわらず;を表記すると、断りを入れておく。 基礎的なあれこれ §いつどこでどのようにスクリプトが動くのか Thymeスクリプトを実行出来る場所は2箇所ある。 F11キーを押して現れるコンソール画面への直接入力 物質を選択後、メニューの「スクリプトメニュー」内の各属性値への記述 スクリプト言語Thymeのページには、onCollide属性内以外への記述については特に述べられていないが 書式さえ守ればどの属性内にも直接スクリプトを記述できる。 onCollide以外の属性へ書き込む場合の注意点としては以下の2つ。 「{ (スクリプト内容) }」の形式で書き込むこと({ }で囲む) 各属性ごとに決められているデータ型と、スクリプトが出力する値の型を合わせる事 どちらかの条件が満たされていない場合、書き込んだあとに決定しても編集前の状態に戻ってしまう。 §値と変数 式に用いる数値や文字のことを総称して値(あたい)と言う。値には定数と変数の2種がある。 定数とは「値が固定されているもの」であり、明確に数値が表記されているものである。 変数とは「名前の付けられた箱」であり、その中に入っている値を変更できるものである。 以下に例として4行の計算を示し、解説をする。 行番号 内容 説明 1行目 x = 3; xという変数を内容「 3 」で作成 2行目 x = x + 4 - 5; xに『 x + 4 - 5 』の計算結果を入れる 3行目 y = x + x; yという変数を内容『 x + x 』で作成 4行目 y = x + y; yに『 x + y 』の計算結果を入れる 1行目 x = 3; 「xを3という内容で作成します」という意味の式。 変数を始めに作成する演算子「 =」を用いている。 変数には必ず初期値が必要であり、この場合は「3」である。 2行目 x = x + 4 - 5; 「xに『 x + 4 - 5 』の計算結果を入れる」という意味の式。 変数の値を変更する演算子「=」を用いている。 xの値は3であるため『x+4-5』は2となり、xの値が2に変更される。 3行目 y = x + x; 「yという変数を内容『 x + x 』で作成します」という意味の式。 初期値に「すでに作成済みである変数を用いた計算式」を使用しても問題ない。 つまりこの式は「 y = 2 + 2; 」と同義であり、yの初期値は4になる。 4行目 y = x + y; 「yに『 x + y 』の計算結果を入れる」という意味の式。 xは2でありyは4であるため、この式は「y= 2 + 4;」と同義である。 結果としてyの値は6になる。 注意事項 実際に変数を作成し使用する際には、変数名の前に「Scene.my.」をつけなければならない。 この決まりに従って上記の例を実際に使用する場合、以下のようになる Scene.my.x = 3; Scene.my.x = Scene.my.x + 4 - 5; Scene.my.y = Scene.my.x + Scene.my.x; Scene.my.y = Scene.my.x + Scene.my.y; 配列 変数の種類として「配列」がある。 変数は1つに対して1つの値しか持てないが、配列は複数個の値を持つことが出来る。 イメージとしては「1つの名前を共有する複数の箱があり、それは番号で区別される」といったものである。 実際に配列を使用している例を以下に示す。 Scene.my.x = [ 1 , 5 , 10 , 999 , 7 ]; Scene.my.y = Scene.my.x(0); Scene.my.z = Scene.my.x(2) + Scene.my.x(3); 順を追って解説していこう。 1行目 ここでScene.my.xという配列を作成している。 配列を作る際の書式は「 変数名 = [ 配列の内容 ]; 」である。 この配列の内容を書き表すと以下のようになる。 scene.my.x(0) scene.my.x(1) scene.my.x(2) scene.my.x(3) scene.my.x(4) 1 5 10 999 7 2行目 変数Scene.my.yを作成し、その内容としてScene.my.xの0番目を指定している。 配列の内容を指定する書式は「 変数名(番号) 」である。 この際注意する点は「番号は0から始まる」ということである。つまり、Scene.my.xの中身は0~4番までの5つ存在する。 3行目 変数Scene.my.zを作成し、その内容として「Scene.my.xの2番目と3番目を加算した値」を指定している。 Scene.my.xの2番目は10、3番目は999であるため、Scene.my.zの値は1009となる。 尚、配列の内容を書き換える際には注意が必要である。 scene.my.x = [ 1 , 2 , 3 ]; scene.my.x(2) = 99; 上記のスクリプトは「scene.my.x の2番目の内容を99に書き換える」ことを意図したものであるが これはその意図通りには動かない。 配列の中身を部分的に書き換える際には、非常に面倒くさい式になるが scene.my.x = [ 1 , 2 , 3 ]; scene.my.x = [ scene.my.x(0) , scene.my.x(1) , 99 ]; と、このように書くしかない。 §データ型 面倒な話だが、これはどうしても避けて通れない スクリプトで扱う値は4つに分類されている。 分類のされ方は以下のとおり 型名 内容 例 文字列型 1文字以上の文字列 "" "A" "B" "AABB" "あいうえお" 浮動小数点型 小数点以下を含む数字 0.0 1.5 1.0001 10000.0 整数型 小数点以下がない数字 0 1 100 10000 ブール型 正か偽を表現 true false 注意するべきは、整数型と浮動小数点型の違いである。 「0」は整数だが「0.0」は浮動小数点となる。同様に「1」は整数だが「1.0」は浮動小数点である。 文字列型の「""」は「0文字のテキストデータ」を表している。 以下に物質のスクリプトメニュー内の各項目について型を示す。 項目名 データ型 airFrictionrMult = 浮動小数点 attraction = 浮動小数点 collideSet = 整数 collideWater = ブール color = 浮動小数点(配列、要素数4) controllerAcc = 浮動小数点 controllerInvertX = ブール controllerInvertY = ブール controllerReverseXY = ブール density = 浮動小数点 drawBorder = ブール friction = 浮動小数点 heteroCollide = ブール immortal = ブール killer = ブール onCollide = 関数 opaqueBorders = ブール restitution = 浮動小数点 ruler = ブール text = 文字列 textColor = 浮動小数点(配列、要素数4) textScale 浮動小数点 texture 文字列 textureMatrix 浮動小数点(配列、要素数9) 式の処理順序、データ型の優先順位 式には細かな処理の順番がある。 たとえば「 x = 1 + 2 + 3 + 4 + 5; 」という式は 「 x = (((( 1 + 2) + 3 ) + 4 ) + 5 ); 」この括弧のもっとも内側から順に処理される。 型にも優先順位があり、以下のようになっている。 文字列型 > 浮動小数点型 > 整数型 文字列型 > ブール型 これは、「異なる型の値同士を処理する際に、結果を何型にするか」というものであり 下位のものと上位のものを同じ式で扱う場合、式の結果は上位の型になる。 例として以下のさまざまな式について、計算結果を見ていこう。 式 xに入る値 結果のデータ型 x = 1 + 2 + 3; 6 整数 x = 1 + 2 + 3.0; 6.0 浮動小数点 整数のみの式は結果も整数。浮動小数点型が1つでも含まれる場合、浮動小数点になる。 式 xに入る値 結果のデータ型 x = 1 + "A"; "1A" 文字列 x = 1.0 + "A"; "1A" 文字列 x = "A" + 1.0; "A1" 文字列 文字列と整数、浮動小数点の演算は、結果文字列となる。 尚この際に1.0や2.0などの小数点以下が0の浮動小数点については、小数点以下は省略される。 式 xに入る値 結果のデータ型 x = 1 + 2 + 3 + "A"; "6A" 文字列 x = 1 + "A" + 2 + 3; "1A23" 文字列 上の式だと、「1+2+3」が処理されるまでは整数の足し算であり、「+"A"」で最後に文字列型になる。 下の式では、最初の「1+"A"」の結果が「"1A"(文字列型)」となり、それ以降の演算も「文字列型+整数型」となるため結果が「"1A23"」となる。 式 xに入る値 結果のデータ型 x = 1 + 2.2 + "A" + "B"; "3.2AB" 文字列 x = 1 + 2.2 + "A" + true; "3.2Atrue" 文字列 上の式は特に解説の必要はないと思われる。 下の式は、「1+2.2+"A"」が「"3.2A"」となり、その後「"3.2A"+ true」つまり「文字列型+ブール型」の演算となる。 ブール型の値「true」は文字列と演算する際には、そのままの文字「"true"」として扱われるため 結果として「"3.2A" + "true"」と同義である。したがって結果は「"3.2Atrue"」となる。 式 xに入る値 結果のデータ型 x = 1 + true; (演算不可) - x = 1 + "" + true; "1ture" 文字列 x = true + 1.0; (演算不可) - x = true + "" + 1.0; "true1" 文字列 整数型とブール型の演算については演算不可となりエラーが起きる。浮動小数点型も同じく。 ただし、整数と文字列型、文字列型とブール型は演算できるため、途中に「""(空の文字列)」をはさめば演算が行える。 x = true + true + "" + 1 (演算不可) - x = true + "" + true + 1 "truetrue1" 文字列 ブール型同士の四則演算も演算不可である。 ただしこれも間に空文字列を挟むことにより演算は行える。 §演算子 演算に使用する記号を総称して「演算子」と呼ぶ。 演算子の左辺と右辺には値がくる(三項演算子は除外) 演算子は総じて演算結果である値を残す 要は「+」や「-」などといった計算記号のことである。 以下に演算子を分類ごとに紹介する。 数値を扱う場合 算術演算子 演算子 意味 例文 演算結果 + 加算 3 + 4 7 3 + 4.0 7.0 - 減算 5 - 2 3 5 - 2.0 3.0 * 乗算 4 * 5 20 4 * 5.0 20.0 / 除算 8 / 4 2 8 / 5 1 8 / 5.0 1.6 % 剰余 8 % 5 3 8 % 5.0 3.0 ^ 累乗 2 ^ 3 8 10 ^ 3 1000 基本的には浮動小数点と整数の演算は、結果が浮動小数点になることに気をつけておけばよい。 除算の場合は、割る数が整数ならば演算結果も整数だが、割る数が浮動小数点ならば小数点以下も計算される。 剰余とは割り算の余りのことである。浮動小数点を含む計算でも問題なく余りが求められる。 関係演算子 演算子 意味 例文 演算結果 == 等しい 1 == 1 true 1 == 2 false != 等しくない 1 != 1 false 1 != 2 true 大なり 1 2 false 2 1 true 小なり 1 2 true 2 1 false = 以上 1 = 1 true 1 = 2 false = 以下 1 = 1 true 2 = 1 false 文字列を扱う場合 演算子 意味 例文 演算結果 + 加算 "ABC" + "DE" "ABCDE" == 等しい "AB" == "AB" true != 等しくない "AB" != "ab" true Thymeで文字列に対して行うことがある演算はこの3つしかないと思われる 大なり小なりの比較演算なども行えるが、行うことはないであろう 尚、加算以外の算術演算子は全てエラーとなる ブール限定の演算 細かい話は抜きにして「ブール型にのみ用いられる演算でありその結果もすべてブール型である」と覚えておけば良い。 true=真 か false=偽 を判断する際に用いる。 以下の表が、その演算内容のすべてである。 論理演算子 演算子 意味 例文 演算結果 論理積(and) true true true true false false false true false false false false || 論理和(or) true || true true true || false true false || true true false||false false ! 否定(not) !true false !false true wikiの書式上の問題で論理和の演算子を全角文字で表記している。実際には半角(||)である。 論理積(and)は「両辺共にtrueならばtrue、それ以外はfalse」 論理和(or)は「両辺どちらかがtrueならばtrue、共にfalseの場合のみfalse」 否定(not)は値を一つしか対象とせず「真偽値を逆転させる」 配列に対する演算 演算が要素ごとに行われるもの 演算子 意味 例文 演算結果 + 加算 [1,2,3] + [1,3,5] [2,5,8] - 減算 [4,5,6] - [1,2,3] [3,3,3] * 乗算 [1,2,3] * [2,3,4] [2,6,12] / 除算 [12,12,12] / [2,3,4] [6,4,3] 論理積 [true,true,false] [true,false,true] [true,false,false] || 論理和 [true,true,false]||[true,false,false] [true,true,false] 演算子の左辺の0番目と右辺の0番目、同様に1番と1番というように、それぞれの要素同士で演算が行われる。 演算子の両辺が同じ要素数でなければエラーとなり、演算は行われない。 演算は配列全体で行われるもの 演算子 意味 例文 演算結果 * 乗算 2 * [1,2,3] [2,4,6] * [2,3,4] * 2 [4,6,8] / 除算 2 / [1,2,3] (error) / [2,4,8] / 2 [1,2,3] == 等しい [1,2,3] == [1,2,3] true != 等しくない [1,2,3] != [1,2,3] false ++ 結合 [1,2,3] ++ [4,5,6] [1,2,3,4,5,6] 乗算については、前後関係に問わず演算可能である。 除算は、割られる数が配列で割る数が整数もしくは浮動小数点ならば演算が可能である。 等しいか等しくないかの判断は全体で行われる。ひとつでも要素の内容が違っていれば不等号扱いである。 結合演算子は両辺の要素全てを左辺→右辺の順に持つひとつの配列を結果とする。 §その他、覚えておくべきこと 使用できる変数について スクリプト内で使用できる変数は「そのスクリプトがどこに書かれているものか」によって変わる。 それらを3つに分類し、それぞれについて使用可能な変数をまとめたものが以下。 F11キーで現れるコンソール画面に書き込んだ場合 スクリプト言語Thymeのページに記載のある「App.~Sim.」までの全て 実際に使用する際には「FileInfo.author」や「math.pi」といった表記で用いる 表の「変数型」の部分については英語表記なので以下の表を参照 表記 意味 decimal 十進数 integer 整数 value 値 positive 正の(0より大きい) true or false 真か偽 function 関数(※後述参照) array of 配列である string 文字列 constant 定数 sub-group 内部に変数や関数を持つグループ名 Read only 読み取りのみ可能(値を変更不可) ※説明文部分については、各自で翻訳してくださいな。 ※使用頻度の高そうなものについては、応用編にて紹介と解説を行うので、そちらを参照してください 物質のスクリプトメニューに書き込んだ場合(onCollide以外) 上記コンソール画面で使用できる変数全てを使用可能 その物質自身のスクリプトメニュー内の全ての項目をそのまま変数として使用可能。 表記は項目名をそのまま「density」や「text」と、項目名自体が変数名となる。 物質のスクリプトメニュー内onCollide部分に書き込んだ場合 上記の全ての変数を使用可能 それに加えて、衝突した相手の変数を使用可能 表記は「e.other.text」や「e.other.color」など、項目名の前に「e.other.」を付け足したものである。 ※スクリプト言語Thymeページの「衝突した相手の物質のタイプを得る」と「e.normalの解説」に興味深い話が載っている 今は理解できないという方でも、講座を最後まで理解したあとで読んでみるべし 実用的なお話へ §条件分岐構造と三項演算子 これ抜きには複雑なThymeスクリプトなど組めない、と言っても過言ではない。 条件分岐構造 ある変数Aがあり、Aが1ならば処理1を実行し、Aが2なら処理2を実行する。端的に言うとそういうことである。 何はともあれ実例を見ていただきたい scene.my.x = 2; scene.my.y = ( scene.my.x == 3 )?( scene.my.x + 3 ) ( scene.my.x + 10 ); 1行目は特に解説の必要はないと思われる。 2行目はscene.my.y変数を作成しているのだが、その中身に条件分岐を用いている。 2行目の「 =」以降の部分が条件分岐構造になっており 「 『scene.my.x==3』が真ならば『scene.my.x + 3』、そうでなければ『scene.my.x + 10』 」という意味である。 この場合 scene.my.x は 2 なので、『scene.my.x + 10』が選ばれ、scene.my.yの値は12となる。 三項演算子 先ほどの例で条件分岐のために用いた演算子を「三項演算子」と言う。 使用方法は以下のとおりである。 判定条件 ? 条件が真の場合の処理内容 条件が偽の場合の処理内容 判定条件の部分は関係演算、もしくは論理演算などを用いてブール型の値でなければならない。 処理内容部分は1文であるならば;は省略可能。 処理内容が複数行ある場合は、それらを{}で囲む必要がある。 (scene.my.x == 2) ? scene.my.y = 5; scene.my.z = 3; scene.my.y = 1; scene.my.z = 10; ; (×エラー) (scene.my.x == 2) ?{ scene.my.y = 5; scene.my.z = 3 } { scene.my.y = 1; scene.my.z = 10 }; (○正常動作) 条件部分で複雑な式を書き、細かな条件判定をすることも可能。 onCollide = (e) = { e.this.density = (( e.other.collideSet == 2 ) ( e.other.density == 100.0 ))?{ 50.0 } { 2.0 }; } 条件分岐部分は「『衝突相手の衝突判定がBのみであり、かつ密度が100.0』ならば 50.0 、違うならば 2.0 」という意味である。 それを e.this.density つまりは自分自身の密度へ書き込んでいる。 まとめると「衝突相手の衝突判定がBであり密度が100.0ならば、自分自身が密度50.0になり、違うならば2.0になる」 という動作をするスクリプトである。 §関数 関数とは何か さて、だいぶ小難しい話になるところなので、腰を落ち着けてじっくりと読んでいただきたい。 「関数」といきなり言っても通じないであろうから、まずPhun抜きにして以下の事例をごらんいただこう。 あなたは書類の整理をしていて、一人の友達に手伝ってもらうことになった。 あなたは友達に2種類の仕事を頼みたい。そのどちらも、かなりの回数あり、順不同に頼みたい。 2種類の仕事をA、Bと呼び名をつける。 そしてAのときはこういう物を渡すから、こう処理して欲しい。Bのときはこう。とそれぞれ内容を定め教える。 それ以降はあなたは友達に「Aだよ、はいこれ」と名称と共に物を渡すだけ。 ひとつの仕事が終わるたび友達はあなたに「できたよ、はいどうぞ」と完成書類を返してくれる。 実に効率的でよろしい話である。 実は上記の話でA、Bと名づけたものこそが「関数」なのだ。 つまり「あらかじめ手順と渡すものを決めておくことで、規定された処理を行ってくれるもの」なのである。 関数を実際に見る前に「引数」と「戻り値」というものについて、上記の話にからめて知っていただこう。 「引数(ひきすう)」とは「Aを頼む際には大きな書類2枚と小さな書類1枚を渡すよ」といった場合の、その書類である。 関数を実行する際には「0個以上の引数」が必要である。これは関数を作成する際に取り決める。 「戻り値(もどりち)」とは「仕事が終わったら、その完成品を渡してね」といった場合の、その完成品である。 関数は「必ず1つの戻り値」を持つ。 作成と使用 それでは、実際に関数を作成し、使用する例を見てみよう Scene.my.func1 = (var) = { var % 2 == 0 ? true false }; Scene.my.x = Scene.my.func1(2); 1行目で関数を製作し、2行目で使用している。 関数の内容としては「引数が偶数ならばtrue、奇数ならfalseを戻り値とする」である。 つまりは偶数か奇数かを判定するための関数だ。 関数の書式は以下のとおりである 関数名 = ( 引数名 ) = { 処理内容 } 関数名はもちろん「Scene.my.」をつけることを忘れてはならない 引数は「0個以上」と定められているので、引数が必要ない関数ならば何も表記しなくてよい。 引数は2つ以上でも構わなく、その場合は「,」で区切って宣言する。 処理内容も2行以上でも構わない。その際はきっちり1行ごとに「;」で区切ること。 尚、関数の作成を行う際にはF11キーで現れるコンソール画面から作成する必要がある。 ちなみに、たとえその関数がonCollide内に書かれていても「e.other.○○」や「e.this.○○」などの変数は使用できない。 関数内で使用したい値については基本的に引数で渡してやらねばならない。 ただし、Phun自体が持っている変数については使用することが出来る。(「Sim.○○」や「App.○○」など) 以下にいくつかの関数の作成例を示す 三角形の高さと幅を引数として渡すと、その面積を求める関数 (引数が2つある関数) ◇関数 scene.my.triangle = ( width , height ) = { width * height * 0.5 }; ◇使用例 scene.my.x = scene.my.triangle( 3.0 , 5.0 ); scene.my.x には 3.0 * 5.0 * 0.5 の演算結果 7.5 が入る。 シミュレーション経過時間0.5秒ごとに戻り値がtrueとfalseで入れ替わる関数 (引数を持たない関数) ◇関数 scene.my.blink = () = { sim.time % 1.0 = 0.5 ? true false }; ◇使用例 onCollide = (e) = { text = { "" + ( scene.my.blink ? "Yes" "No" ) }; } 書かれた物質のtext属性値が0.5秒ごとに "Yes" と "No" 交互に変わる。 用意されている関数 あらかじめPhunのシステム上に作成されていて、使用可能な関数はいくつもある。 かなりの量であるが、実際に使用する可能性のあるものは限られる。 使用頻度の高い関数をいくつか書き留めておこう。 数学関数 関数名 引数 戻り値 math.asin(x) 浮動小数点型 逆三角関数 arcsin(x)の値 math.acos(x) 浮動小数点型 逆三角関数 arccos(x)の値 math.atan(x) 浮動小数点型 逆三角関数 arctan(x)の値 math.sin(x) 浮動小数点型、単位は[rad] 三角関数 sin(x)の値 math.cos(x) 浮動小数点型、単位は[rad] 三角関数 cos(x)の値 math.tan(x) 浮動小数点型、単位は[rad] 三角関数 tan(x)の値 Scene属関数(主に物質の生成) 関数名 引数 戻り値 scene.addBox{ x } (後述) "box" scene.addCircle{ x } (後述) "circle" scene.addFixjoint{ x } (後述) "fixjoint" scene.addHinge{ x } (後述) "hinge" scene.addPen{ x } (後述) "pen" scene.addPlane{ x } (後述) "plane" scene.addPolygon{ x } (後述) "polygon" scene.addSpring{ x } (後述) "spring" scene.addWater{ x } (後述) "water" scene.EraseWater (なし) (なし) add****{}タイプの関数の引数については、phn形状についてを参照にしてほしい。 というだけも味気ないので、2つの例を以下に挙げておく 位置[10.0,25.5]に、幅15.0 高さ20.0 密度10.0のboxを追加するスクリプト scene.addBox{ pos = [ 10.0 , 25.5 ]; size = [ 15.0 , 20.0 ]; density = 10.0 }; 横長の長方形に、二つの丸をヒンジで接続するスクリプト scene.addBox{ pos = [ 0.0 , 0.0 ]; size = [ 6.0 , 2.0 ]; geomID = 100; }; scene.addCircle{ pos = [ 2.0 , -0.5 ]; radius = 0.8; geomID = 101 }; scene.addCircle{ pos = [-2.0 , -0.5 ]; radius = 0.8; geomID = 102 }; scene.addHinge{ geom0 = 100; geom0pos = [ 2.0 , -0.5 ]; geom1 = 101; geom1pos = [ 0.0 , 0.0 ] }; scene.addHinge{ geom0 = 100; geom0pos = [-2.0 , -0.5 ]; geom1 = 102; geom1pos = [ 0.0 , 0.0 ] }; ※追記 Thymeで物体を発生させる場合、速度と角速度も指定できる。両方共に「じょうほう」メニューで表示されている単位(速度 m/s, 角速度 rad/s)で指定する。 x速度20m/s、y速度10m/s、角速度30rad/sの円を発生させるスクリプト scene.addBox({vel = [20.0, 10.0]; angVel = 30}); §配列の応用 配列の解説部分で作った配列のような1列しかない配列は、1次元配列と言う。 1次元という呼び名があるからには、2次元配列ももちろん存在する。 作成の仕方と使用の仕方を以下に示す。 scene.my.x = [ [1,2,3] , [4,5,6] ]; これが2行3列の2次元配列である。 配列の0番目の値として「要素3の配列」が入っており、1番目の値にも「要素3の配列」が入っている。 これを使用する際には以下のように書く scene.my.y = scene.my.x(0)(1); scene.my.xの0行目の1番目を指定している。この時scene.my.yに入る値は「2」である。 scene.my.xの内容を視覚的にわかりやすく表にまとめると、以下のようになる。 scene.my.x(A)(B) \ B=0 B=1 B=2 A=0 1 2 3 A=1 4 5 6 ちなみに、2次元配列を作る際に、列の値は必ずしも全て揃える必要はない。 更に、データ型はそれぞれの要素ごとに記録されるため、揃える必要はない。(これは1次元配列でも同じく) つまり、以下のような配列も生成可能である。 scene.my.x = [ [ 11 , 12 , 13 ],[ "welcome" , 2 , "phun"],[ 21 , 22 , 23 , 24 , 25 ] ]; scene.my.y = [ [ "one" , 2 , "three" ],"welcome",[ true , "or" , false ],[ "Let s" , "phun" ] ]; それぞれ内容は以下のようになる。 scene.my.x(A)(B) \ B=0 B=1 B=2 B=3 B=4 A=0 11 12 13 (error) (error) A=1 "welcome" 2 "phun" (error) (error) A=2 21 22 23 24 25 scene.my.y(A)(B) \ B=0 B=1 B=2 A=0 "one" 2 "three" A=1 (error) (error) (error) A=2 true "or" false A=3 "Let s" "phun" error scene.my.x(1)(4) や scene.my.y(3)(2) など、表記が(error)のものは使用することが出来ない。 scene.my.y の A=1の場合は、そこだけ1次元配列のままなので、"welcome" を参照したければ「scene.my.y(1)」と表記する。 大きな間違いの訂正とお詫び 講座の書き出し時点で「ThymeスクリプトをonCollide属性以外にも書き込み可能だ」と書きましたが間違いであることが分かりました。 書いたそのときは動きはすれど、Phunを終了させたりファイルに保存する際に、onCollide以外の属性に書いたスクリプトは保存されない ことが多いという事実が判明しました。 紛らわしい文章を載せてしまい、まことに申し訳ありませんでした。(現在は訂正済み) 2010/08/23 08 08 作成主 コメント欄 誤記?:×「scene.my.x の2番目の内容を99に書き換える」○「scene.my.x の3番目の内容を99に書き換える」 - 扇翁 2010-08-22 08 19 53 誤記ではありません。配列の要素を「0番、1番、2番・・・」と数える数え方に慣れてもらう意図もこめて、表記はそう統一してあります。 - 作成主 2010-08-22 12 59 20 うーん、0番(#0)はいいとして「0番目」(0st?)はしっくりこないなぁ「目」をつけない表記に統一したほうが良いかも…つまり「scene.my.x の2番の内容を…」でどう? - 扇翁 2010-08-22 14 59 02 配列の乗算の追記ありがとうございます。配列の0起点に由来する説明の難しさは厄介な問題ですね; - 名無しさん 2010-08-22 15 27 32 扇翁さんの指摘に、確かにと納得しました。そう言われると「n番」と「n番目」でのニュアンスの違いが気になりますね・・・。「n番目」→「n番」に書き換えておきました。 - 作成主 2010-08-23 08 06 45 onCollide以外にThyme書くのはVaDWingなどには必要なんだが、再生時にonCollideで展開する必要あり。 - igaguri 2010-08-24 14 43 00 保存されないのであれば、直接.phnに書き込んだらいいのでは? - 名無しさん 2010-09-21 04 20 23 名前
https://w.atwiki.jp/p-phun/pages/68.html
Thyme例文集 1.簡易なものたち シミュレーション経過時間をリアルタイムで表示する シミュレーション経過時間をリアルタイムに表示する-2 衝突相手を判断して処理を変更する 衝突相手を判断して処理を変更する-2 2.関数例 シミュレーション経過時間を時分秒表記であらわす 3.複雑なものたち PJsystemさんの発明したアレに似たもの 4.拡張的な技術 コメント欄 Thyme例文集 Thyme講座を読み終わり、これからThymeをさまざまなものに応用していこうとする方のために、いくつかの例文を紹介しておく。 1.簡易なものたち シミュレーション経過時間をリアルタイムで表示する onCollide = (e) = { text = { "" + sim.time }; } boxにこのスクリプトを書き込めば、text部分にシミュレーション経過時間をリアルタイムで表示できる。 シミュレーション経過時間をリアルタイムに表示する-2 onCollide = (e) = { text = { "" + (sim.time - sim.time % 1) }; } こちらの場合は、表示されるのが「小数点以下を省いた秒数」となる。 ( sim.time - sime.time % 1 )の部分が「小数点以下を省いた秒数」である。 衝突相手を判断して処理を変更する onCollide = (e) = { e.this.color = (e.other + "" == "box" ? [1.0, 0.0, 0.0, 1.0] [0.0, 0.0, 1.0, 1.0]) } 衝突相手がboxならば赤色になり、box以外ならば青色になる。 衝突相手を判断して処理を変更する-2 onCollide = (e) = { e.this.color = e.other.collideSet == 1 ? [1.0, 0.0, 0.0, 1.0] e.this.color ; (※1) e.this.color = e.other.collideSet == 2 ? [0.0, 0.0, 1.0, 1.0] e.this.color ; (※2) e.this.color = e.other.collideSet == 3 ? [1.0, 0.0, 1.0, 1.0] e.this.color ; (※3) } 衝突相手が衝突判定Aのみならば赤色になり、Bのみならば青色になる。(※1、※2) 衝突相手が衝突判定AとB両方を持っているならばピンク色になる。(※3) もちろん、このスクリプトを書く物質はAとB両方に衝突するように設定しなければならない。 (スクリプト案絶賛募集中) 2.関数例 シミュレーション経過時間を時分秒表記であらわす scene.my.extractTime = () = { var = sim.time; hour = ( var = 3600 ? var / 3600.0 0.0 ); hour = ( hour - hour % 1.0); minute = ( var = 60 ? ( var - hour * 3600.0 ) / 60.0 0.0 ); minute = ( minute - minute % 1.0 ); second = ( var - hour * 3600.0 - minute * 60.0 ); second = ( second - second % 1.0 ); "" + hour + "h " + minute + "m " + second + "s"; } 小数点を含む秒数のみのsim.timeから、時間と分を切り出し、残ったものを秒とする関数だ。 戻り値は「"1h 32m 15s"」のような表記になる。 3.複雑なものたち PJsystemさんの発明したアレに似たもの onCollide = (e) = { collideSet = {sim.time * 13.0 % 1 = 0.5 ? 1 2} (※1) e.this.text = e.other.collideSet == 1 ? e.other.text e.this.text ; (※2) e.other.text = e.other.collideSet == 2 ? e.this.text e.other.text ; (※3) } 衝突判定を「A→B→Aと変更する」を1ループとし、毎秒13回それを行っている。(※1) 「sim.time % 1」という処理を行うことで秒数の小数点以下のみを導出している。 判定条件を分かりやすく言うと「秒の小数点以下が(.0~.4999…)ならばfalse、(.5~.999…)ならばtrue」である。 つまり1秒の間に「trueの場合の処理」と「falseの場合の処理」を交互に行うことになる。 「sim.time * 13」を言い換えると「13倍早く進む時間」を表現している。 13倍進む時間を元に「毎秒trueとfalseの処理を交互に行う」処理を行っていることになる。 つまり「A→B→A」の切り替えは 1/13秒ごとに行われる。 相手がA判定ならば、自分自身のtextに相手のtextを読み込む。A判定でなければ現状を維持する。(※2) つまり、自分自身のtextが変更される条件は「相手がA判定」の時だけとなる。 相手がB判定ならば、相手のtextに自分のtextを書き込む。B判定でないのならば現状を維持する。(※3) つまり、相手のtextが変更される条件は「相手がB判定」の時だけとなる。 これを利用する際には「A判定の四角」と「B判定の四角」に挟まれた「このスクリプトを書き込んだ四角」を用意する。 A判定B判定の二つの四角はフィクスで、スクリプトを書き込んだ四角はヒンジで、共に背景に接着しておく。 実際に動かすとtext属性に書かれた値が「A判定の四角」→「スクリプトを書いた四角」→「B判定の四角」と伝達していく。 あたかも電気信号により情報が伝達したかのような振る舞いをするのである。 参考動画【Phun】あのエンジンをさらに応用してみた 4.拡張的な技術 コメント欄 "" + (time - time % 1) - 384 2010-08-23 11 09 47 失敗しました・・・。「{"" + (time - time % 1)}」とtext欄に書き込めば、時間を一秒間隔で表示できます。どうでしょうか? - 384 2010-08-23 11 11 48 発案ありがとうございます384さん、追記しておきました。 - 作成主 2010-08-26 07 34 38 onCollide=(e)= { e.this.controllerAcc = e.pos(0) - App.mousePos(0) ; text = {"" + e.this.controllerAcc } } - WING7 2012-01-08 23 02 07 マウスのX軸と自分の距離が測れます。 - WING7 2012-01-08 23 02 59 名前
https://w.atwiki.jp/jpops/pages/9799.html
THYMEをお気に入りに追加 THYMEのリンク #bf Amazon.co.jp ウィジェット THYMEの報道 松本潤・Bright&Win『TVガイド』表紙・裏表紙を日・タイ“F4”が飾る(オリコン) - Yahoo!ニュース - Yahoo!ニュース タイ版ドラマ「花より男子」が本国と同時にオンエア、撮影の舞台裏収めた番組も放送(映画ナタリー) - Yahoo!ニュース - Yahoo!ニュース タイ版「花より男子」今秋日本上陸!CSテレ朝チャンネル1で最速独占放送(シネマトゥデイ) - Yahoo!ニュース - Yahoo!ニュース THYME CAFE & DINER (タイム カフェ&ダイナー) | 【伊賀タウン情報 YOU】 - YOU THYME、映画『魔法遣いに大切なこと』主題歌をリリース - BARKS 【THYME】 - okmusic UP s THYMEとは THYMEの66%はカルシウムで出来ています。THYMEの26%はやさしさで出来ています。THYMEの3%は蛇の抜け殻で出来ています。THYMEの2%は微妙さで出来ています。THYMEの2%は犠牲で出来ています。THYMEの1%は純金で出来ています。 THYME@ウィキペディア THYME Amazon.co.jp ウィジェット 掲示板 名前(HN) カキコミ すべてのコメントを見る ページ先頭へ THYME このページについて このページはTHYMEのインターネット上の情報を集めたリンク集のようなものです。ブックマークしておけば、日々更新されるTHYMEに関連する最新情報にアクセスすることができます。 情報収集はプログラムで行っているため、名前が同じであるが異なるカテゴリーの情報が掲載される場合があります。ご了承ください。 リンク先の内容を保証するものではありません。ご自身の責任でクリックしてください。
https://w.atwiki.jp/p-phun/pages/70.html
Thyme実例集衝突時に自分自身を消去する 衝突で透明な円が発生し、その中心にペンをつけるスクリプト 衝突すると自分を衝突判定Bにする 衝突すると相手を衝突判定B+NSCにする ぶつけた相手の空気抵抗100 衝突した相手を水に変える 大きさを指定して四角を発生させる 配列の1要素のみを書き換える 触った相手のイモータル設定を解除する 2つのオブジェクトを出す 衝突すると引力が200になる F2キーを押すたびに Scene.my.x に1を加算 キー入力で物体の空気抵抗を変える 衝突するごとにimmortal属性を切り替える 3度傾いたBoxを出す ズームをキーで操作する方法 ズームイン/ズームアウトするときに画面の中央が徐々にマウスカーソルの位置に近づく wキーでカメラを右に10m動かす ; Thyme実例集 【Physical】PhunスレPart7【Sandbox】のスレッドより、質問で出たThymeのスクリプト集です。 衝突時に自分自身を消去する e.this.airFrictionMult = NaN; あるいは density=1e-12; 衝突で透明な円が発生し、その中心にペンをつけるスクリプト Scene.addCircle{ radius =0.1; collideSet =2; color =[0.05 , 0.05 , 0.05 , 0.0]; pos =e.pos; }; Scene.addPen{ size =0.15; color =[0.05,0.05,0.05,1.0]; pos =e.pos; } 円を追加「半径0.1、衝突判定B、色は透明、発生位置は衝突位置」 ペンを追加「半径0.75、黒っぽい色、発生位置は衝突位置」 と記述してある。 適時パラメータを調節して使えばOK 円の発生位置とペンの発生位置を揃えておくと、ぴったり真ん中にくっつく ただし、発生直後の円の挙動を乱すとズレたりちゃんとくっつかない ペンを円の半径に対して大きくしすぎると背景や後ろにある物体についちゃう 衝突すると自分を衝突判定Bにする e.this.collideSet = 2; 衝突すると相手を衝突判定B+NSCにする e.other.collideSet = 2; heteroCollide=true; ぶつけた相手の空気抵抗100 e.other.airfrctionMult = 100; 衝突した相手を水に変える e.other.liquify; 大きさを指定して四角を発生させる Scene.addBox({Size = [1, 1]; collideSet = 64; restitution = 1; density = 100; pos = e.pos}); この例では、大きさ1m×1m、衝突判定G、反発の度合い1、密度100の四角が、衝突地点に発生する。 配列の1要素のみを書き換える 例えば、4つの要素を持つ配列hogeの3番目の要素を0にしたい場合、 hoge(2) = 0; とはできないので、 hoge = [hoge(0), hoge(1), 0, hoge(3)]; とするしかない。 触った相手のイモータル設定を解除する e.other.immortal = false; 2つのオブジェクトを出す Scene.addBox{Size = [1, 1]}; Scene.addBox{Size = [2, 2]}; 衝突すると引力が200になる e.this.attracion=200; F2キーを押すたびに Scene.my.x に1を加算 F11(AlgodooではF10)でコンソール開いて、下記を入力。 Scene.my.x = 0 Keys.bind( "f2", { Scene.my.x = Scene.my.x + 1 } ) キー入力で物体の空気抵抗を変える F11(AlgodooではF10)でコンソール開いて、下記を入力。 Keys.bind("1", {Scene.my.x = 100}) Keys.bind("2", {Scene.my.x = 1}) そして、物体のスクリプトメニューを開いてAirFrictionMultのところに {Scene.my.x} と書いておく。 衝突するごとにimmortal属性を切り替える e.this.immortal = ! e.this.immortal; 三項演算子を使った別解。 controllerAcc==1 ?{ controllerAcc=0;immortal=false } { controllerAcc=1;immortal=true } 3度傾いたBoxを出す Scene.addBox{angle = math.pi / 180 * 3}; つまり、angleは弧度法(ラジアン)で指定する。 ズームをキーで操作する方法 以下2行を背景の空の部分にコピペ Keys.bind("shift i",{Scene.Camera.zoom = Scene.Camera.zoom * 2 ^ 0.5}); Keys.bind("shift o",{Scene.Camera.zoom = Scene.Camera.zoom / 2 ^ 0.5}); [Shift]+[I] でズーム [Shift]+[O] でズームアウト ("shift o"の部分を"o"にすると、[Shift]キーを押さなくても良い反面、[Ctrl]+[O]を押した時にもズームアウトしてしまう。) ズームイン/ズームアウトするときに画面の中央が徐々にマウスカーソルの位置に近づく Keys.bind("shift i",{Scene.Camera.zoom = Scene.Camera.zoom * 2 ^ 0.5; Scene.Camera.pan = (Scene.Camera.pan + App.mousePos) / 2; }); Keys.bind("shift o",{Scene.Camera.zoom = Scene.Camera.zoom / 2 ^ 0.5; Scene.Camera.pan = (Scene.Camera.pan + App.mousePos) / 2; }); wキーでカメラを右に10m動かす Keys.bind("w",{Scene.Camera.pan=Scene.Camera.pan+[10,0]});
https://w.atwiki.jp/hmiku/pages/56358.html
【検索用 Thymekarte 登録タグ 2012年 T UTAU ユネコP 上原三 曲 曲英 朱雀P】 + 目次 目次 曲紹介 歌詞 コメント 作詞:朱雀P 作曲:朱雀P・ユネコP 編曲:朱雀P 唄:上原三 曲紹介 曲名:『Thyme karte』 歌詞 ここに居ない君に 会える時は何時だ 頼りになるものは 俺の記憶だけで 永い時を巡り 探している君を ※時を越えて 翼広げ空へ あの扉を開く 貰いウケた ファイル 照らし合わし探す 永い時をかけて 辿り着いた扉 ※そこに見つけた 人気の無い廊下 君にむかい歩く コメント 名前 コメント コメントを書き込む際の注意 コメント欄は匿名で使用できる性質上、荒れやすいので、 以下の条件に該当するようなコメントは削除されることがあります。 コメントする際は、絶対に目を通してください。 暴力的、または卑猥な表現・差別用語(Wiki利用者に著しく不快感を与えるような表現) 特定の個人・団体の宣伝または批判 (曲紹介ページにおいて)歌詞の独自解釈を展開するコメント、いわゆる“解釈コメ” 長すぎるコメント 『歌ってみた』系動画や、歌い手に関する話題 「カラオケで歌えた」「学校で流れた」などの曲に直接関係しない、本来日記に書くようなコメント カラオケ化、カラオケ配信等の話題 同一人物によると判断される連続・大量コメント Wikiの保守管理は有志によって行われています。 Wikiを気持ちよく利用するためにも、上記の注意事項は守って頂くようにお願いします。
https://w.atwiki.jp/yurina0106/pages/4616.html
タグ 明るい 曲名T 歌 KOTOKO 作詞 KOTOKO 作曲 羽鳥風画 作品 シュクレ~sweet and charming time for you~OP シュクレ コンプリートサウンドトラック~Secret tea party~
https://w.atwiki.jp/p-phun/pages/67.html
追記&修正「演算子」 執筆「条件分岐構造と三項演算子」「関数(途中まで)」 - 作成主 2010-08-20 08 11 50 とりあえず最後まで一通り執筆完了。 間違いや気になる点、分かりにくい点があったらコメントお願いしま - 作成主 2010-08-21 06 37 18 配列(リスト)には要素ごとに書き込めない旨どこかに書いてましたっけ?例:×e.this.color(1)=0; ○e.this.color=[e.this.color(0),0,e.this.color(2),e.this.color(3)]; - 扇翁 2010-08-21 11 52 08 ご指摘ありがとうございます扇翁さん。追記しておきました。 - 作成主 2010-08-21 12 32 46 わかりやすくまとめられていて助かります。 3*[1,2,3] といった演算も可能なようです。 結果は[3,6,9] - 名無しさん 2010-08-21 13 06 41 ご指摘ありがとうございます名無しさん。追記しておきました。 - 作成主 2010-08-21 13 57 04 誤記?:×「scene.my.x の2番目の内容を99に書き換える」○「scene.my.x の3番目の内容を99に書き換える」 - 扇翁 2010-08-22 08 19 53 誤記ではありません。配列の要素を「0番、1番、2番・・・」と数える数え方に慣れてもらう意図もこめて、表記はそう統一してあります。 - 作成主 2010-08-22 12 59 20 うーん、0番(#0)はいいとして「0番目」(0st?)はしっくりこないなぁ「目」をつけない表記に統一したほうが良いかも…つまり「scene.my.x の2番の内容を…」でどう? - 扇翁 2010-08-22 14 59 02 配列の乗算の追記ありがとうございます。配列の0起点に由来する説明の難しさは厄介な問題ですね; - 名無しさん 2010-08-22 15 27 32 扇翁さんの指摘に、確かにと納得しました。そう言われると「n番」と「n番目」でのニュアンスの違いが気になりますね・・・。「n番目」→「n番」に書き換えておきました。 - 作成主 2010-08-23 08 06 45 onCollide以外にThyme書くのはVaDWingなどには必要なんだが、再生時にonCollideで展開する必要あり。 - igaguri 2010-08-24 14 43 00 保存されないのであれば、直接.phnに書き込んだらいいのでは? - 名無しさん 2010-09-21 04 20 23
https://w.atwiki.jp/p-phun/pages/60.html
Thymeは、Phun内部につくられたスクリプト言語です。Emil氏により開発され、重力の大きさなどの値を変更するのに使用されます。 このスクリプトは、[F11]を押して現れるコンソール画面で入力するか、.phnファイル内に埋め込むか、背景にペーストすることで効力を発揮します。なお、[F11]を押して現れるコンソール画面上では、Tabを入力することで自動補完されます。 変数は何に使用されるかによってグループ分けされています。 グループ APP. Console. FileInfo.(new since Beta 4) GUI.(not the same as App.GUI.) Keys. math. Resources. SPH. Scene. (new since Beta 4) Sim. System. App. App.はレンダリングに関する設定を扱います。 変数のリスト 変数名 変数型 説明 Background. サブグループ App.Background.参照 DPI 正の整数 1インチ当たりのドットの数 (初期値86) GUI. サブグループ App.GUI.参照 HQPolygons true or false Whether to store polygon distance maps in much larger textures or not Redo function Execute a redo step Undo function Execute an undo step alwaysCalcContacts true or false Whether to calculate collisions every frame or not autosaveEnable true or false Whether to autosave every set amount of time or not autosaveTime 正の小数 自動保存をする間隔 (初期値30) borderWidth 正の小数 オブジェクトの境界線の幅 (初期値0.1) borders trueもしくはfalse Sets if borders should be rendered chainDensityFactor 正の小数 The density per circle in a chain divided by two checkForUpdates true or false Whether to check for updates and news each "updateinterval" days or not currentPalette string The colour palette currently used dragToolStrength 正の小数 ドラッグツール(引っ張る)の強さ (初期値0.25) drawBCs trueもしくはfalse オブジェクト(ポリゴン)の衝突半径の表示 (初期false) drawBodyCenters trueもしくはfalse オブジェクト中心の表示 (初期false) drawCables true or false Whether to show cables or not drawCollisions trueもしくはfalse 衝突線の表示 (初期false) drawMapOBBs trueもしくはfalse If the oriented bounding box map should be visible (初期false) drawOBBs trueもしくはfalse If the minimum oriented bounding box (初期false) drawParticleCenters trueもしくはfalse 水粒子中心の表示 (初期false) drawParticleNeighbors true or false If the connection of particles (water) should be drawn as lines drawScaleIndicator true or false Whether to show the scale or not drawSelectionOBB true or false App.drawOBBs for objects selected drawVelocityFactor decimal value The multiplier for velocity lines (shown when BodyCenters are shown) drawVertices trueもしくはfalse ポリゴン頂点の表示 (初期false) enableScriptMenu true or false Whether the script menu for each object is accessible or not fadeColor array of three decimal values 隠し機能のパラメータ fadeRotate 少数 隠し機能のパラメータ(初期値0) fadeScale 二つの少数の配列 隠し機能のパラメータ(初期値[0.94999999,0.94999999]) fadeTranslate 二つの少数の配列 隠し機能のパラメータ(初期値[2,3]) forceVertexPolygonDrawing true or false Whether to force drawing of all verticies(true) or not (false) (this also upgrades collisions) gpuWater true or false Whether to use hardware surface generation (true) or not (false) killerPlanes true or false Whether new scenes should add killerPlanes (true) or not (false) (also affects current scene) language string 使用する言語 laserBroadPhase true or false Whether to enable increased performance of lasers (true) or not (false) laserEvents true or false Whether to enable onHitByLaser and onLaserHit (true) or not (false) laserResolution decimal positive value The quality for finite light speed laserSuperBoost decimal positive value Allows more ray splits laserWaterBVH true or false Whether to increase laser performance against water using bounding volume hierarchies (true) or not (false) laserWidth decimal Laser ray size relative to laser body lineWidth 正の小数 描画時の線の幅 (初期値3) marchingSquaresResolution decimal ??? maxBorderArea decimal The maximum area relative to the geometry that can be taken up by the border maxBorderAreaSpecial decimal The maximum area relative to the geometry that can be taken up by the selection border maxCogs integer The maximum number of cogs avaliable on each gear maxPointDist 正の小数 ポリゴンの頂点の間隔(値が小さいほど高精度) (初期値0.5) maxPolygonBorderFactor decimal The width of a polygons border maxSPHspawn 正の整数 生成される水粒子の最大数 (初期値10000) maxTracerLife positive integer value The number of frames of an individual tracer that are recorded maxUndo 正の整数 やり直しの最大数 (初期値35) metaCutoff decimal positive value Meta-surface generation cutoff 0.5 metaWater true or false Whether meta-surface generation is on (true) or off (false) true minPointDist decimal positive value minimum distance between vertices drawn by draw tool 0.20 mousePos array of two decimal values The position of the mouse numColorsInRainbow positive integer The number of colours each ray splits into 12 pointSize positive decimal value (integer recommended?) size of vertex points(if visible) 4.0 polytoolPreviewColor array of four decimal values The color of the preview area of each polygon [1, 0.5, 1, 0.4] scaleGravityField true or false Whether to scale field arrows with gravity strength(true) or not(false) false sceneFadeInTime decimal How long it takes for a scene to fade in 1 screenshotsWithAlpha true or false Saves scenes with the alpha channel in tact (transparent screenshots) false showGravityField true or false Whether to show the gravity field for attraction(true) or not(false) false updateInterval positive integer The news and update checking interval (days) 1 waterColor array of three decimal values The color of the water [0.1, 0.1, 1.0, 0.7] waterElongation decimal positive value multiplier for stretching of water drops when speed increases 0.050 waterFanceyFactor decimal positive value quality of fancy water rendering 10.0 waterMaxElongation decimal positive value Maximum stretch of fancy water droplets 2.0 waterRefractiveIndex decimal positive value The reflective-ness of water 1.33 waterTracerLightness decimal positive value How bright water tracers are in relation to the colour of the water 0.75 waterTracerSize decimal positive value The size of the water tracers 0.015 waterTracers integer The fraction of a water particle that should have a tracer 0 APP.Background. はPhunの背景の空に関係のある変数のグループです。 変数のリスト 変数名 変数型 説明 cloudOpacity 正の少数 背景の雲の透明度 (初期0.89999998) cuteClouds boolean Whether to use normal (false) or cute (true) clouds drawClouds trueもしくはfalse 雲の表示 (初期true) skyColor 四つの少数 背景の色[赤,緑,青,透] (初期値[0.30000001,0.40000001,1,1]) App.GUI.はGUIに関する設定を扱います。 変数のリスト 変数名 変数型 説明 Forces. sub group App.GUI.Forces.参照 Rebuild function Reload all the GUI. alikeTolerance integer The maximum number of differences to be selected by the "Select alike" command 0 allowDrawSelect boolean Select by encircling on (true) or off (false) true cv_sketchMorphTime float The time before a shape is formed by the sketch tool 0.5 dragUndo boolean Whether drag saves an undo step (true) or not (false) true drawDragLine boolean Whether to show the line from the point of dragging to the mouse (true) or not (false) true drawHingesWhenRunning boolean Whether to show hinges when running (true) or not (false) true geomGenMinArea float Not sure what this does 0.0009 geomGenShrink float Not sure what this does either -0.0033 geomGenTolerance float Not sure what this does either 1.2 level integer The level of interface 1 (Simple), 2 (Medium) or 3 (Advanced) 1 toolGestureSensitivity float How sensitive cancel gestures are 1 toolGestures boolean Whether to cancel a tool by shaking the mouse (true) or not (false) true toolSpecificCursors boolean Whether to show a different cursor for each tool (true) or not (false) true trapUser boolean Whether the user is able to quit, open ingame links and toggle fullscreen (false) or not (true) false useHSL boolean Use the old colour system (Hue Saturation Lightness)(true) as opposed to HSV (Hue Saturation Value)(false) false zoomFactor float How fast a user zooms in and out 0.2 App.GUI.Forces.は~に関する設定を扱います。 変数のリスト 変数名 変数型 説明 airBuoyancy boolean Whether to show the visualisation for airBuoyancy (true) or not (false) true airBuoyancyText string The text to show accompanying the airBuoyancy visualisation -adg airFriction boolean Whether to show the visualisation for airFriction (true) or not (false) ture airFrictionText string The text to show accompanying the airFriction visualisation -fv attraction boolean Whether to show the visualisation for attraction (true) or not (false) true attractionText string The text to show accompanying the attraction attraction visualisation A contactCombinationDistance float The distance in screen centimetres(cm) distance before normal visualisation arrows join into one 1.2 drawForces boolean Whether to show all force visualisations (true) or not (false) false drawNames boolean Whether to show all force names (true) or not (false) true drawValues boolean Whether to show all force values (true) or not (false) false external boolean Whether to show the visualisation for external forces (true) or not (false) true externalText string The text to show accompanying the external forces visualisation ext forceScale float The scale of the arrow visualisation of foce visualisation 1 friction boolean Whether to show the visualisation for friction (true) or not (false) true frictionProjection boolean Whether to show friction from both directions (false) or the direction the force pushes(true) true frictionText string The text to show accompanying the friction visualisation T gravity boolean Whether to show the visualisation for gravity (true) or not (false) true gravityText string The text to show accompanying the gravity visualisation mg hinge boolean Whether to show the visualisation for the for the force of hinges (true) or not (false) true hingeText string The text to show accompanying the hinge visualisation H normal boolean Whether to show the visualisation for normal forces (true) or not (false) true normalText string The text to show accompanying the normal forces visualisation N spring boolean Whether to show the visualisation for spring forces (true) or not (false) true springText string The text to show accompanying the spring forces visualisation -kx-bv total boolean Whether to show the visualisation for the total force (true) or not (false) true totalText string The text to show accompanying the total force visualisation velScale float The scale of the velocity visualisation 1 velocities boolean Whether to show the visualisation for velocities (true) or not (false) false Console. コンソール関連の変数群です。 変数のリスト 変数名 変数型 説明 clear function Clears the console window color four positive decimal values The RGBA color code for the console window delay positive decimal value The amount of seconds it takes before the console appears fade true or false If the console window should fade in transparency lengthwise screenSize positive decimal value How much of the screen should be covered by the console. 0.0 = 0%, 1 = 100% scroll true or false If the console window should scroll in view, or fade in view when opened FileInfo. FileInfo.(ファイル情報)はファイルの作者名・タイトル・説明 を扱います。 変数のリスト 変数名 変数型 説明 author string Defines the author of a file description string Gives a description of the file title string The title of the file version string Version of thyme used to make the file GUI. 操作画面に関連するものです。表示に使用するフォントやウィンドウのサイズ等を扱います。 変数のリスト 変数名 変数型 説明 clickTimeTolerance positive decimal value how long time in seconds before a click is no longer a click clcikTolerance positive decimal value how far in pixels the mouse may move before a click is not longer a click crispFontFactor positive decimal value amount of crispiness on the fonts.. Don t touch, default is good enough crispFonts true or false Whether or not to use crisp fonts font string what font to use. Only fixedsys and arial_black are supported as of now fontShadow true or false whether or not to render shadows of text fontShadowOffset array of two decimal values XY offset of shadow forceOSCursor true or false force operating system cursor or use the phun cursors opaqueness positive decimal value transparency of user interface scale positive decimal value scale of user interface Keys. Keysはキーをバインドすることにのみ使用します。 この関数を使うことで、あるキーが押下されたとき実行するコードを記述出来ます。 Keys.bind("space", {Sim.running = ! Sim.running}); math. Mathに変数はなく、数学的な定数と関数を提供します。 変数のリスト: 変数名 変数型 説明 acos(x) function, x = decimal returns the inverse cosine of the number entered add(x,y) function, x y = decimal adds two numbers together asin(x) function, x = decimal returns the inverse sine of the number entered atan(x) function, x = decimal returns the inverse tangent of the number entered cos(x) function, x = decimal returns the cosine of the number entered divide(x,y) function, x y = decimal divides x by y multiply(x,y) function, x y = decimal multiplies x by y negate(x) function, x = boolean flips the value of x pi constant gives a value of 3.1415926535.... sin(x) function, x = decimal returns the sine of the number entered subtract(x,y) function, x y = decimal subtracts y from x tan(x) function, x = decimal returns the tangent of the number entered Resources. Resourcesはほとんどのユーザーは無視してかまいません。16bitテクスチャやシェーダなどのリソースへのアクセスを扱います。 変数のリスト 変数名 変数型 説明 force16BitTextures true or false whether or not 16 bit color-mode should be used loadAll function loads all resources into the ram reloadAll function reload all resources reloadShaders function reload only shaders reloadTextures function reload only textures shaders true or false whether or not shaders should be used unloadAll function unload all resources vramUsage read-only decimal positive value how much bytes of video RAM are used by Phun SPH. SPHとはSmoothed Particle Hydrodynamicsのことで、phunにおける流体のシミュレーションに使われています。SPH粒子は流体と、その密度や流れを表現します。粒子の動きは圧力、粘性、また様々な外的な力(重力や界面の状態など)に左右されます。流体は圧力の働きにより体積を一定に保とうとしますが、phunでの処理時間の制約により、現実の水よりはかなり弾力があります。 変数のリスト: 変数名 変数型 説明 SPH.AVG_density decimal positive value average density of the water (related to pressure) SPH.AVG_neighCount decimal positive value average number of neighbouring drops of water SPH.AVG_pressure decimal positive value average pressure exerted on the water SPH.bucketSize decimal positive value use when checking SPH neighbourhood. Changing this value should not affect behavior, but may affect performance. SPH.density decimal positive value the weight of a water droplet. SPH.friction decimal positive value the amount of friction experienced between two water droplets. SPH.hashInfo function gives information about the water. Bucket size, number of particles and average bucket size SPH.influence decimal positive value the influcence radius of an SPH particle. A larger value will give a slower, but maybe more stable, simulation. SPH.jitter decimal positive value adds random movement to the SPH particle. The larger the value, the stronger forces. A value of 0 means no jitter. SPH.pressMultiplier decimal positive value multiplication factor of pressure forces SPH.radius decimal positive value the size of a water droplet. SPH.restitution decimal positive value the amount of bounciness of the water SPH.soundSpeed decimal positive value the update frequency of the water system SPH.specialPressure true or false changes to a different pressure averaging formula SPH.surfaceTension decimal positive value not used SPH.vaporizeTime decimal positive value the time that a water droplet can be idle before it disappears. SPH.viscMultiplier decimal positive value multiplication factor of viscosity forces SPH.viscosity decimal positive value the viscosity of the water Scene. Sceneは主にphunのファイルを操作するのに使い、例えばオブジェクトを追加したり、削除したりすることが出来ます。 変数名 変数型 説明 Camera. sub-group see Scene.Camera. Clear function clears the entire scene of objects and water EraseWater function clears only water New function creates a new scene, and resets all scene variables to default addBox function adds a box addCircle function adds a circle addFixjoint function adds a fixate addGroup function adds a group addHinge function adds a hinge addPen function adds a pen addPlane function adds a plane addPolygon function adds a complex polygon addSpring function adds a spring addWater function adds water addWidget function adds a window author string author of the file description string description of file title string title of file 「addXXX」となっている関数については、phn形式についてもご覧下さい。 Scene.Camera. は Scene. のサブグループで、カメラに関する変数群です。ズームとパンを扱います。 変数名 変数型 説明 pan array of two decimal values XY position of the camera zoom positive decimal value zoom factor of camera Sim. Simはかなり大きな変数グループで、シミュレーションを制御する様々な変数を扱っています。シミュレーションの精度を変更したり、摩擦などに影響を与えたり出来ます。また、一部の力学エンジンを使用するか否かも決められます。これらの変数はphunの内部に影響を与えるので、弄る時は自己責任でお願いします。 変数名 変数型 説明 adHocSolver true or false if true, switches from SPOOK to a different and more basic solver. default is false airDensity positive decimal value density of the air airFrictionLinear positive decimal value linear friction of the air airFrictionQuadratic positive decimal value quadratic friction of the air airSwitch true or false whether air friction is enabled or not defaultBodyDensity positive decimal value default density of objects defaultBodyFriction positive decimal value default friction of objects defaultBodyRestitution positive decimal value default bounciness of objects fallLimit positive decimal value the limit of when an object gets deleted after falling outside of the screen gravity array of two decimal values X and Y force of gravity gravitySwitch true or false whether gravity is enabled or not leapFrog true or false if false, switches to euler integration instead of leap-frog. true by default. maxPositionCorrection positive decimal value sets the maximum penetration used when applying impulses in constraint violations. Set to infinity by default. prioritizedSolver true or false if set to true, will yield a more stable, but far slower, constraint solver. rotFrictionLinear positive decimal value linear rotational friction running true or false whether the simulation is running or not solveAccFactor positive decimal value sets how much the solver will conuter-act acceleration differences between two constrained bodies. Set to 1 by default. Don t touch. solveConstant positive decimal value Affects the SPOOK solver. Don t touch! solveDconstraints positive decimal value The number of time steps the SPOOK solver will aim to satisfy a hinge contraint within. A low number means faster convergence; a high number means more damped and stable simulation. solveDcontacts positive decimal value The number of time steps the SPOOK solver will aim to satisfy c contact within. A low number means faster convergence; a high number means more damped and stable simulation. solveDistFactor positive decimal value sets how much the solver will conuter-act penteration in constraint violation. Set to 1 by default. Don t touch. solveIter positive decimal value the number of constraint solving iterations. A higher number means a more stable simulation. solvePenetrationDamping true or false not used. solvePreSortConstraints true or false sets if the constraints will be ordered by violation amount before solving them. true by default. solveRegularizationFactor positive decimal value Affects the amount of regalurization in the SPOOK solver. Set to 1 by default. solveVelFactor positive decimal value sets how much the solver will conuter-act velocity differences between two constrained bodies. Set to 1 by default. Don t touch. springForce positive decimal value this is the value by which spring strengths are multiplied. Alterning this will change the strength of all springs. targetPenetration positive decimal value sets how much penetration is allowed in a contact time constant positive decimal value number of seconds the simulation has been running timeDelta positive decimal value time between two physics engine solvings timeFactor positive decimal value sets the simulation speed. A value of 1 means realtime. warmStart true or false whether or not to apply forces at sim start warmStartFactor positive decimal value multiplication value of warm-start forces existing at sim start System. Systemはシステムに関する設定です。よほど知識のある方以外は触らないでください。 変数のリスト: 変数名 変数型 説明 antiAlias positive integer value determines the amount of antialias used depth positive integer value color depth exit function shuts down the game fullscreen true or false sets phun to fullscreen and back maxFPS decimal positive value the maximum allowed FPS minFPS decimal positive value the minimum allowed FPS objectCurrent Read only positive integer value don t touch objectHandleCurrent Read only positive integer value don t touch objectTotal Read only positive integer value the total amount of objects recreateWindow function rebuilds the main window resizable true or false if the window can be resized or not resolution array of 2 positive integers the resolution of the window screenshot function makes a screenshot of the window time decimal positive value the amount of seconds the game has been running vSync true or false if vSync is enabled