Commit 90e3ccb2 authored by Neil Fraser's avatar Neil Fraser

Add Blockly.BlockSvg.START_HAT option.

parent b9929573
This diff is collapsed.
......@@ -851,6 +851,28 @@ Blockly.BlockSvg.NOTCH_WIDTH = 30;
* @const
*/
Blockly.BlockSvg.CORNER_RADIUS = 8;
/**
* Do blocks with no previous or output connections have a 'hat' on top?
* @const
*/
Blockly.BlockSvg.START_HAT = false;
/**
* Path of the top hat's curve.
* @const
*/
Blockly.BlockSvg.START_HAT_PATH = 'c 30,-15 70,-15 100,0';
/**
* Path of the top hat's curve's highlight in LTR.
* @const
*/
Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR =
'c 17.8,-9.2 45.3,-14.9 75,-8.7 M 100.5,0.5';
/**
* Path of the top hat's curve's highlight in RTL.
* @const
*/
Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL =
'm 25,-8.7 c 29.7,-6.2 57.2,-0.5 75,8.7';
/**
* Distance from shape edge to intersect with a curved corner at 45 degrees.
* Applies to highlighting on around the inside of a curve.
......@@ -1704,6 +1726,7 @@ Blockly.BlockSvg.prototype.renderCompute_ = function(iconWidth) {
* @private
*/
Blockly.BlockSvg.prototype.renderDraw_ = function(iconWidth, inputRows) {
this.startHat_ = false;
// Should the top and bottom left corners be rounded or square?
if (this.outputConnection) {
this.squareTopLeftCorner_ = true;
......@@ -1717,6 +1740,11 @@ Blockly.BlockSvg.prototype.renderDraw_ = function(iconWidth, inputRows) {
if (prevBlock && prevBlock.getNextBlock() == this) {
this.squareTopLeftCorner_ = true;
}
} else if (Blockly.BlockSvg.START_HAT) {
// No output or previous connection.
this.squareTopLeftCorner_ = true;
this.startHat_ = true;
inputRows.rightEdge = Math.max(inputRows.rightEdge, 100);
}
var nextBlock = this.getNextBlock();
if (nextBlock) {
......@@ -1771,6 +1799,12 @@ Blockly.BlockSvg.prototype.renderDrawTop_ =
if (this.squareTopLeftCorner_) {
steps.push('m 0,0');
highlightSteps.push('m 0.5,0.5');
if (this.startHat_) {
steps.push(Blockly.BlockSvg.START_HAT_PATH);
highlightSteps.push(this.RTL ?
Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL :
Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR);
}
} else {
steps.push(Blockly.BlockSvg.TOP_LEFT_CORNER_START);
highlightSteps.push(this.RTL ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment