ƦץȤγSyntax & Style

ߤΤƦץ(SoraMame.ps.js)ϡץProcessing.jsѴƼ¹Ԥޤ

ޥɥեϡˤޤ

ʵǽ

  • Web֥饦ưӥ奢ǥѤΥץߥ󥰸
  • Ф䤹ñʸˡ
  • ֥Ȼظ򥵥ݡ
  • WebGLˤ3Dɽ

ʸμ

ƦץȤǤϡɤ񤯤ʸ򼡤Τ褦ʬषƤޤ

ʲʸϡȤ̰ޤ

ȡˡ򡢤Ρ

Ȥˡ֤ϡפϥǡ˻Ȥޤ

ʸϡѿ̾ؿ̾˻ѤǤޤ

֡(-)ϡ֥ȤΥ᥽åɸƤӽФ˻Ȥޤ

10ɽ

124 , 3.14 , -2.3
  • Ⱦѿ
  • ѿ
  • "."""Ǿʲɽޤ

16ɽ

顼Υǡʤɤ16ɽǵҤǤޤ

#FF00 , #2234
  • Ƭϡ#
  • ͤϡ0-9, a-f, A-F
  • ٤Ⱦ

εϡƦץȤ̤äƤޤ

= + - * / % ^ ( ) [ ] { } . , : @ ! & | < > #
                        ֡סء 

ʳεϡդĤʸȤƼͳѤǤޤ

֡(-)ϡ̤ʵȤưäƤޤ

ʸ

ʸ(⤸)ȤϡץʸˤǡΤȤǤ

ʸϡΣĤΤɤ餫ΥåΥڥǡϤߤޤ

Ūʤ

ʸ

ʸϡΤɤ餫ȽǤޤ

  • ʶ

դȸդζڤ

ܸǤϡۤȤɤξ硢դȸդδ֤˶򤪤ޤ

ΤˡץȤƸդȽ̤񤷤ʤäƤޤ

ǡƦץȤǤϡʸθդζڤ

ֽסֿסֵסʸפȽ̤ޤ

ѿ̾̿̾(ؿ᥽å)˻Ȥʸ

ʸȾʸΤۤȤɡ

ʲΤޤ

  • ȤϿѤߤѿ̾ȴؿ̾
  • (1ʸܤΤ)

ȤˡǽΣʸ˿ϻȤޤ

ʸˡ - ǡ

ѿ̾

ѿϡ̾'@'򵭽Ҥޤ

@ޥX
@
@

@ΤȤˤϡܸѸ򤽤Τޤ޻Ȥޤ2ʸܰʹߤˤϿȤޤ

ȥ

ͤѲʤǡϡˤޤޤƥǻ꤬ɬפñϡɤȤʤޤ

ȥɤϡ̾'$'򵭽Ҥޤ

$P3D
$PI

@ΤȤˤϡܸѸ򤽤Τޤ޻Ȥޤ2ʸܰʹߤˤϿȤޤ

ǡ

ѿ̾ΤȤˤϡΤ褦˽()ǡǡǤޤ

@
@åʸ

ѿ̾Υǡꤷľˡͤ뤳ȤǤޤ

@ = 0
@åʸ =֤

ܥǡ

ΥǡϡܥǡȤƥǡʤѤǤޤ

¿
ʸ
ݷ
顼

Ȥ߹ߥǡ

Ȥ߹ߥǡפȤϡ٤ʵǽäǡǡܥǡȾȤ㤤ޤ

Ȥ߹ߥǡפϡҤȤĤΥǡʣͤޤȤ᤿ꡢͤФ̤ʵǽ(᥽å)Ƥޤ(֥ȻظȤ߹ߥ֥Ȥޤ)

Τ褦ʥǡȤˤϡѿ̾ΤȤˤϡΤ褦˽()ǡǡޤ ϡۤɤƱ

@vP٥ȥ뷿

ѿ̾ˡͤϤˤϡΤ褦ˡֿ̿Ȥޤ

@vP٥ȥ뷿
@v = {x:10, y:20, z:40}P٥ȥ뷿

ϡΤ褦ˤҤȤĤˤޤȤ뤳ȤǤޤ

@vP٥ȥ뷿 = {x:10, y:20, z:40}P٥ȥ뷿

ġͤϡΤ褦ˤѤǤޤ

@v@x = 100

ޤǡФ̤ϡΤ褦˸ƤӽФޤ

@v{x:100, y:200, z:400}ꤹ

ϡʣΥǡֹĤưǽǤ

Τ褦ˡҤޤ

@ץ쥤䡼[1] = 7
@ץ쥤䡼[2] = 34
@ץ쥤䡼[3] = 240

ȤˤϡΤ褦ޤ

@(̾)(ǡ)[]

餫θĿˤϡΤ褦˽񤭤ޤ

@(̾)(ǡ)[] = (ǡ)[(Ŀ)]

ä̤ʽǤۤɤȤ߹ߥǡ䡢ȤǽФƤȼǡƱˤʤäƤޤ

ʸˡ -

Ȥꤢ(P)Ȥޤ

ܤϡSoraMame.ps.js/ReferenceΡֻѵסӵס黻פ򻲾Ȥ

ʸˡ - ʸ

ʸ

Ƭޤʸˡ//פ񤯤ȡʹߤϥʸˤʤꡢץμ¹Ի̵뤵ޤ

//ʹߤϡʸ

֥åȤϡ档

¹ʸ

¹ʸϡ¤Ӥ³ơ̿򤪤ޤ

{:250, ⤵:250}Υ
{x:ޥX, y:ޥY}{:10, ⤵:10}Υޥ

̿ˤΤϡ֥ס֥ޥפǤ

ϡְ̾פȡ͡פΣĤȤ߹碌{}פǰϤǡǤĤʤޤ

  • {̾:,}
  • ΣĤνʤȡˡ򡢤Ρǡ

ϡҤ֤(¤)¸ޤ

̾Ƚμࡦ֤ϡ̵뤵ޤ

ۤɤǡˤΤ

{:250, ⤵:250}
{x:ޥX, y:ޥY}{:10, ⤵:10}

Ǥ

ʸ

Τ褦˵Ҥơѿˡͤޤ

() = ()
@ = 0

ˤϼ()ѤǤޤ

@ = 3 + 2

ǡΤȤ褦ˡǡ³ơͤ뤳ȤǤޤ

@ = 0
@åʸ =֤

Ȥ߹ߥǡΤȤ褦ˡֿ̿ȥåȤǻȤȤǤޤ

@vP٥ȥ뷿 = {x:10, y:20, z:40}P٥ȥ뷿

ޤ黻ҤȤޤ

@ += 10

ܤϡSoraMame.ps.js/ReferenceΡפ򻲾Ȥ

⤷ʸ

2Ĥνޤ

⤷{:P}ʤ
   {//¹}
⤷{:P}ʤ
   {//¹}

   {//¹}

PˤĤƤϡSoraMame.ps.js/ReferenceΡӵס黻פ򻲾Ȥ

֤ʸ

ꤷͤꤷޤǡ򤯤֤ޤ

Τ褦˽񤭤ޤ

{:@i = 0 , :@i < 100 ,Ѳ:@i += 1}Τ꤫{
{x:@i, y:@i}{:30, ⤵:30}Υޥ
}

ʸ

ξδ֡򤯤֤ޤ

Τ褦˽񤭤ޤ

@y = 0
 {:@y < @⤵}Τ{
{x:50, y:@y}{:30, ⤵:30}Υޥ
@y += 20
}

ʬʤ̿ɲä

ʬʤ̿Ƥȡۤξ꤫鼫ͳ˸ƤӽФȤǤޤ

νޤȤƤꡢץʬ䤹뤿˻Ȥޤ

̿

̿ȡؿ᥽åɤȤѤǤޤ

ޤֽꤹפ֤֤褹פΤ褦ˡ餫줿̿ץȡץμ¹ԴĶƤӽФ⤢ޤ

̿ˤϡ4νޤ

---(̿̾){//¹}
---(̿̾)(ͥǡ){//¹}
---{̾1:1, ...}(){̾2:2, ...}()(̿̾){//¹}
---{̾1:1, ...}(){̾2:2, ...}()(̿̾)(ǡ){//¹}

Ǹ(ͥǡ)ꤷƤϡͤΥǡꤷޤ

ͤʤξϾάޤ(void)

ʲץ

---¹Ԥ{
  //¹
}
---¹Ԥ{
  //¹
  {:100}Ǥɤ
}
---{:@x}Ǽ¹Ԥ{
  //¹
}
---{:@x}Ǽ¹Ԥϼ¿{
  //¹
  {:10.2}Ǥɤ
}

(饹)

ַפϡʬʤΥǡ뵡ǽǤҤȤĤηʣΥǡޤȤ᤿ꡢǡ̿Ȥ߹碌ƤȤǤޤϡǡƱ褦˻ȤȤǤޤ

Τ褦˽񤭤ޤ

===(̾) {
  //˷
  (ĥǡ)
+++(̿){
  }
---(ȼ̿){
  }
}

̿ϡηäǡȤǽ˸ƤӽФ̿Ǥ̾Ʊ̾ˤޤǤͤϾάޤ

ȼ̿ϡΥǡ̿Ǥ(֥ȻظΥ᥽åɤˤޤ)ۤȼ̿ȽƱǤ

Ѥˤϡޤѿޤ줫ֿ̿Ȥä˸ƤӽФơѿޤΤȤꤷƽͤǤޤ̿ȷ̾Ʊ̾ˤʤäƤޤ

@(ѿ̾)(̾)
@(ѿ̾)=(̿)#ֿפȤޤ

ȼ̿ƤӽФˤϡΤ褦ˤޤ

@(ѿ̾)(ȼ̿)
@(ѿ̾)()(ȼ̿)

ȼǡƤӽФˤϡΤ褦ˤޤ

@(ѿ̾)@(ȼǡ)

Processing.jsΥ᥽åɤץѥƥɲäˡ

Ʀץ(soramame.ps.js)ϡܸäݤɤProcessing.jsΥɤѴƼ¹Ԥޤ
ƦץȤ̿ĶѿProcessing.jsΤɤΥ᥽åɤץѥƥбդ뤫ϡ餫ꤷƤޤ
ɲä뤳Ȥǡ̿ѿ򥵥ݡȤǤޤ

ե

ɲäˤϡlib_command.jsץեԽޤ
ϡlib_command.jsפΰǤ

//Ѵǡ - ̿
//ǡ  Ѵǡ
  this.commands = {
    //Structure
     : 'size',
    ꤹ : 'setup',
    ֤褹 : 'draw',
    ɤ : 'return',

ΥեˡΤ褦ʷǡѴñ(Ʀ)Ѵñ(Processing)бդޤ
Ρ,()˺ʤ褦ˤޤ礦

    (Ʀ) : '(Processing)',

եѹˤ뤳

Υե񤭴顢Web֥饦ɤ

ե

lib_command.jsפˤϡ4Ĥμ򵭽ҤǤޤ

̿

̿᥽åɤѴޤ
ĤȤǤޤ

  • 㡧 ƥ : 'point',
  • 㡧 : 'line',

Ķѿ

Ķѿ̾Ѵޤ

ƦץȤΥǵҤȤˤϡ ĶѿˤƬˡ@פդޤ

  • 㡧 : 'width',
  • 㡧 ⤵ : 'height',
  • 㡧 ޥX : 'mouseX',
  • 㡧 ޥY : 'mouseY',

ˤƬˡ$פդޤ

  • 㡧 PI : 'PI',
  • 㡧 HALF_PI : 'HALF_PI',

ǡ̾(ܥǡȤ߹ߥǡ)

ǡ̾䥯饹̾Ѵޤ
ƦץȤΥǵҤȤˤϡ
ѿ̾(ǡ̾)פȵҤޤ

  • 㡧 : 'int',
  • 㡧 ¿ : 'float',
  • 㡧 P᡼ : 'PImage',
  • 㡧 P٥ȥ뷿 : 'PVector',
  • 㡧 Pեȷ : 'PFont',

ץѥƥ̾᥽å̾

Υ饹°ץѥƥ̾᥽å̾Ѵޤ
Ʀץ¦ϡ°륯饹̾(Ѵ)ȡץѥƥ̾᥽å̾(Ѵ)
"_"(С)ǤĤʤޤ

  • 㡧 PVector_x : 'x',
  • 㡧 PVector_y : 'y',
  • 㡧 PVector_z : 'z',
  • 㡧 PVector_ : 'get',
  • 㡧 PVector_ꤹ : 'set',

˾ܤ

ƦץȤϡCJavaRubyȤäڤƤALGOLϥץߥ󥰸Ʊ褦ʸˡƤޤ

ȤˡŪʹͤϡJavaˤ褯Ƥޤ

Ȥ桼Processing/Processing.jsѴƤʤΤǡʸˡȤۤƱǤ


  ȥå   ʬ Хåå   ñ측 ǽ   إ   ǽRSS
Last-modified: 2012-12-31 () 02:38:37 (2269d)