-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
seperate core and c_core, auto-generate dependency, update google-blo…
…ckly
- Loading branch information
1 parent
b6a710a
commit 6de4295
Showing
174 changed files
with
49,254 additions
and
10,745 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,115 +20,118 @@ | |
|
||
/** | ||
* @fileoverview Colour blocks for Blockly. | ||
* | ||
* This file is scraped to extract a .json file of block definitions. The array | ||
* passed to defineBlocksWithJsonArray(..) must be strict JSON: double quotes | ||
* only, no outside references, no functions, no trailing commas, etc. The one | ||
* exception is end-of-line comments, which the scraper will remove. | ||
* @author [email protected] (Neil Fraser) | ||
*/ | ||
'use strict'; | ||
|
||
goog.provide('Blockly.Blocks.colour'); | ||
goog.provide('Blockly.Blocks.colour'); // Deprecated | ||
goog.provide('Blockly.Constants.Colour'); | ||
|
||
goog.require('Blockly.Blocks'); | ||
goog.require('Blockly.Types'); | ||
goog.require('Blockly'); | ||
|
||
|
||
/** | ||
* Common HSV hue for all blocks in this category. | ||
* This should be the same as Blockly.Msg.COLOUR_HUE. | ||
* @readonly | ||
*/ | ||
Blockly.Blocks.colour.HUE = 20; | ||
Blockly.Constants.Colour.HUE = 20; | ||
/** @deprecated Use Blockly.Constants.Colour.HUE */ | ||
Blockly.Blocks.colour.HUE = Blockly.Constants.Colour.HUE; | ||
|
||
Blockly.Blocks['colour_picker'] = { | ||
/** | ||
* Block for colour picker. | ||
* @this Blockly.Block | ||
*/ | ||
init: function() { | ||
this.jsonInit({ | ||
"message0": "%1", | ||
"args0": [ | ||
{ | ||
"type": "field_colour", | ||
"name": "COLOUR", | ||
"colour": "#ff0000" | ||
} | ||
], | ||
"output": "Colour", | ||
"colour": Blockly.Blocks.colour.HUE, | ||
"helpUrl": Blockly.Msg.COLOUR_PICKER_HELPURL | ||
}); | ||
// Assign 'this' to a variable for use in the tooltip closure below. | ||
var thisBlock = this; | ||
// Colour block is trivial. Use tooltip of parent block if it exists. | ||
this.setTooltip(function() { | ||
var parent = thisBlock.getParent(); | ||
return (parent && parent.getInputsInline() && parent.tooltip) || | ||
Blockly.Msg.COLOUR_PICKER_TOOLTIP; | ||
}); | ||
} | ||
}; | ||
Blockly.defineBlocksWithJsonArray([ // BEGIN JSON EXTRACT | ||
// Block for colour picker. | ||
{ | ||
"type": "colour_picker", | ||
"message0": "%1", | ||
"args0": [ | ||
{ | ||
"type": "field_colour", | ||
"name": "COLOUR", | ||
"colour": "#ff0000" | ||
} | ||
], | ||
"output": "Colour", | ||
"colour": "%{BKY_COLOUR_HUE}", | ||
"helpUrl": "%{BKY_COLOUR_PICKER_HELPURL}", | ||
"tooltip": "%{BKY_COLOUR_PICKER_TOOLTIP}", | ||
"extensions": ["parent_tooltip_when_inline"] | ||
}, | ||
|
||
Blockly.Blocks['colour_random'] = { | ||
/** | ||
* Block for random colour. | ||
* @this Blockly.Block | ||
*/ | ||
init: function() { | ||
this.jsonInit({ | ||
"message0": Blockly.Msg.COLOUR_RANDOM_TITLE, | ||
"output": "Colour", | ||
"colour": Blockly.Blocks.colour.HUE, | ||
"tooltip": Blockly.Msg.COLOUR_RANDOM_TOOLTIP, | ||
"helpUrl": Blockly.Msg.COLOUR_RANDOM_HELPURL | ||
}); | ||
} | ||
}; | ||
// Block for random colour. | ||
{ | ||
"type": "colour_random", | ||
"message0": "%{BKY_COLOUR_RANDOM_TITLE}", | ||
"output": "Colour", | ||
"colour": "%{BKY_COLOUR_HUE}", | ||
"helpUrl": "%{BKY_COLOUR_RANDOM_HELPURL}", | ||
"tooltip": "%{BKY_COLOUR_RANDOM_TOOLTIP}" | ||
}, | ||
|
||
Blockly.Blocks['colour_rgb'] = { | ||
/** | ||
* Block for composing a colour from RGB components. | ||
* @this Blockly.Block | ||
*/ | ||
init: function() { | ||
this.setHelpUrl(Blockly.Msg.COLOUR_RGB_HELPURL); | ||
this.setColour(Blockly.Blocks.colour.HUE); | ||
this.appendValueInput('RED') | ||
.setCheck(Blockly.Types.NUMBER.checkList) | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(Blockly.Msg.COLOUR_RGB_TITLE) | ||
.appendField(Blockly.Msg.COLOUR_RGB_RED); | ||
this.appendValueInput('GREEN') | ||
.setCheck(Blockly.Types.NUMBER.checkList) | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(Blockly.Msg.COLOUR_RGB_GREEN); | ||
this.appendValueInput('BLUE') | ||
.setCheck(Blockly.Types.NUMBER.checkList) | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(Blockly.Msg.COLOUR_RGB_BLUE); | ||
this.setOutput(true, 'Colour'); | ||
this.setTooltip(Blockly.Msg.COLOUR_RGB_TOOLTIP); | ||
} | ||
}; | ||
// Block for composing a colour from RGB components. | ||
{ | ||
"type": "colour_rgb", | ||
"message0": "%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3", | ||
"args0": [ | ||
{ | ||
"type": "input_value", | ||
"name": "RED", | ||
"check": "Number", | ||
"align": "RIGHT" | ||
}, | ||
{ | ||
"type": "input_value", | ||
"name": "GREEN", | ||
"check": "Number", | ||
"align": "RIGHT" | ||
}, | ||
{ | ||
"type": "input_value", | ||
"name": "BLUE", | ||
"check": "Number", | ||
"align": "RIGHT" | ||
} | ||
], | ||
"output": "Colour", | ||
"colour": "%{BKY_COLOUR_HUE}", | ||
"helpUrl": "%{BKY_COLOUR_RGB_HELPURL}", | ||
"tooltip": "%{BKY_COLOUR_RGB_TOOLTIP}" | ||
}, | ||
|
||
Blockly.Blocks['colour_blend'] = { | ||
/** | ||
* Block for blending two colours together. | ||
* @this Blockly.Block | ||
*/ | ||
init: function() { | ||
this.setHelpUrl(Blockly.Msg.COLOUR_BLEND_HELPURL); | ||
this.setColour(Blockly.Blocks.colour.HUE); | ||
this.appendValueInput('COLOUR1') | ||
.setCheck('Colour') | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(Blockly.Msg.COLOUR_BLEND_TITLE) | ||
.appendField(Blockly.Msg.COLOUR_BLEND_COLOUR1); | ||
this.appendValueInput('COLOUR2') | ||
.setCheck('Colour') | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(Blockly.Msg.COLOUR_BLEND_COLOUR2); | ||
this.appendValueInput('RATIO') | ||
.setCheck(Blockly.Types.NUMBER.checkList) | ||
.setAlign(Blockly.ALIGN_RIGHT) | ||
.appendField(Blockly.Msg.COLOUR_BLEND_RATIO); | ||
this.setOutput(true, 'Colour'); | ||
this.setTooltip(Blockly.Msg.COLOUR_BLEND_TOOLTIP); | ||
// Block for blending two colours together. | ||
{ | ||
"type": "colour_blend", | ||
"message0": "%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} " + | ||
"%1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3", | ||
"args0": [ | ||
{ | ||
"type": "input_value", | ||
"name": "COLOUR1", | ||
"check": "Colour", | ||
"align": "RIGHT" | ||
}, | ||
{ | ||
"type": "input_value", | ||
"name": "COLOUR2", | ||
"check": "Colour", | ||
"align": "RIGHT" | ||
}, | ||
{ | ||
"type": "input_value", | ||
"name": "RATIO", | ||
"check": "Number", | ||
"align": "RIGHT" | ||
} | ||
], | ||
"output": "Colour", | ||
"colour": "%{BKY_COLOUR_HUE}", | ||
"helpUrl": "%{BKY_COLOUR_BLEND_HELPURL}", | ||
"tooltip": "%{BKY_COLOUR_BLEND_TOOLTIP}" | ||
} | ||
}; | ||
]); // END JSON EXTRACT (Do not delete this comment.) |
Oops, something went wrong.