[[Programing]] > [[Blockly2017>Programing/Blockly2017]] > ֥åκ

#title("Blockly1.0֥åκ")

#ref(final.png,nolink)

#contents()

*  [#f08c9217]

ǤϡBlocklyΥǥɤơ֥åɲäޤ

BlocklyΥ֥åϡBlocklyΥǥUIˤꡢɥåɥåפǺ뤳ȤǤޤ

ϡ֥åä塢Google Closure toolsǺư̤ȤƤɡ줬פʤΤǡäñǤ


** ǥ [#h771662c]

ˤʤǥϡBlocklyΥǥ˴ޤޤGenerating JavaScriptǤΥǥǤϡBlocklyȤäơJavascriptΥɤԽǤޤ

-[[Blockly Demo: Generating JavaScript:https://blockly-demo.appspot.com/static/demos/generator/index.html]]

** ɲä֥å [#hee713c2]

ToolboxMathƥˡrandomץ֥åɲäޤ


*  ֥å [#mc94f82e]

** ֥åǥ󤹤 [#e7f30605]

֥åΥǥϡBlockly Demoˤ[[Blockly Developer Tools:https://blockly-demo.appspot.com/static/demos/blockfactory/index.html]]ǹԤޤ

+[[Blockly Developer Tools:https://blockly-demo.appspot.com/static/demos/blockfactory/index.html]]򳫤
+ Block Factoryץ֤򥯥å
+ ޤΤ褦˥֥åȤ߹碌
+ Save ""ץܥޤ Update ""ץܥ򥯥å

#ref(block_factoy_s3.png,nolink)

¸ɤϡ֥饦Υ륹ȥ졼ˡ֥饤֥פȤ¸ޤ

** ֥å򥨥ݡȤ [#ha2db5b3]

+Block Exporterץ֤򥯥å
+ ¦ǡݡȤ֥åΥåܥå򥪥ˤ
+ Export Settings
-- Block Definition(s): ֥å
--- Format: Javascript
--- File Name()random_block.js
-- Generator Stub(s): Ѵ
--- Language: Javascript
--- File Name:()random.js
+Exportץܥ򥯥åơΥե˳Ǽ
-- ֥å /blocks/random_block.js
-- Ѵ /generators/javaScript/random.js

#ref(block_expoter_s.png,nolink)

ݡȻʣΥ֥å򤷤ƤȡȤΥեˤޤȤ롣θΡѴɤɲáפ񤭤ƤޤΤա

*Ȥ߹ [#f176a70c]

** ɤ [#v3942239]

BlocklyΥɤ򡢼Τɤ餫ɤŸޤ

-[[GithubClone:https://github.com/google/blockly]]
-[[ZIPեΥ:https://github.com/google/blockly/archive/master.zip]]


** ǥץ¹Ԥ [#x2d2441a]

Generating JavaScriptϡɤե/demos/generatorˤޤ


** ǥץʣ [#b367259f]

/demos/generatorեƱ/demosե˴ݤʣޤ

ǤȤơ/demos/testȤʣƤޤ

index.html򳫤ơưǧƤޤ礦

* ֥åȤ߹ [#s03644fe]

** Ѵɤɲä [#kc1a1548]

random.jsԽơ֥åѴ륳ɤ򵭽Ҥޤ(5)

 Blockly.JavaScript['random'] = function(block) {
   var value_min = Blockly.JavaScript.valueToCode(block, 'min', Blockly.JavaScript.ORDER_ATOMIC);
   var value_max = Blockly.JavaScript.valueToCode(block, 'max', Blockly.JavaScript.ORDER_ATOMIC);
   // TODO: Assemble JavaScript into code variable.
   var code = 'Math.floor( Math.random() * (' + value_max + ' - ' + value_min + ' + 1 )) + ' +  value_min;
   // TODO: Change ORDER_NONE to the correct strength.
   return [code, Blockly.JavaScript.ORDER_NONE];
 };


** index.html˥֥åɤ߹ [#tb02c9bb]

/demos/test/index.html򳫤ơrandom_block.jsפȡrandom.jsפɤ߹ߤǤ褦ˤޤ(6ܤ7)

 <title>Blockly Demo: Generating JavaScript</title>
 <script src="../../blockly_compressed.js"></script>
 <script src="../../blocks_compressed.js"></script>
 <script src="../../javascript_compressed.js"></script>
 <script src="../../msg/js/en.js"></script>
 <script src="../../blocks/random_block.js"></script>
 <script src="../../generators/javaScript/random.js"></script>


** Toolbox˥֥åɲä [#t2a9dbdd]

Tooboxϡ<xml id="toolbox" style="display: none"> - </xml>ǡindex.htmlƤޤ

ToolboxMathƥˡrandomץ֥åɲäޤ(5)

 <category name="Math">
   <block type="math_number"></block>
   <block type="math_arithmetic"></block>
   <block type="math_single"></block>
   <block type="random"></block>
 </category>


** ưǧ [#s6dd5f6c]

Խ/demos/test/index.html򳫤ȡMathƥrandom֥åɲäƤޤ

#ref(add_toolbox.png,nolink)

󡢤Υ֥åȤäơץȤΩƤꡢǧꡢ¹ԤǤޤ

#ref(final.png,nolink)

* ¾ [#g3701ce6]

** ֥åοѹ [#j2ca8964]

֥åοѤˡ3Ĥ롣

- Blockly Developer Toolsǿ(:Hue)ꤹ롣(Saturation)(Value)ϸ
- blocks_compressed.js ޤ core/constant.js˵ҤƤBlockly.HSV_SATURATIONBlockly.HSV_VALUE(0.0-1.0)ϡƤΥ֥åο礤ĴǤ롣
- (Saturation)(Value)ϡblocks_compressed.js ޤ core/constant.jsˤBlockly.HSV_SATURATIONBlockly.HSV_VALUE(0.0-1.0)ϡƤΥ֥åο礤Ĵ롣
-- https://groups.google.com/forum/#!topic/blockly/6qLrbJSwE3w

 /**
  * The richness of block colours, regardless of the hue.
  * Must be in the range of 0 (inclusive) to 1 (exclusive).
  */
 Blockly.HSV_SATURATION = 0.45;
 /**
  * The intensity of block colours, regardless of the hue.
  * Must be in the range of 0 (inclusive) to 1 (exclusive).
  */
 Blockly.HSV_VALUE = 0.65;

- ޥɲå֥åϡ#RRGGBBǿǤ
-- https://developers.google.com/blockly/reference/js/Blockly.Block#setColour

 this.setColour("#808080");

** ͻ [#b6e7342f]

ΥСϡpythonΥץ(build.py)ưɬפäϡGoogle Clusur template(GCT)JSΥץȤޡܥߥ˥ޥƤΤǤϤʤ

̤GCTȤɬפϤʤΤǡʬιߤΥġǥߥ˥ޥФȻפ

** Ϣڡ [#ab720fb9]

- [[Blockly2017>Programing/Blockly2017]] 
- [[Blockly1.0ġܥåȥڡˡ>Blockly/Toolbox_WorkSpace]]

ȥå   ʬ Хåå   ñ측 ǽ   إ   ǽRSS