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;
};