File tree Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Expand file tree Collapse file tree 3 files changed +92
-0
lines changed Original file line number Diff line number Diff line change @@ -216,6 +216,57 @@ const simpleCircle = {
216
216
'inputsInline' : true ,
217
217
} ;
218
218
219
+ const writeTextWithoutShadow = {
220
+ 'type' : 'write_text_without_shadow' ,
221
+ 'tooltip' : '' ,
222
+ 'helpUrl' : '' ,
223
+ 'message0' : 'write without shadow %1' ,
224
+ 'args0' : [
225
+ {
226
+ 'type' : 'field_input' ,
227
+ 'name' : 'TEXT' ,
228
+ 'text' : 'bit'
229
+ } ,
230
+ ] ,
231
+ 'previousStatement' : null ,
232
+ 'nextStatement' : null ,
233
+ 'colour' : 225
234
+ } ;
235
+
236
+ const writeTextWithShadow = {
237
+ 'type' : 'write_text_with_shadow' ,
238
+ 'tooltip' : '' ,
239
+ 'helpUrl' : '' ,
240
+ 'message0' : 'write with shadow %1' ,
241
+ 'args0' : [
242
+ {
243
+ 'type' : 'input_value' ,
244
+ 'name' : 'TEXT' ,
245
+ 'check' : 'String'
246
+ }
247
+ ] ,
248
+ 'previousStatement' : null ,
249
+ 'nextStatement' : null ,
250
+ 'colour' : 225
251
+ } ;
252
+
253
+ const textBlock =
254
+ {
255
+ 'type' : 'text_only' ,
256
+ 'tooltip' : '' ,
257
+ 'helpUrl' : '' ,
258
+ 'message0' : '%1' ,
259
+ 'args0' : [
260
+ {
261
+ 'type' : 'field_input' ,
262
+ 'name' : 'TEXT' ,
263
+ 'text' : 'micro'
264
+ } ,
265
+ ] ,
266
+ 'output' : 'String' ,
267
+ 'colour' : 225
268
+ } ;
269
+
219
270
// Create the block definitions for all the JSON-only blocks.
220
271
// This does not register their definitions with Blockly.
221
272
const jsonBlocks = Blockly . common . createBlockDefinitionsFromJsonArray ( [
@@ -225,6 +276,9 @@ const jsonBlocks = Blockly.common.createBlockDefinitionsFromJsonArray([
225
276
ellipse ,
226
277
draw_emoji ,
227
278
simpleCircle ,
279
+ writeTextWithoutShadow ,
280
+ writeTextWithShadow ,
281
+ textBlock
228
282
] ) ;
229
283
230
284
export const blocks = {
Original file line number Diff line number Diff line change @@ -80,3 +80,26 @@ sketch.stroke(${color});
80
80
sketch.ellipse(150, 150, 50, 50);` ;
81
81
return code ;
82
82
} ;
83
+
84
+ forBlock [ 'text_only' ] = function ( block , generator ) {
85
+ const code = generator . quote_ ( block . getFieldValue ( 'TEXT' ) ) ;
86
+ return [ code , Order . ATOMIC ] ;
87
+ } ;
88
+
89
+ forBlock [ 'write_text_with_shadow' ] = function ( block , generator ) {
90
+ const text = generator . valueToCode ( block , 'TEXT' , Order . ATOMIC ) || `''` ;
91
+ const code = `\nsketch.stroke(0x000000);
92
+ sketch.fill(0x000000);
93
+ sketch.textSize(100);
94
+ sketch.text(${ text } , 50, 350);\n` ;
95
+ return code ;
96
+ } ;
97
+
98
+ forBlock [ 'write_text_without_shadow' ] = function ( block , generator ) {
99
+ const text = generator . quote_ ( block . getFieldValue ( 'TEXT' ) ) ;
100
+ const code = `\nsketch.stroke(0x000000);
101
+ sketch.fill(0x000000);
102
+ sketch.textSize(100);
103
+ sketch.text(${ text } , 50, 350);\n` ;
104
+ return code ;
105
+ } ;
Original file line number Diff line number Diff line change @@ -37,5 +37,20 @@ export const toolbox = {
37
37
} ,
38
38
} ,
39
39
} ,
40
+ {
41
+ kind : 'block' ,
42
+ type : 'write_text_with_shadow' ,
43
+ inputs : {
44
+ TEXT : {
45
+ shadow : {
46
+ type : 'text_only' ,
47
+ } ,
48
+ } ,
49
+ } ,
50
+ } ,
51
+ {
52
+ kind : 'block' ,
53
+ type : 'write_text_without_shadow' ,
54
+ } ,
40
55
] ,
41
56
} ;
You can’t perform that action at this time.
0 commit comments