Содержание

Слайд 2

Тело

Blockly.Language.webgl_a09_body = {
category: 'WebGL',
helpUrl: 'file://localhost/C:/blockly/demos/webgl/webgl_a09_headerhtml5.help.html',
init: function () {

Тело Blockly.Language.webgl_a09_body = { category: 'WebGL', helpUrl: 'file://localhost/C:/blockly/demos/webgl/webgl_a09_headerhtml5.help.html', init: function () {
this.setColour(65);
this.appendStatementInput("BODY")
.appendTitle("Body");
this.appendStatementInput("NAME");
this.appendStatementInput("NAME");
this.appendDummyInput()
.appendTitle("canvas id=")
.appendTitle(new Blockly.FieldTextInput("canv"), "canv")
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip('');
}
};
Blockly.JavaScript.webgl_a09_body = function() {
var statements_body = Blockly.JavaScript.statementToCode(this, 'BODY');
var statements_name = Blockly.JavaScript.statementToCode(this, 'NAME');
var statements_name = Blockly.JavaScript.statementToCode(this, 'NAME');
var code = '<body><"'+statements_body+'"></body>\n';
return code;
};

Слайд 3

Blockly.Language.webgl_a09_header = {
category: 'WebGL',
helpUrl: 'file://localhost/C:/blockly/demos/webgl/webgl_a09_headerhtml5.help.html',
init: function() {
this.setColour(65);
this.appendStatementInput("HEADER")

Blockly.Language.webgl_a09_header = { category: 'WebGL', helpUrl: 'file://localhost/C:/blockly/demos/webgl/webgl_a09_headerhtml5.help.html', init: function() { this.setColour(65); this.appendStatementInput("HEADER")
.appendTitle("Header");
this.setOutput(true);
this.setTooltip('');
}
};
Blockly.JavaScript.webgl_a09_header = function() {
var statements_header = Blockly.JavaScript.statementToCode(this, 'HEADER');
// TODO: Assemble JavaScript into code variable.
var code = '\n<header>\n' + value_header + '\n</header>'
// TODO: Change ORDER_NONE to the correct strength.
return [code, Blockly.JavaScript.ORDER_NONE];
};

Голова

Слайд 4

Заголовок

Blockly.Language.webgl_a09_title = {
category: 'WebGL',
helpUrl: 'file://localhost/C:/blockly/demos/webgl/webgl_a09_headerhtml5.help.html',
init: function() {
this.setColour(160);
this.appendDummyInput()
.appendTitle("title")

Заголовок Blockly.Language.webgl_a09_title = { category: 'WebGL', helpUrl: 'file://localhost/C:/blockly/demos/webgl/webgl_a09_headerhtml5.help.html', init: function() { this.setColour(160);
.appendTitle(new Blockly.FieldTextInput("Blockly"), "NAME");
this.setPreviousStatement(true);
this.setNextStatement(true);
//this.appendValueInput("TITLE")
// .appendTitle("Title");
// this.setOutput(true);
this.setTooltip('');
}
};
Blockly.JavaScript.webgl_a09_title = function() {
var value_title = Blockly.JavaScript.valueToCode(this, 'TITLE', Blockly.JavaScript.ORDER_ATOMIC);
// TODO: Assemble JavaScript into code variable.
//var code = '\n<title>\n;' + statements_title + '\n</title>'
var code = "'<title>'" + value_title.toString() +"'< Blockly ></canvas>"
//return [code, Blockly.JavaScript.ORDER_NONE];
return code;
};

Слайд 5

Blockly.Language.a09_img = {
category: 'WebGL',
helpUrl: 'file://localhost/C:/blockly/demos/webgl/webgl_a09_headerhtml5.help.html',
init: function() {
this.setColour(280);
this.appendDummyInput()

Blockly.Language.a09_img = { category: 'WebGL', helpUrl: 'file://localhost/C:/blockly/demos/webgl/webgl_a09_headerhtml5.help.html', init: function() { this.setColour(280); this.appendDummyInput()
.appendTitle("img")
.appendTitle(new Blockly.FieldTextInput("canvas"), "NAME");
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip(''); }
};
Blockly.JavaScript.a09_canvas = function() {
var text_name_canvas = this.getTitleValue('NAME');
var code = "<canvas id='" + text_name_canvas.toString() +"' width=\"120\" height=\"120\" ></canvas>"
canvas_name = text_name_canvas;
return code;
};

Canvas

Слайд 6

Отрисовка круга

Blockly.Language.webgl_a09_circle = {
category: 'WebGL_2d',
helpUrl: '../webgl/webgl_a08_headerhtml5.help.html',
init: function() {
this.setColour(350);

Отрисовка круга Blockly.Language.webgl_a09_circle = { category: 'WebGL_2d', helpUrl: '../webgl/webgl_a08_headerhtml5.help.html', init: function() {
this.appendDummyInput()
.appendTitle(new Blockly.FieldImage("../../media/html1.svg", 64, 48))
.appendTitle("Set coordinates A(x,y)& radius of the round:");
this.appendValueInput("x")
.setCheck(Number)
.setAlign(Blockly.ALIGN_RIGHT)
.appendTitle("x");
this.appendValueInput("y")
.setCheck(Number)
.setAlign(Blockly.ALIGN_RIGHT)
.appendTitle("y");
this.appendValueInput("r")
.setCheck(Number)
.setAlign(Blockly.ALIGN_RIGHT)
.appendTitle("radius");
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setTooltip('');
}
};

Blockly.JavaScript.webgl_a09_circle = function() {
var value_canv_id = Blockly.JavaScript.valueToCode(this, 'canv_id', Blockly.JavaScript.ORDER_ATOMIC);
var value_x = Blockly.JavaScript.valueToCode(this, 'x', Blockly.JavaScript.ORDER_ATOMIC);
var value_y = Blockly.JavaScript.valueToCode(this, 'y', Blockly.JavaScript.ORDER_ATOMIC);
var value_w = Blockly.JavaScript.valueToCode(this, 'radius', Blockly.JavaScript.ORDER_ATOMIC);
// TODO: Assemble JavaScript into code variable.
var code="var ctx = document.getElementById("+ value_canv_id + ").getContext('2d');\n"
code += 'ctx.save();\n';
code += 'ctx.beginPath();\n';
code += 'ctx.translate('+ value_x+',' + value_y+');\n';
code += 'ctx.scale('+value_w +', 1);\n';
code += "\n gl.arc(" + parseInt(text_x) + ", "+parseInt(text_y)+", "+parseInt(text_radius)+", 0, 2 * Math.PI, false);";
code += 'ctx.restore();\n';
code += 'ctx.closePath();\n';
code += 'ctx.fill();\n';
return code;
};

Слайд 7

html>

Blockly





JavaScript код программы
и ее результат

Имя файла: Blockly.pptx
Количество просмотров: 64
Количество скачиваний: 0