212 |
Remember to connect your PC/laptop to to your B-Robot Wifi network! (JJROBOTS_xx, password:87654321)
213 |
214 |
215 |
216 |
217 |
--------------------------------------------------------------------------------
/Blockly/brobot/generators/python/loops.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Visual Blocks Language
4 | *
5 | * Copyright 2012 Google Inc.
6 | * https://developers.google.com/blockly/
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 |
21 | /**
22 | * @fileoverview Generating Python for loop blocks.
23 | * @author q.neutron@gmail.com (Quynh Neutron)
24 | */
25 | 'use strict';
26 |
27 | goog.provide('Blockly.Python.loops');
28 |
29 | goog.require('Blockly.Python');
30 |
31 |
32 | Blockly.Python['controls_repeat_ext'] = function(block) {
33 | // Repeat n times.
34 | if (block.getField('TIMES')) {
35 | // Internal number.
36 | var repeats = String(parseInt(block.getFieldValue('TIMES'), 10));
37 | } else {
38 | // External number.
39 | var repeats = Blockly.Python.valueToCode(block, 'TIMES',
40 | Blockly.Python.ORDER_NONE) || '0';
41 | }
42 | if (Blockly.isNumber(repeats)) {
43 | repeats = parseInt(repeats, 10);
44 | } else {
45 | repeats = 'int(' + repeats + ')';
46 | }
47 | var branch = Blockly.Python.statementToCode(block, 'DO');
48 | branch = Blockly.Python.addLoopTrap(branch, block.id) ||
49 | Blockly.Python.PASS;
50 | var loopVar = Blockly.Python.variableDB_.getDistinctName(
51 | 'count', Blockly.Variables.NAME_TYPE);
52 | var code = 'for ' + loopVar + ' in range(' + repeats + '):\n' + branch;
53 | return code;
54 | };
55 |
56 | Blockly.Python['controls_repeat'] = Blockly.Python['controls_repeat_ext'];
57 |
58 | Blockly.Python['controls_whileUntil'] = function(block) {
59 | // Do while/until loop.
60 | var until = block.getFieldValue('MODE') == 'UNTIL';
61 | var argument0 = Blockly.Python.valueToCode(block, 'BOOL',
62 | until ? Blockly.Python.ORDER_LOGICAL_NOT :
63 | Blockly.Python.ORDER_NONE) || 'False';
64 | var branch = Blockly.Python.statementToCode(block, 'DO');
65 | branch = Blockly.Python.addLoopTrap(branch, block.id) ||
66 | Blockly.Python.PASS;
67 | if (until) {
68 | argument0 = 'not ' + argument0;
69 | }
70 | return 'while ' + argument0 + ':\n' + branch;
71 | };
72 |
73 | Blockly.Python['controls_for'] = function(block) {
74 | // For loop.
75 | var variable0 = Blockly.Python.variableDB_.getName(
76 | block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
77 | var argument0 = Blockly.Python.valueToCode(block, 'FROM',
78 | Blockly.Python.ORDER_NONE) || '0';
79 | var argument1 = Blockly.Python.valueToCode(block, 'TO',
80 | Blockly.Python.ORDER_NONE) || '0';
81 | var increment = Blockly.Python.valueToCode(block, 'BY',
82 | Blockly.Python.ORDER_NONE) || '1';
83 | var branch = Blockly.Python.statementToCode(block, 'DO');
84 | branch = Blockly.Python.addLoopTrap(branch, block.id) ||
85 | Blockly.Python.PASS;
86 |
87 | var code = '';
88 | var range;
89 |
90 | // Helper functions.
91 | var defineUpRange = function() {
92 | return Blockly.Python.provideFunction_(
93 | 'upRange',
94 | ['def ' + Blockly.Python.FUNCTION_NAME_PLACEHOLDER_ +
95 | '(start, stop, step):',
96 | ' while start <= stop:',
97 | ' yield start',
98 | ' start += abs(step)']);
99 | };
100 | var defineDownRange = function() {
101 | return Blockly.Python.provideFunction_(
102 | 'downRange',
103 | ['def ' + Blockly.Python.FUNCTION_NAME_PLACEHOLDER_ +
104 | '(start, stop, step):',
105 | ' while start >= stop:',
106 | ' yield start',
107 | ' start -= abs(step)']);
108 | };
109 | // Arguments are legal Python code (numbers or strings returned by scrub()).
110 | var generateUpDownRange = function(start, end, inc) {
111 | return '(' + start + ' <= ' + end + ') and ' +
112 | defineUpRange() + '(' + start + ', ' + end + ', ' + inc + ') or ' +
113 | defineDownRange() + '(' + start + ', ' + end + ', ' + inc + ')';
114 | };
115 |
116 | if (Blockly.isNumber(argument0) && Blockly.isNumber(argument1) &&
117 | Blockly.isNumber(increment)) {
118 | // All parameters are simple numbers.
119 | argument0 = parseFloat(argument0);
120 | argument1 = parseFloat(argument1);
121 | increment = Math.abs(parseFloat(increment));
122 | if (argument0 % 1 === 0 && argument1 % 1 === 0 && increment % 1 === 0) {
123 | // All parameters are integers.
124 | if (argument0 <= argument1) {
125 | // Count up.
126 | argument1++;
127 | if (argument0 == 0 && increment == 1) {
128 | // If starting index is 0, omit it.
129 | range = argument1;
130 | } else {
131 | range = argument0 + ', ' + argument1;
132 | }
133 | // If increment isn't 1, it must be explicit.
134 | if (increment != 1) {
135 | range += ', ' + increment;
136 | }
137 | } else {
138 | // Count down.
139 | argument1--;
140 | range = argument0 + ', ' + argument1 + ', -' + increment;
141 | }
142 | range = 'range(' + range + ')';
143 | } else {
144 | // At least one of the parameters is not an integer.
145 | if (argument0 < argument1) {
146 | range = defineUpRange();
147 | } else {
148 | range = defineDownRange();
149 | }
150 | range += '(' + argument0 + ', ' + argument1 + ', ' + increment + ')';
151 | }
152 | } else {
153 | // Cache non-trivial values to variables to prevent repeated look-ups.
154 | var scrub = function(arg, suffix) {
155 | if (Blockly.isNumber(arg)) {
156 | // Simple number.
157 | arg = parseFloat(arg);
158 | } else if (arg.match(/^\w+$/)) {
159 | // Variable.
160 | arg = 'float(' + arg + ')';
161 | } else {
162 | // It's complicated.
163 | var varName = Blockly.Python.variableDB_.getDistinctName(
164 | variable0 + suffix, Blockly.Variables.NAME_TYPE);
165 | code += varName + ' = float(' + arg + ')\n';
166 | arg = varName;
167 | }
168 | return arg;
169 | };
170 | var startVar = scrub(argument0, '_start');
171 | var endVar = scrub(argument1, '_end');
172 | var incVar = scrub(increment, '_inc');
173 |
174 | if (typeof startVar == 'number' && typeof endVar == 'number') {
175 | if (startVar < endVar) {
176 | range = defineUpRange(startVar, endVar, increment);
177 | } else {
178 | range = defineDownRange(startVar, endVar, increment);
179 | }
180 | } else {
181 | // We cannot determine direction statically.
182 | range = generateUpDownRange(startVar, endVar, increment);
183 | }
184 | }
185 | code += 'for ' + variable0 + ' in ' + range + ':\n' + branch;
186 | return code;
187 | };
188 |
189 | Blockly.Python['controls_forEach'] = function(block) {
190 | // For each loop.
191 | var variable0 = Blockly.Python.variableDB_.getName(
192 | block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
193 | var argument0 = Blockly.Python.valueToCode(block, 'LIST',
194 | Blockly.Python.ORDER_RELATIONAL) || '[]';
195 | var branch = Blockly.Python.statementToCode(block, 'DO');
196 | branch = Blockly.Python.addLoopTrap(branch, block.id) ||
197 | Blockly.Python.PASS;
198 | var code = 'for ' + variable0 + ' in ' + argument0 + ':\n' + branch;
199 | return code;
200 | };
201 |
202 | Blockly.Python['controls_flow_statements'] = function(block) {
203 | // Flow statements: continue, break.
204 | switch (block.getFieldValue('FLOW')) {
205 | case 'BREAK':
206 | return 'break\n';
207 | case 'CONTINUE':
208 | return 'continue\n';
209 | }
210 | throw 'Unknown flow statement.';
211 | };
212 |
--------------------------------------------------------------------------------
/Blockly/brobot/msg/json/en-gb.json:
--------------------------------------------------------------------------------
1 | {
2 | "@metadata": {
3 | "authors": [
4 | "Andibing",
5 | "Codynguyen1116",
6 | "Shirayuki"
7 | ]
8 | },
9 | "VARIABLES_DEFAULT_NAME": "item",
10 | "TODAY": "Today",
11 | "DUPLICATE_BLOCK": "Duplicate",
12 | "ADD_COMMENT": "Add Comment",
13 | "REMOVE_COMMENT": "Remove Comment",
14 | "EXTERNAL_INPUTS": "External Inputs",
15 | "INLINE_INPUTS": "Inline Inputs",
16 | "DELETE_BLOCK": "Delete Block",
17 | "DELETE_X_BLOCKS": "Delete %1 Blocks",
18 | "DELETE_ALL_BLOCKS": "Delete all %1 blocks?",
19 | "CLEAN_UP": "Clean up Blocks",
20 | "COLLAPSE_BLOCK": "Collapse Block",
21 | "COLLAPSE_ALL": "Collapse Blocks",
22 | "EXPAND_BLOCK": "Expand Block",
23 | "EXPAND_ALL": "Expand Blocks",
24 | "DISABLE_BLOCK": "Disable Block",
25 | "ENABLE_BLOCK": "Enable Block",
26 | "HELP": "Help",
27 | "UNDO": "Undo",
28 | "REDO": "Redo",
29 | "CHANGE_VALUE_TITLE": "Change value:",
30 | "RENAME_VARIABLE": "Rename variable...",
31 | "RENAME_VARIABLE_TITLE": "Rename all '%1' variables to:",
32 | "NEW_VARIABLE": "New variable...",
33 | "NEW_VARIABLE_TITLE": "New variable name:",
34 | "COLOUR_PICKER_HELPURL": "https://en.wikipedia.org/wiki/Colour",
35 | "COLOUR_PICKER_TOOLTIP": "Choose a colour from the palette.",
36 | "COLOUR_RANDOM_TITLE": "random colour",
37 | "COLOUR_RANDOM_TOOLTIP": "Choose a colour at random.",
38 | "COLOUR_RGB_TITLE": "colour with",
39 | "COLOUR_RGB_RED": "red",
40 | "COLOUR_RGB_GREEN": "green",
41 | "COLOUR_RGB_BLUE": "blue",
42 | "COLOUR_RGB_TOOLTIP": "Create a colour with the specified amount of red, green, and blue. All values must be between 0 and 100.",
43 | "COLOUR_BLEND_TITLE": "blend",
44 | "COLOUR_BLEND_COLOUR1": "colour 1",
45 | "COLOUR_BLEND_COLOUR2": "colour 2",
46 | "COLOUR_BLEND_RATIO": "ratio",
47 | "COLOUR_BLEND_TOOLTIP": "Blends two colours together with a given ratio (0.0 - 1.0).",
48 | "CONTROLS_REPEAT_HELPURL": "https://en.wikipedia.org/wiki/For_loop",
49 | "CONTROLS_REPEAT_TITLE": "repeat %1 times",
50 | "CONTROLS_REPEAT_INPUT_DO": "do",
51 | "CONTROLS_REPEAT_TOOLTIP": "Do some statements several times.",
52 | "CONTROLS_WHILEUNTIL_OPERATOR_WHILE": "repeat while",
53 | "CONTROLS_WHILEUNTIL_OPERATOR_UNTIL": "repeat until",
54 | "CONTROLS_WHILEUNTIL_TOOLTIP_WHILE": "While a value is true, then do some statements.",
55 | "CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL": "While a value is false, then do some statements.",
56 | "CONTROLS_FOR_TOOLTIP": "Have the variable '%1' take on the values from the start number to the end number, counting by the specified interval, and do the specified blocks.",
57 | "CONTROLS_FOR_TITLE": "count with %1 from %2 to %3 by %4",
58 | "CONTROLS_FOREACH_TITLE": "for each item %1 in list %2",
59 | "CONTROLS_FOREACH_TOOLTIP": "For each item in a list, set the variable '%1' to the item, and then do some statements.",
60 | "CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK": "break out of loop",
61 | "CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE": "continue with next iteration of loop",
62 | "CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK": "Break out of the containing loop.",
63 | "CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE": "Skip the rest of this loop, and continue with the next iteration.",
64 | "CONTROLS_FLOW_STATEMENTS_WARNING": "Warning: This block may only be used within a loop.",
65 | "CONTROLS_IF_TOOLTIP_1": "If a value is true, then do some statements.",
66 | "CONTROLS_IF_TOOLTIP_2": "If a value is true, then do the first block of statements. Otherwise, do the second block of statements.",
67 | "CONTROLS_IF_TOOLTIP_3": "If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements.",
68 | "CONTROLS_IF_TOOLTIP_4": "If the first value is true, then do the first block of statements. Otherwise, if the second value is true, do the second block of statements. If none of the values are true, do the last block of statements.",
69 | "CONTROLS_IF_MSG_IF": "if",
70 | "CONTROLS_IF_MSG_ELSEIF": "else if",
71 | "CONTROLS_IF_MSG_ELSE": "else",
72 | "CONTROLS_IF_IF_TOOLTIP": "Add, remove, or reorder sections to reconfigure this if block.",
73 | "CONTROLS_IF_ELSEIF_TOOLTIP": "Add a condition to the if block.",
74 | "CONTROLS_IF_ELSE_TOOLTIP": "Add a final, catch-all condition to the if block.",
75 | "LOGIC_COMPARE_HELPURL": "https://en.wikipedia.org/wiki/Inequality_(mathematics)",
76 | "LOGIC_COMPARE_TOOLTIP_EQ": "Return true if both inputs equal each other.",
77 | "LOGIC_COMPARE_TOOLTIP_NEQ": "Return true if both inputs are not equal to each other.",
78 | "LOGIC_COMPARE_TOOLTIP_LT": "Return true if the first input is smaller than the second input.",
79 | "LOGIC_COMPARE_TOOLTIP_LTE": "Return true if the first input is smaller than or equal to the second input.",
80 | "LOGIC_COMPARE_TOOLTIP_GT": "Return true if the first input is greater than the second input.",
81 | "LOGIC_COMPARE_TOOLTIP_GTE": "Return true if the first input is greater than or equal to the second input.",
82 | "LOGIC_OPERATION_TOOLTIP_AND": "Return true if both inputs are true.",
83 | "LOGIC_OPERATION_AND": "and",
84 | "LOGIC_OPERATION_TOOLTIP_OR": "Return true if at least one of the inputs is true.",
85 | "LOGIC_OPERATION_OR": "or",
86 | "LOGIC_NEGATE_TITLE": "not %1",
87 | "LOGIC_NEGATE_TOOLTIP": "Returns true if the input is false. Returns false if the input is true.",
88 | "LOGIC_BOOLEAN_TRUE": "true",
89 | "LOGIC_BOOLEAN_FALSE": "false",
90 | "LOGIC_BOOLEAN_TOOLTIP": "Returns either true or false.",
91 | "LOGIC_NULL": "null",
92 | "LOGIC_NULL_TOOLTIP": "Returns null.",
93 | "LOGIC_TERNARY_CONDITION": "test",
94 | "LOGIC_TERNARY_IF_TRUE": "if true",
95 | "LOGIC_TERNARY_IF_FALSE": "if false",
96 | "LOGIC_TERNARY_TOOLTIP": "Check the condition in 'test'. If the condition is true, returns the 'if true' value; otherwise returns the 'if false' value.",
97 | "MATH_NUMBER_HELPURL": "https://en.wikipedia.org/wiki/Number",
98 | "MATH_NUMBER_TOOLTIP": "A number.",
99 | "MATH_ARITHMETIC_HELPURL": "https://en.wikipedia.org/wiki/Arithmetic",
100 | "MATH_ARITHMETIC_TOOLTIP_ADD": "Return the sum of the two numbers.",
101 | "MATH_ARITHMETIC_TOOLTIP_MINUS": "Return the difference of the two numbers.",
102 | "MATH_ARITHMETIC_TOOLTIP_MULTIPLY": "Return the product of the two numbers.",
103 | "MATH_ARITHMETIC_TOOLTIP_DIVIDE": "Return the quotient of the two numbers.",
104 | "MATH_ARITHMETIC_TOOLTIP_POWER": "Return the first number raised to the power of the second number.",
105 | "MATH_SINGLE_HELPURL": "https://en.wikipedia.org/wiki/Square_root",
106 | "MATH_SINGLE_OP_ROOT": "square root",
107 | "MATH_SINGLE_TOOLTIP_ROOT": "Return the square root of a number.",
108 | "MATH_SINGLE_OP_ABSOLUTE": "absolute",
109 | "MATH_SINGLE_TOOLTIP_ABS": "Return the absolute value of a number.",
110 | "MATH_SINGLE_TOOLTIP_NEG": "Return the negation of a number.",
111 | "MATH_SINGLE_TOOLTIP_LN": "Return the natural logarithm of a number.",
112 | "MATH_SINGLE_TOOLTIP_LOG10": "Return the base 10 logarithm of a number.",
113 | "MATH_SINGLE_TOOLTIP_EXP": "Return e to the power of a number.",
114 | "MATH_SINGLE_TOOLTIP_POW10": "Return 10 to the power of a number.",
115 | "MATH_TRIG_HELPURL": "https://en.wikipedia.org/wiki/Trigonometric_functions",
116 | "MATH_TRIG_TOOLTIP_SIN": "Return the sine of a degree (not radian).",
117 | "MATH_TRIG_TOOLTIP_COS": "Return the cosine of a degree (not radian).",
118 | "MATH_TRIG_TOOLTIP_TAN": "Return the tangent of a degree (not radian).",
119 | "MATH_TRIG_TOOLTIP_ASIN": "Return the arcsine of a number.",
120 | "MATH_TRIG_TOOLTIP_ACOS": "Return the arccosine of a number.",
121 | "MATH_TRIG_TOOLTIP_ATAN": "Return the arctangent of a number.",
122 | "MATH_CONSTANT_HELPURL": "https://en.wikipedia.org/wiki/Mathematical_constant",
123 | "MATH_CONSTANT_TOOLTIP": "Return one of the common constants: π (3.141…), e (2.718…), φ (1.618…), sqrt(2) (1.414…), sqrt(½) (0.707…), or ∞ (infinity).",
124 | "MATH_IS_EVEN": "is even",
125 | "MATH_IS_ODD": "is odd",
126 | "MATH_IS_PRIME": "is prime",
127 | "MATH_IS_WHOLE": "is whole",
128 | "MATH_IS_POSITIVE": "is positive",
129 | "MATH_IS_NEGATIVE": "is negative",
130 | "MATH_IS_DIVISIBLE_BY": "is divisible by",
131 | "MATH_IS_TOOLTIP": "Check if a number is an even, odd, prime, whole, positive, negative, or if it is divisible by certain number. Returns true or false.",
132 | "MATH_CHANGE_HELPURL": "https://en.wikipedia.org/wiki/Programming_idiom#Incrementing_a_counter",
133 | "MATH_CHANGE_TITLE": "change %1 by %2",
134 | "MATH_CHANGE_TOOLTIP": "Add a number to variable '%1'.",
135 | "MATH_ROUND_HELPURL": "https://en.wikipedia.org/wiki/Rounding",
136 | "MATH_ROUND_TOOLTIP": "Round a number up or down.",
137 | "MATH_ROUND_OPERATOR_ROUND": "round",
138 | "LISTS_SORT_ORDER_DESCENDING": "descendente"
139 | }
140 |
--------------------------------------------------------------------------------
/Blockly/brobot/generators/python/text.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Visual Blocks Language
4 | *
5 | * Copyright 2012 Google Inc.
6 | * https://developers.google.com/blockly/
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 |
21 | /**
22 | * @fileoverview Generating Python for text blocks.
23 | * @author q.neutron@gmail.com (Quynh Neutron)
24 | */
25 | 'use strict';
26 |
27 | goog.provide('Blockly.Python.texts');
28 |
29 | goog.require('Blockly.Python');
30 |
31 |
32 | Blockly.Python['text'] = function(block) {
33 | // Text value.
34 | var code = Blockly.Python.quote_(block.getFieldValue('TEXT'));
35 | return [code, Blockly.Python.ORDER_ATOMIC];
36 | };
37 |
38 | Blockly.Python['text_join'] = function(block) {
39 | // Create a string made up of any number of elements of any type.
40 | //Should we allow joining by '-' or ',' or any other characters?
41 | switch (block.itemCount_) {
42 | case 0:
43 | return ['\'\'', Blockly.Python.ORDER_ATOMIC];
44 | break;
45 | case 1:
46 | var element = Blockly.Python.valueToCode(block, 'ADD0',
47 | Blockly.Python.ORDER_NONE) || '\'\'';
48 | var code = 'str(' + element + ')';
49 | return [code, Blockly.Python.ORDER_FUNCTION_CALL];
50 | break;
51 | case 2:
52 | var element0 = Blockly.Python.valueToCode(block, 'ADD0',
53 | Blockly.Python.ORDER_NONE) || '\'\'';
54 | var element1 = Blockly.Python.valueToCode(block, 'ADD1',
55 | Blockly.Python.ORDER_NONE) || '\'\'';
56 | var code = 'str(' + element0 + ') + str(' + element1 + ')';
57 | return [code, Blockly.Python.ORDER_ADDITIVE];
58 | break;
59 | default:
60 | var elements = [];
61 | for (var i = 0; i < block.itemCount_; i++) {
62 | elements[i] = Blockly.Python.valueToCode(block, 'ADD' + i,
63 | Blockly.Python.ORDER_NONE) || '\'\'';
64 | }
65 | var tempVar = Blockly.Python.variableDB_.getDistinctName('x',
66 | Blockly.Variables.NAME_TYPE);
67 | var code = '\'\'.join([str(' + tempVar + ') for ' + tempVar + ' in [' +
68 | elements.join(', ') + ']])';
69 | return [code, Blockly.Python.ORDER_FUNCTION_CALL];
70 | }
71 | };
72 |
73 | Blockly.Python['text_append'] = function(block) {
74 | // Append to a variable in place.
75 | var varName = Blockly.Python.variableDB_.getName(block.getFieldValue('VAR'),
76 | Blockly.Variables.NAME_TYPE);
77 | var value = Blockly.Python.valueToCode(block, 'TEXT',
78 | Blockly.Python.ORDER_NONE) || '\'\'';
79 | return varName + ' = str(' + varName + ') + str(' + value + ')\n';
80 | };
81 |
82 | Blockly.Python['text_length'] = function(block) {
83 | // Is the string null or array empty?
84 | var text = Blockly.Python.valueToCode(block, 'VALUE',
85 | Blockly.Python.ORDER_NONE) || '\'\'';
86 | return ['len(' + text + ')', Blockly.Python.ORDER_FUNCTION_CALL];
87 | };
88 |
89 | Blockly.Python['text_isEmpty'] = function(block) {
90 | // Is the string null or array empty?
91 | var text = Blockly.Python.valueToCode(block, 'VALUE',
92 | Blockly.Python.ORDER_NONE) || '\'\'';
93 | var code = 'not len(' + text + ')';
94 | return [code, Blockly.Python.ORDER_LOGICAL_NOT];
95 | };
96 |
97 | Blockly.Python['text_indexOf'] = function(block) {
98 | // Search the text for a substring.
99 | // Should we allow for non-case sensitive???
100 | var operator = block.getFieldValue('END') == 'FIRST' ? 'find' : 'rfind';
101 | var substring = Blockly.Python.valueToCode(block, 'FIND',
102 | Blockly.Python.ORDER_NONE) || '\'\'';
103 | var text = Blockly.Python.valueToCode(block, 'VALUE',
104 | Blockly.Python.ORDER_MEMBER) || '\'\'';
105 | var code = text + '.' + operator + '(' + substring + ')';
106 | if (block.workspace.options.oneBasedIndex) {
107 | return [code + ' + 1', Blockly.Python.ORDER_ADDITIVE];
108 | }
109 | return [code, Blockly.Python.ORDER_FUNCTION_CALL];
110 | };
111 |
112 | Blockly.Python['text_charAt'] = function(block) {
113 | // Get letter at index.
114 | // Note: Until January 2013 this block did not have the WHERE input.
115 | var where = block.getFieldValue('WHERE') || 'FROM_START';
116 | var text = Blockly.Python.valueToCode(block, 'VALUE',
117 | Blockly.Python.ORDER_MEMBER) || '\'\'';
118 | switch (where) {
119 | case 'FIRST':
120 | var code = text + '[0]';
121 | return [code, Blockly.Python.ORDER_MEMBER];
122 | case 'LAST':
123 | var code = text + '[-1]';
124 | return [code, Blockly.Python.ORDER_MEMBER];
125 | case 'FROM_START':
126 | var at = Blockly.Python.getAdjustedInt(block, 'AT');
127 | var code = text + '[' + at + ']';
128 | return [code, Blockly.Python.ORDER_MEMBER];
129 | case 'FROM_END':
130 | var at = Blockly.Python.getAdjustedInt(block, 'AT', 1, true);
131 | var code = text + '[' + at + ']';
132 | return [code, Blockly.Python.ORDER_MEMBER];
133 | case 'RANDOM':
134 | Blockly.Python.definitions_['import_random'] = 'import random';
135 | var functionName = Blockly.Python.provideFunction_(
136 | 'text_random_letter',
137 | ['def ' + Blockly.Python.FUNCTION_NAME_PLACEHOLDER_ + '(text):',
138 | ' x = int(random.random() * len(text))',
139 | ' return text[x];']);
140 | code = functionName + '(' + text + ')';
141 | return [code, Blockly.Python.ORDER_FUNCTION_CALL];
142 | }
143 | throw 'Unhandled option (text_charAt).';
144 | };
145 |
146 | Blockly.Python['text_getSubstring'] = function(block) {
147 | // Get substring.
148 | var where1 = block.getFieldValue('WHERE1');
149 | var where2 = block.getFieldValue('WHERE2');
150 | var text = Blockly.Python.valueToCode(block, 'STRING',
151 | Blockly.Python.ORDER_MEMBER) || '\'\'';
152 | switch (where1) {
153 | case 'FROM_START':
154 | var at1 = Blockly.Python.getAdjustedInt(block, 'AT1');
155 | if (at1 == '0') {
156 | at1 = '';
157 | }
158 | break;
159 | case 'FROM_END':
160 | var at1 = Blockly.Python.getAdjustedInt(block, 'AT1', 1, true);
161 | break;
162 | case 'FIRST':
163 | var at1 = '';
164 | break;
165 | default:
166 | throw 'Unhandled option (text_getSubstring)';
167 | }
168 | switch (where2) {
169 | case 'FROM_START':
170 | var at2 = Blockly.Python.getAdjustedInt(block, 'AT2', 1);
171 | break;
172 | case 'FROM_END':
173 | var at2 = Blockly.Python.getAdjustedInt(block, 'AT2', 0, true);
174 | // Ensure that if the result calculated is 0 that sub-sequence will
175 | // include all elements as expected.
176 | if (!Blockly.isNumber(String(at2))) {
177 | Blockly.Python.definitions_['import_sys'] = 'import sys';
178 | at2 += ' or sys.maxsize';
179 | } else if (at2 == '0') {
180 | at2 = '';
181 | }
182 | break;
183 | case 'LAST':
184 | var at2 = '';
185 | break;
186 | default:
187 | throw 'Unhandled option (text_getSubstring)';
188 | }
189 | var code = text + '[' + at1 + ' : ' + at2 + ']';
190 | return [code, Blockly.Python.ORDER_MEMBER];
191 | };
192 |
193 | Blockly.Python['text_changeCase'] = function(block) {
194 | // Change capitalization.
195 | var OPERATORS = {
196 | 'UPPERCASE': '.upper()',
197 | 'LOWERCASE': '.lower()',
198 | 'TITLECASE': '.title()'
199 | };
200 | var operator = OPERATORS[block.getFieldValue('CASE')];
201 | var text = Blockly.Python.valueToCode(block, 'TEXT',
202 | Blockly.Python.ORDER_MEMBER) || '\'\'';
203 | var code = text + operator;
204 | return [code, Blockly.Python.ORDER_FUNCTION_CALL];
205 | };
206 |
207 | Blockly.Python['text_trim'] = function(block) {
208 | // Trim spaces.
209 | var OPERATORS = {
210 | 'LEFT': '.lstrip()',
211 | 'RIGHT': '.rstrip()',
212 | 'BOTH': '.strip()'
213 | };
214 | var operator = OPERATORS[block.getFieldValue('MODE')];
215 | var text = Blockly.Python.valueToCode(block, 'TEXT',
216 | Blockly.Python.ORDER_MEMBER) || '\'\'';
217 | var code = text + operator;
218 | return [code, Blockly.Python.ORDER_FUNCTION_CALL];
219 | };
220 |
221 | Blockly.Python['text_print'] = function(block) {
222 | // Print statement.
223 | var msg = Blockly.Python.valueToCode(block, 'TEXT',
224 | Blockly.Python.ORDER_NONE) || '\'\'';
225 | return 'print(' + msg + ')\n';
226 | };
227 |
228 | Blockly.Python['text_prompt_ext'] = function(block) {
229 | // Prompt function.
230 | var functionName = Blockly.Python.provideFunction_(
231 | 'text_prompt',
232 | ['def ' + Blockly.Python.FUNCTION_NAME_PLACEHOLDER_ + '(msg):',
233 | ' try:',
234 | ' return raw_input(msg)',
235 | ' except NameError:',
236 | ' return input(msg)']);
237 | if (block.getField('TEXT')) {
238 | // Internal message.
239 | var msg = Blockly.Python.quote_(block.getFieldValue('TEXT'));
240 | } else {
241 | // External message.
242 | var msg = Blockly.Python.valueToCode(block, 'TEXT',
243 | Blockly.Python.ORDER_NONE) || '\'\'';
244 | }
245 | var code = functionName + '(' + msg + ')';
246 | var toNumber = block.getFieldValue('TYPE') == 'NUMBER';
247 | if (toNumber) {
248 | code = 'float(' + code + ')';
249 | }
250 | return [code, Blockly.Python.ORDER_FUNCTION_CALL];
251 | };
252 |
253 | Blockly.Python['text_prompt'] = Blockly.Python['text_prompt_ext'];
254 |
--------------------------------------------------------------------------------
/Arduino/BROBOT_EVO2/OSC.ino:
--------------------------------------------------------------------------------
1 | // BROBOT EVO 2 by JJROBOTS
2 | // SELF BALANCE ARDUINO ROBOT WITH STEPPER MOTORS
3 | // License: GPL v2
4 | // OSC functions (OSC = Open Sound Control protocol)
5 |
6 | // OSC Messages read: OSC: /page/command parameters
7 | // FADER (1,2,3,4) Ex: /1/fader1 f, XXXX => lenght:20, Param: float (0.0-1.0)
8 | // XY (1,2) Ex: /1/xy1 f,f, XXXXXXXX => length: 24 Params: float,float (0.0-1.0)
9 | // PUSH (1,2,3,4) Ex: /1/push1 f, XXXX => length:20 Param: float
10 | // TOGGLE (1,2,3,4) Ex: /1/toggle1 f, XXXX => length:20 Param: float
11 | // MOVE Ex: /1/m XXXX XXXX XXXX => length:16 Params: speed, steps1, steps2 (all float)
12 | //
13 | // OSC Message send:
14 | // string to send + param (float)[last 4 bytes]
15 |
16 |
17 | // for DEBUG uncomment this lines...
18 | //#define OSCDEBUG 0
19 |
20 |
21 | char UDPBuffer[8]; // input message buffer
22 |
23 | // OSC message internal variables
24 | unsigned char OSCreadStatus;
25 | unsigned char OSCreadCounter;
26 | unsigned char OSCreadNumParams;
27 | unsigned char OSCcommandType;
28 | unsigned char OSCtouchMessage;
29 |
30 |
31 | // ------- OSC functions -----------------------------------------
32 |
33 | // Aux functions
34 | float OSC_extractParamFloat(uint8_t pos) {
35 | union {
36 | unsigned char Buff[4];
37 | float d;
38 | } u;
39 |
40 | u.Buff[0] = (unsigned char)UDPBuffer[pos];
41 | u.Buff[1] = (unsigned char)UDPBuffer[pos + 1];
42 | u.Buff[2] = (unsigned char)UDPBuffer[pos + 2];
43 | u.Buff[3] = (unsigned char)UDPBuffer[pos + 3];
44 | return (u.d);
45 | }
46 |
47 | int16_t OSC_extractParamInt(uint8_t pos) {
48 | union {
49 | unsigned char Buff[2];
50 | int16_t d;
51 | } u;
52 |
53 | u.Buff[1] = (unsigned char)UDPBuffer[pos];
54 | u.Buff[0] = (unsigned char)UDPBuffer[pos + 1];
55 | return (u.d);
56 | }
57 |
58 |
59 | void OSC_init()
60 | {
61 | OSCreadStatus = 0;
62 | OSCreadCounter = 0;
63 | OSCreadNumParams = 0;
64 | OSCcommandType = 0;
65 | OSCfader[0] = 0.5;
66 | OSCfader[1] = 0.5;
67 | OSCfader[2] = 0.5;
68 | OSCfader[3] = 0.5;
69 | }
70 |
71 | void OSC_MsgSend(char *c, unsigned char msgSize, float p)
72 | {
73 | uint8_t i;
74 | union {
75 | unsigned char Buff[4];
76 | float d;
77 | } u;
78 |
79 | // We copy the param in the last 4 bytes
80 | u.d = p;
81 | c[msgSize - 4] = u.Buff[3];
82 | c[msgSize - 3] = u.Buff[2];
83 | c[msgSize - 2] = u.Buff[1];
84 | c[msgSize - 1] = u.Buff[0];
85 | for (i = 0; i < msgSize; i++)
86 | {
87 | Serial1.write((uint8_t)c[i]);
88 | //Serial.write((uint8_t)c[i]);
89 | }
90 | }
91 |
92 | void OSC_MsgRead()
93 | {
94 | uint8_t i;
95 | uint8_t tmp;
96 | float value;
97 | float value2;
98 |
99 | // New bytes available to process?
100 | if (Serial1.available() > 0) {
101 | // We rotate the Buffer (we could implement a ring buffer in future)
102 | for (i = 7; i > 0; i--) {
103 | UDPBuffer[i] = UDPBuffer[i - 1];
104 | }
105 | UDPBuffer[0] = Serial1.read();
106 | #ifdef OSCDEBUG3
107 | Serial.print(UDPBuffer[0]);
108 | #endif
109 | // We look for an OSC message start like /x/
110 | if ((UDPBuffer[0] == '/') && (UDPBuffer[2] == '/') && ((UDPBuffer[1] == '1') || (UDPBuffer[1] == '2'))) {
111 | if (OSCreadStatus == 0) {
112 | OSCpage = UDPBuffer[1] - '0'; // Convert page to int
113 | OSCreadStatus = 1;
114 | OSCtouchMessage = 0;
115 | //Serial.print("$");
116 | #ifdef OSCDEBUG3
117 | Serial.println();
118 | #endif
119 | }
120 | else {
121 | Serial.println("!ERR:osc");
122 | OSCreadStatus = 1;
123 | }
124 | return;
125 | } else if (OSCreadStatus == 1) { // looking for the message type
126 | // Fadder /1/fader1 ,f xxxx
127 | if ((UDPBuffer[3] == 'd') && (UDPBuffer[2] == 'e') && (UDPBuffer[1] == 'r')) {
128 | OSCreadStatus = 2; // Message type detected
129 | OSCreadCounter = 11; // Bytes to read the parameter
130 | OSCreadNumParams = 1; // 1 parameters
131 | OSCcommandType = UDPBuffer[0] - '0';
132 | #ifdef OSCDEBUG2
133 | Serial.print("$FAD1");
134 | Serial.print(OSCcommandType);
135 | Serial.print("$");
136 | #endif
137 | return;
138 | } // end fadder
139 | // MOVE message
140 | if ((UDPBuffer[3] == 'o') && (UDPBuffer[2] == 'v') && (UDPBuffer[1] == 'e')) {
141 | OSCreadStatus = 2; // Message type detected
142 | OSCreadCounter = 8; // Bytes to read the parameters
143 | OSCreadNumParams = 3; // 3 parameters
144 | OSCcommandType = 40;
145 | #ifdef OSCDEBUG2
146 | Serial.print("$MOVE:");
147 | #endif
148 | return;
149 | } // End MOVE message
150 | // XY message
151 | if ((UDPBuffer[2] == 'x') && (UDPBuffer[1] == 'y')) {
152 | OSCreadStatus = 2; // Message type detected
153 | OSCreadCounter = 14; // Bytes to read the parameters
154 | OSCreadNumParams = 2; // 2 parameters
155 | OSCcommandType = 10 + (UDPBuffer[0] - '0');
156 | return;
157 | } // End XY message
158 | // Push message
159 | if ((UDPBuffer[3] == 'u') && (UDPBuffer[2] == 's') && (UDPBuffer[1] == 'h')) {
160 | OSCreadStatus = 2; // Message type detected
161 | OSCreadCounter = 10; // Bytes to read the parameter
162 | OSCreadNumParams = 1; // 1 parameters
163 | OSCcommandType = 20 + (UDPBuffer[0] - '1');
164 | //Serial.println(commandType);
165 | #ifdef OSCDEBUG2
166 | Serial.print("$P"):
167 | Serial.print(UDPBuffer[0] - '1');
168 | Serial.print(":");
169 | #endif
170 | return;
171 | } // end push
172 | // Toggle message
173 | if ((UDPBuffer[3] == 'g') && (UDPBuffer[2] == 'l') && (UDPBuffer[1] == 'e')) {
174 | OSCreadStatus = 2; // Message type detected
175 | OSCreadCounter = 10; // Bytes to read the parameter
176 | OSCreadNumParams = 1; // 1 parameters
177 | OSCcommandType = 30 + (UDPBuffer[0] - '1');
178 | //Serial.println(commandType);
179 | #ifdef OSCDEBUG2
180 | Serial.print("$T"):
181 | Serial.print(UDPBuffer[0] - '1');
182 | Serial.print(":");
183 | #endif
184 | return;
185 | } // end toggle
186 | } else if (OSCreadStatus == 2) {
187 | if ((UDPBuffer[1] == '/') && (UDPBuffer[0] == 'z')) { // Touch up message? (/z) [only on page1]
188 | if ((OSCpage == 1) && (OSCcommandType <= 2)) { // Touchup message only on Fadder1 and Fadder2
189 | OSCtouchMessage = 1;
190 | }
191 | else {
192 | OSCtouchMessage = 0;
193 | OSCreadStatus = 0; //Finish
194 | }
195 | } // Touch message(/z)
196 | OSCreadCounter--; // Reading counter until we reach the Parameter position
197 | if (OSCreadCounter <= 0) {
198 | OSCreadStatus = 0;
199 | OSCnewMessage = 1;
200 | //Serial.println(value);
201 | switch (OSCcommandType) {
202 | case 1:
203 | value = OSC_extractParamFloat(0);
204 | OSCfader[0] = value;
205 | if ((OSCtouchMessage) && (value == 0)) {
206 | OSCfader[0] = 0.5;
207 | //Serial.println("TOUCH_X");
208 | OSC_MsgSend("/1/fader1\0\0\0,f\0\0\0\0\0\0", 20, 0.5);
209 | }
210 | #ifdef OSCDEBUG
211 | Serial.print("$F1:");
212 | Serial.println(OSCfader[0]);
213 | #endif
214 | break;
215 | case 2:
216 | value = OSC_extractParamFloat(0);
217 | OSCfader[1] = value;
218 | if ((OSCtouchMessage) && (value == 0)) {
219 | OSCfader[1] = 0.5;
220 | //Serial.println("TOUCH_Y");
221 | OSC_MsgSend("/1/fader2\0\0\0,f\0\0\0\0\0\0", 20, 0.5);
222 | }
223 | #ifdef OSCDEBUG
224 | Serial.print("$F2:");
225 | Serial.println(OSCfader[1]);
226 | #endif
227 | break;
228 | case 3:
229 | OSCfader[2] = OSC_extractParamFloat(0);
230 | #ifdef OSCDEBUG
231 | Serial.print("$F3:");
232 | Serial.println(OSCfader[2]);
233 | #endif
234 | break;
235 | case 4:
236 | OSCfader[3] = OSC_extractParamFloat(0);
237 | #ifdef OSCDEBUG
238 | Serial.print("$F4:");
239 | Serial.println(OSCfader[3]);
240 | #endif
241 | break;
242 | case 11:
243 | OSCxy1_x = OSC_extractParamFloat(0);
244 | OSCxy1_y = OSC_extractParamFloat(4);
245 | #ifdef OSCDEBUG
246 | Serial.print("$XY1:");
247 | Serial.print(OSCxy1_x);
248 | Serial.print(",");
249 | Serial.println(OSCxy1_y);
250 | #endif
251 | break;
252 | case 12:
253 | OSCxy2_x = OSC_extractParamFloat(0);
254 | OSCxy2_y = OSC_extractParamFloat(4);
255 | #ifdef OSCDEBUG
256 | Serial.print("$XY2:");
257 | Serial.print(OSCxy2_x);
258 | Serial.print(",");
259 | Serial.println(OSCxy2_y);
260 | #endif
261 | break;
262 | case 40:
263 | // MOVE
264 | OSCmove_mode = 1;
265 | OSCmove_speed = OSC_extractParamInt(4);
266 | OSCmove_steps1 = OSC_extractParamInt(2);
267 | OSCmove_steps2 = OSC_extractParamInt(0);
268 | #ifdef OSCDEBUG
269 | Serial.print("$MOVE:");
270 | Serial.print(OSCmove_speed);
271 | Serial.print(",");
272 | Serial.print(OSCmove_steps1);
273 | Serial.print(",");
274 | Serial.println(OSCmove_steps2);
275 | #endif
276 | break;
277 |
278 | default:
279 | // Push y toggle
280 | value = OSC_extractParamFloat(0);
281 | if ((OSCcommandType >= 20) && (OSCcommandType < 25))
282 | {
283 | if (value == 0)
284 | OSCpush[OSCcommandType - 20] = 0;
285 | else
286 | OSCpush[OSCcommandType - 20] = 1;
287 | }
288 | if ((OSCcommandType >= 30) && (OSCcommandType < 35))
289 | {
290 | if (value == 0)
291 | OSCtoggle[OSCcommandType - 30] = 0;
292 | else
293 | OSCtoggle[OSCcommandType - 30] = 1;
294 | }
295 | break;
296 | } // switch
297 | } // if (OSCRead_counter<=0)
298 | } // if (OSCread_status==2)
299 | } // end Serial.available()
300 | }
301 |
302 |
--------------------------------------------------------------------------------
/Blockly/brobot/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2011
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
--------------------------------------------------------------------------------
/Blockly/brobot/generators/python.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @license
3 | * Visual Blocks Language
4 | *
5 | * Copyright 2012 Google Inc.
6 | * https://developers.google.com/blockly/
7 | *
8 | * Licensed under the Apache License, Version 2.0 (the "License");
9 | * you may not use this file except in compliance with the License.
10 | * You may obtain a copy of the License at
11 | *
12 | * http://www.apache.org/licenses/LICENSE-2.0
13 | *
14 | * Unless required by applicable law or agreed to in writing, software
15 | * distributed under the License is distributed on an "AS IS" BASIS,
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 | * See the License for the specific language governing permissions and
18 | * limitations under the License.
19 | */
20 |
21 | /**
22 | * @fileoverview Helper functions for generating Python for blocks.
23 | * @author fraser@google.com (Neil Fraser)
24 | */
25 | 'use strict';
26 |
27 | goog.provide('Blockly.Python');
28 |
29 | goog.require('Blockly.Generator');
30 |
31 |
32 | /**
33 | * Python code generator.
34 | * @type {!Blockly.Generator}
35 | */
36 | Blockly.Python = new Blockly.Generator('Python');
37 |
38 | /**
39 | * List of illegal variable names.
40 | * This is not intended to be a security feature. Blockly is 100% client-side,
41 | * so bypassing this list is trivial. This is intended to prevent users from
42 | * accidentally clobbering a built-in object or function.
43 | * @private
44 | */
45 | Blockly.Python.addReservedWords(
46 | // import keyword
47 | // print ','.join(keyword.kwlist)
48 | // http://docs.python.org/reference/lexical_analysis.html#keywords
49 | 'and,as,assert,break,class,continue,def,del,elif,else,except,exec,' +
50 | 'finally,for,from,global,if,import,in,is,lambda,not,or,pass,print,raise,' +
51 | 'return,try,while,with,yield,' +
52 | //http://docs.python.org/library/constants.html
53 | 'True,False,None,NotImplemented,Ellipsis,__debug__,quit,exit,copyright,' +
54 | 'license,credits,' +
55 | // http://docs.python.org/library/functions.html
56 | 'abs,divmod,input,open,staticmethod,all,enumerate,int,ord,str,any,eval,' +
57 | 'isinstance,pow,sum,basestring,execfile,issubclass,print,super,bin,file,' +
58 | 'iter,property,tuple,bool,filter,len,range,type,bytearray,float,list,' +
59 | 'raw_input,unichr,callable,format,locals,reduce,unicode,chr,frozenset,' +
60 | 'long,reload,vars,classmethod,getattr,map,repr,xrange,cmp,globals,max,' +
61 | 'reversed,zip,compile,hasattr,memoryview,round,__import__,complex,hash,' +
62 | 'min,set,apply,delattr,help,next,setattr,buffer,dict,hex,object,slice,' +
63 | 'coerce,dir,id,oct,sorted,intern'
64 | );
65 |
66 | /**
67 | * Order of operation ENUMs.
68 | * http://docs.python.org/reference/expressions.html#summary
69 | */
70 | Blockly.Python.ORDER_ATOMIC = 0; // 0 "" ...
71 | Blockly.Python.ORDER_COLLECTION = 1; // tuples, lists, dictionaries
72 | Blockly.Python.ORDER_STRING_CONVERSION = 1; // `expression...`
73 | Blockly.Python.ORDER_MEMBER = 2.1; // . []
74 | Blockly.Python.ORDER_FUNCTION_CALL = 2.2; // ()
75 | Blockly.Python.ORDER_EXPONENTIATION = 3; // **
76 | Blockly.Python.ORDER_UNARY_SIGN = 4; // + -
77 | Blockly.Python.ORDER_BITWISE_NOT = 4; // ~
78 | Blockly.Python.ORDER_MULTIPLICATIVE = 5; // * / // %
79 | Blockly.Python.ORDER_ADDITIVE = 6; // + -
80 | Blockly.Python.ORDER_BITWISE_SHIFT = 7; // << >>
81 | Blockly.Python.ORDER_BITWISE_AND = 8; // &
82 | Blockly.Python.ORDER_BITWISE_XOR = 9; // ^
83 | Blockly.Python.ORDER_BITWISE_OR = 10; // |
84 | Blockly.Python.ORDER_RELATIONAL = 11; // in, not in, is, is not,
85 | // <, <=, >, >=, <>, !=, ==
86 | Blockly.Python.ORDER_LOGICAL_NOT = 12; // not
87 | Blockly.Python.ORDER_LOGICAL_AND = 13; // and
88 | Blockly.Python.ORDER_LOGICAL_OR = 14; // or
89 | Blockly.Python.ORDER_CONDITIONAL = 15; // if else
90 | Blockly.Python.ORDER_LAMBDA = 16; // lambda
91 | Blockly.Python.ORDER_NONE = 99; // (...)
92 |
93 | /**
94 | * List of outer-inner pairings that do NOT require parentheses.
95 | * @type {!Array.>}
96 | */
97 | Blockly.Python.ORDER_OVERRIDES = [
98 | // (foo()).bar -> foo().bar
99 | // (foo())[0] -> foo()[0]
100 | [Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_MEMBER],
101 | // (foo())() -> foo()()
102 | [Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_FUNCTION_CALL],
103 | // (foo.bar).baz -> foo.bar.baz
104 | // (foo.bar)[0] -> foo.bar[0]
105 | // (foo[0]).bar -> foo[0].bar
106 | // (foo[0])[1] -> foo[0][1]
107 | [Blockly.Python.ORDER_MEMBER, Blockly.Python.ORDER_MEMBER],
108 | // (foo.bar)() -> foo.bar()
109 | // (foo[0])() -> foo[0]()
110 | [Blockly.Python.ORDER_MEMBER, Blockly.Python.ORDER_FUNCTION_CALL],
111 |
112 | // not (not foo) -> not not foo
113 | [Blockly.Python.ORDER_LOGICAL_NOT, Blockly.Python.ORDER_LOGICAL_NOT],
114 | // a and (b and c) -> a and b and c
115 | [Blockly.Python.ORDER_LOGICAL_AND, Blockly.Python.ORDER_LOGICAL_AND],
116 | // a or (b or c) -> a or b or c
117 | [Blockly.Python.ORDER_LOGICAL_OR, Blockly.Python.ORDER_LOGICAL_OR]
118 | ];
119 |
120 | /**
121 | * Initialise the database of variable names.
122 | * @param {!Blockly.Workspace} workspace Workspace to generate code from.
123 | */
124 | Blockly.Python.init = function(workspace) {
125 | /**
126 | * Empty loops or conditionals are not allowed in Python.
127 | */
128 | Blockly.Python.PASS = this.INDENT + 'pass\n';
129 | // Create a dictionary of definitions to be printed before the code.
130 | Blockly.Python.definitions_ = Object.create(null);
131 | // Create a dictionary mapping desired function names in definitions_
132 | // to actual function names (to avoid collisions with user functions).
133 | Blockly.Python.functionNames_ = Object.create(null);
134 |
135 | if (!Blockly.Python.variableDB_) {
136 | Blockly.Python.variableDB_ =
137 | new Blockly.Names(Blockly.Python.RESERVED_WORDS_);
138 | } else {
139 | Blockly.Python.variableDB_.reset();
140 | }
141 |
142 | var defvars = [];
143 | var variables = workspace.variableList;
144 | for (var i = 0; i < variables.length; i++) {
145 | defvars[i] = Blockly.Python.variableDB_.getName(variables[i],
146 | Blockly.Variables.NAME_TYPE) + ' = None';
147 | }
148 | Blockly.Python.definitions_['variables'] = defvars.join('\n');
149 | };
150 |
151 | /**
152 | * Prepend the generated code with the variable definitions.
153 | * @param {string} code Generated code.
154 | * @return {string} Completed code.
155 | */
156 | Blockly.Python.finish = function(code) {
157 | // Convert the definitions dictionary into a list.
158 | var imports = [];
159 | var definitions = [];
160 | for (var name in Blockly.Python.definitions_) {
161 | var def = Blockly.Python.definitions_[name];
162 | if (def.match(/^(from\s+\S+\s+)?import\s+\S+/)) {
163 | imports.push(def);
164 | } else {
165 | definitions.push(def);
166 | }
167 | }
168 | // Clean up temporary data.
169 | delete Blockly.Python.definitions_;
170 | delete Blockly.Python.functionNames_;
171 | Blockly.Python.variableDB_.reset();
172 | var allDefs = imports.join('\n') + '\n\n' + definitions.join('\n\n');
173 | return allDefs.replace(/\n\n+/g, '\n\n').replace(/\n*$/, '\n\n\n') + code;
174 | };
175 |
176 | /**
177 | * Naked values are top-level blocks with outputs that aren't plugged into
178 | * anything.
179 | * @param {string} line Line of generated code.
180 | * @return {string} Legal line of code.
181 | */
182 | Blockly.Python.scrubNakedValue = function(line) {
183 | return line + '\n';
184 | };
185 |
186 | /**
187 | * Encode a string as a properly escaped Python string, complete with quotes.
188 | * @param {string} string Text to encode.
189 | * @return {string} Python string.
190 | * @private
191 | */
192 | Blockly.Python.quote_ = function(string) {
193 | // Can't use goog.string.quote since % must also be escaped.
194 | string = string.replace(/\\/g, '\\\\')
195 | .replace(/\n/g, '\\\n')
196 | .replace(/\%/g, '\\%')
197 | .replace(/'/g, '\\\'');
198 | return '\'' + string + '\'';
199 | };
200 |
201 | /**
202 | * Common tasks for generating Python from blocks.
203 | * Handles comments for the specified block and any connected value blocks.
204 | * Calls any statements following this block.
205 | * @param {!Blockly.Block} block The current block.
206 | * @param {string} code The Python code created for this block.
207 | * @return {string} Python code with comments and subsequent blocks added.
208 | * @private
209 | */
210 | Blockly.Python.scrub_ = function(block, code) {
211 | var commentCode = '';
212 | // Only collect comments for blocks that aren't inline.
213 | if (!block.outputConnection || !block.outputConnection.targetConnection) {
214 | // Collect comment for this block.
215 | var comment = block.getCommentText();
216 | comment = Blockly.utils.wrap(comment, Blockly.Python.COMMENT_WRAP - 3);
217 | if (comment) {
218 | if (block.getProcedureDef) {
219 | // Use a comment block for function comments.
220 | commentCode += '"""' + comment + '\n"""\n';
221 | } else {
222 | commentCode += Blockly.Python.prefixLines(comment + '\n', '# ');
223 | }
224 | }
225 | // Collect comments for all value arguments.
226 | // Don't collect comments for nested statements.
227 | for (var i = 0; i < block.inputList.length; i++) {
228 | if (block.inputList[i].type == Blockly.INPUT_VALUE) {
229 | var childBlock = block.inputList[i].connection.targetBlock();
230 | if (childBlock) {
231 | var comment = Blockly.Python.allNestedComments(childBlock);
232 | if (comment) {
233 | commentCode += Blockly.Python.prefixLines(comment, '# ');
234 | }
235 | }
236 | }
237 | }
238 | }
239 | var nextBlock = block.nextConnection && block.nextConnection.targetBlock();
240 | var nextCode = Blockly.Python.blockToCode(nextBlock);
241 | return commentCode + code + nextCode;
242 | };
243 |
244 | /**
245 | * Gets a property and adjusts the value, taking into account indexing, and
246 | * casts to an integer.
247 | * @param {!Blockly.Block} block The block.
248 | * @param {string} atId The property ID of the element to get.
249 | * @param {number=} opt_delta Value to add.
250 | * @param {boolean=} opt_negate Whether to negate the value.
251 | * @return {string|number}
252 | */
253 | Blockly.Python.getAdjustedInt = function(block, atId, opt_delta, opt_negate) {
254 | var delta = opt_delta || 0;
255 | if (block.workspace.options.oneBasedIndex) {
256 | delta--;
257 | }
258 | var defaultAtIndex = block.workspace.options.oneBasedIndex ? '1' : '0';
259 | var atOrder = delta ? Blockly.Python.ORDER_ADDITIVE :
260 | Blockly.Python.ORDER_NONE;
261 | var at = Blockly.Python.valueToCode(block, atId, atOrder) || defaultAtIndex;
262 |
263 | if (Blockly.isNumber(at)) {
264 | // If the index is a naked number, adjust it right now.
265 | at = parseInt(at, 10) + delta;
266 | if (opt_negate) {
267 | at = -at;
268 | }
269 | } else {
270 | // If the index is dynamic, adjust it in code.
271 | if (delta > 0) {
272 | at = 'int(' + at + ' + ' + delta + ')';
273 | } else if (delta < 0) {
274 | at = 'int(' + at + ' - ' + -delta + ')';
275 | } else {
276 | at = 'int(' + at + ')';
277 | }
278 | if (opt_negate) {
279 | at = '-' + at;
280 | }
281 | }
282 | return at;
283 | };
284 |
--------------------------------------------------------------------------------
/Blockly/brobot/jquery/jquery-ui.theme.min.css:
--------------------------------------------------------------------------------
1 | /*! jQuery UI - v1.12.1 - 2016-09-14
2 | * http://jqueryui.com
3 | * Copyright jQuery Foundation and other contributors; Licensed MIT */
4 |
5 | .ui-widget{font-family:Arial,Helvetica,sans-serif;font-size:1em}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Arial,Helvetica,sans-serif;font-size:1em}.ui-widget.ui-widget-content{border:1px solid #c5c5c5}.ui-widget-content{border:1px solid #ddd;background:#fff;color:#333}.ui-widget-content a{color:#333}.ui-widget-header{border:1px solid #ddd;background:#e9e9e9;color:#333;font-weight:bold}.ui-widget-header a{color:#333}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default,.ui-button,html .ui-button.ui-state-disabled:hover,html .ui-button.ui-state-disabled:active{border:1px solid #c5c5c5;background:#f6f6f6;font-weight:normal;color:#454545}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited,a.ui-button,a:link.ui-button,a:visited.ui-button,.ui-button{color:#454545;text-decoration:none}.ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus,.ui-button:hover,.ui-button:focus{border:1px solid #ccc;background:#ededed;font-weight:normal;color:#2b2b2b}.ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited,.ui-state-focus a,.ui-state-focus a:hover,.ui-state-focus a:link,.ui-state-focus a:visited,a.ui-button:hover,a.ui-button:focus{color:#2b2b2b;text-decoration:none}.ui-visual-focus{box-shadow:0 0 3px 1px rgb(94,158,214)}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active,a.ui-button:active,.ui-button:active,.ui-button.ui-state-active:hover{border:1px solid #003eff;background:#007fff;font-weight:normal;color:#fff}.ui-icon-background,.ui-state-active .ui-icon-background{border:#003eff;background-color:#fff}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#fff;text-decoration:none}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #dad55e;background:#fffa90;color:#777620}.ui-state-checked{border:1px solid #dad55e;background:#fffa90}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#777620}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #f1a899;background:#fddfdf;color:#5f3f3f}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#5f3f3f}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#5f3f3f}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}.ui-icon{width:16px;height:16px}.ui-icon,.ui-widget-content .ui-icon{background-image:url("images/ui-icons_444444_256x240.png")}.ui-widget-header .ui-icon{background-image:url("images/ui-icons_444444_256x240.png")}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon,.ui-button:hover .ui-icon,.ui-button:focus .ui-icon{background-image:url("images/ui-icons_555555_256x240.png")}.ui-state-active .ui-icon,.ui-button:active .ui-icon{background-image:url("images/ui-icons_ffffff_256x240.png")}.ui-state-highlight .ui-icon,.ui-button .ui-state-highlight.ui-icon{background-image:url("images/ui-icons_777620_256x240.png")}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url("images/ui-icons_cc0000_256x240.png")}.ui-button .ui-icon{background-image:url("images/ui-icons_777777_256x240.png")}.ui-icon-blank{background-position:16px 16px}.ui-icon-caret-1-n{background-position:0 0}.ui-icon-caret-1-ne{background-position:-16px 0}.ui-icon-caret-1-e{background-position:-32px 0}.ui-icon-caret-1-se{background-position:-48px 0}.ui-icon-caret-1-s{background-position:-65px 0}.ui-icon-caret-1-sw{background-position:-80px 0}.ui-icon-caret-1-w{background-position:-96px 0}.ui-icon-caret-1-nw{background-position:-112px 0}.ui-icon-caret-2-n-s{background-position:-128px 0}.ui-icon-caret-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-65px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-65px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:1px -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-on{background-position:-96px -144px}.ui-icon-radio-off{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:3px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:3px}.ui-widget-overlay{background:#aaa;opacity:.003;filter:Alpha(Opacity=.3)}.ui-widget-shadow{-webkit-box-shadow:0 0 5px #666;box-shadow:0 0 5px #666}
--------------------------------------------------------------------------------
/Blockly/brobot/code.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Blockly Demos: Code
3 | *
4 | * Copyright 2012 Google Inc.
5 | * https://developers.google.com/blockly/
6 | *
7 | * Licensed under the Apache License, Version 2.0 (the "License");
8 | * you may not use this file except in compliance with the License.
9 | * You may obtain a copy of the License at
10 | *
11 | * http://www.apache.org/licenses/LICENSE-2.0
12 | *
13 | * Unless required by applicable law or agreed to in writing, software
14 | * distributed under the License is distributed on an "AS IS" BASIS,
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 | * See the License for the specific language governing permissions and
17 | * limitations under the License.
18 | */
19 |
20 |
21 | /**
22 | * @fileoverview JavaScript for Blockly's Code demo.
23 | * @author fraser@google.com (Neil Fraser)
24 | */
25 | 'use strict';
26 |
27 | /**
28 | * Create a namespace for the application.
29 | */
30 | var Code = {};
31 |
32 | Code.Lang = 'en';
33 |
34 | /**
35 | * Lookup for names of supported languages. Keys should be in ISO 639 format.
36 | */
37 | Code.LANGUAGE_NAME = {
38 | 'en': 'English',
39 | };
40 |
41 | /**
42 | * Blockly's main workspace.
43 | * @type {Blockly.WorkspaceSvg}
44 | */
45 | Code.workspace = null;
46 |
47 | /**
48 | * Extracts a parameter from the URL.
49 | * If the parameter is absent default_value is returned.
50 | * @param {string} name The name of the parameter.
51 | * @param {string} defaultValue Value to return if paramater not found.
52 | * @return {string} The parameter value or the default value if not found.
53 | */
54 | Code.getStringParamFromUrl = function(name, defaultValue) {
55 | var val = location.search.match(new RegExp('[?&]' + name + '=([^&]+)'));
56 | return val ? decodeURIComponent(val[1].replace(/\+/g, '%20')) : defaultValue;
57 | };
58 |
59 | /**
60 | * Get the language of this user from the URL.
61 | * @return {string} User's language.
62 | */
63 | Code.getLang = function() {
64 | return 'en';
65 | };
66 |
67 |
68 | /**
69 | * Load blocks saved on App Engine Storage or in session/local storage.
70 | * @param {string} defaultXml Text representation of default blocks.
71 | */
72 | Code.loadBlocks = function(defaultXml) {
73 | try {
74 | var loadOnce = window.sessionStorage.loadOnceBlocks;
75 | } catch(e) {
76 | // Firefox sometimes throws a SecurityError when accessing sessionStorage.
77 | // Restarting Firefox fixes this, so it looks like a bug.
78 | var loadOnce = null;
79 | }
80 | if ('BlocklyStorage' in window && window.location.hash.length > 1) {
81 | // An href with #key trigers an AJAX call to retrieve saved blocks.
82 | BlocklyStorage.retrieveXml(window.location.hash.substring(1));
83 | } else if (loadOnce) {
84 | // Language switching stores the blocks during the reload.
85 | delete window.sessionStorage.loadOnceBlocks;
86 | var xml = Blockly.Xml.textToDom(loadOnce);
87 | Blockly.Xml.domToWorkspace(xml, Code.workspace);
88 | } else if (defaultXml) {
89 | // Load the editor with default starting blocks.
90 | var xml = Blockly.Xml.textToDom(defaultXml);
91 | Blockly.Xml.domToWorkspace(xml, Code.workspace);
92 | } else if ('BlocklyStorage' in window) {
93 | // Restore saved blocks in a separate thread so that subsequent
94 | // initialization is not affected from a failed load.
95 | window.setTimeout(BlocklyStorage.restoreBlocks, 0);
96 | }
97 | };
98 |
99 | /**
100 | * Bind a function to a button's click event.
101 | * On touch enabled browsers, ontouchend is treated as equivalent to onclick.
102 | * @param {!Element|string} el Button element or ID thereof.
103 | * @param {!Function} func Event handler to bind.
104 | */
105 | Code.bindClick = function(el, func) {
106 | if (typeof el == 'string') {
107 | el = document.getElementById(el);
108 | }
109 | el.addEventListener('click', func, true);
110 | el.addEventListener('touchend', func, true);
111 | };
112 |
113 | /**
114 | * Load the Prettify CSS and JavaScript.
115 | */
116 | Code.importPrettify = function() {
117 | //