Actually draw the title block on the canvas
547822
function() {
		var me = this;
		var ctx = me.ctx;
		var opts = me.options;

		if (opts.display) {
			var fontOpts = helpers.options._parseFont(opts);
			var lineHeight = fontOpts.lineHeight;
			var offset = lineHeight / 2 + opts.padding;
			var rotation = 0;
			var top = me.top;
			var left = me.left;
			var bottom = me.bottom;
			var right = me.right;
			var maxWidth, titleX, titleY;

			ctx.fillStyle = helpers.valueOrDefault(opts.fontColor, defaults.global.defaultFontColor); // render in correct colour
			ctx.font = fontOpts.string;

			// Horizontal
			if (me.isHorizontal()) {
				titleX = left + ((right - left) / 2); // midpoint of the width
				titleY = top + offset;
				maxWidth = right - left;
			} else {
				titleX = opts.position === 'left' ? left + offset : right - offset;
				titleY = top + ((bottom - top) / 2);
				maxWidth = bottom - top;
				rotation = Math.PI * (opts.position === 'left' ? -0.5 : 0.5);
			}

			ctx.save();
			ctx.translate(titleX, titleY);
			ctx.rotate(rotation);
			ctx.textAlign = 'center';
			ctx.textBaseline = 'middle';

			var text = opts.text;
			if (helpers.isArray(text)) {
				var y = 0;
				for (var i = 0; i < text.length; ++i) {
					ctx.fillText(text[i], 0, y, maxWidth);
					y += lineHeight;
				}
			} else {
				ctx.fillText(text, 0, 0, maxWidth);
			}

			ctx.restore();
		}
	}
1270083
function(visible) {
            Kinetic.Node.prototype.setVisible.call(this, visible);
            if(visible) {
                this.getCanvas()._canvas.style.display = 'block';
            }
            else {
                this.getCanvas()._canvas.style.display = 'none';
            }
            return this;
        }
656051
function() {
            var offset = IMSoftcrop.Ratio.getElementPosition(this._canvas);

            this._position.x = offset.x;
            this._position.y = offset.y;
        }
1322834
function drawAnimatedHorizontalBars(bars) {
            // Enter + Update
            bars.enter()
              .append('rect')
                .classed('bar', true)
                .attr('x', 0)
                .attr('y', chartHeight)
                .attr('height', yScale.bandwidth())
                .attr('width', ({value}) => xScale(value))
                .on('mouseover', function(d, index, barList) {
                    handleMouseOver(this, d, barList, chartWidth, chartHeight);
                })
                .on('mousemove', function(d) {
                    handleMouseMove(this, d, chartWidth, chartHeight);
                })
                .on('mouseout', function(d, index, barList) {
                    handleMouseOut(this, d, barList, chartWidth, chartHeight);
                })
                .on('click', function(d) {
                    handleClick(this, d, chartWidth, chartHeight);
                });

            bars
                .attr('x', 0)
                .attr('y', ({name}) => yScale(name))
                .attr('height', yScale.bandwidth())
                .attr('fill', ({name}) => computeColor(name))
                .transition()
                .duration(animationDuration)
                .delay(interBarDelay)
                .ease(ease)
                .attr('width', ({value}) => xScale(value));
        }
960072
private function drawCapatchaImageText()
	{
		
		#	Create Image Text
	
		# here we will first create background text, then front text
		# we will set x- position
		# initial front text position 'initial_x'
		# current position 'current_x'
		
		$this->_front_text['initial_x'] = $this->_front_text['x'] = rand( 10, 25 );
		
		# Background Text
		# X, Y positions
		
		$this->_background_text['x'] = $this->_front_text['x'] / 2;
		$this->_background_text['y'] = ( $this->_calculated_text_box['dimensions']['height'] ) + ( $this->_calculated_text_box['additional_height'] / 2 );

		// Developing::preview( $this->_calculated_text_box['additional_height'], $this->_image_info['height'] - $this->_calculated_text_box['dimensions']['height'] );
		
		$characters = str_split( $this->_code, 1 );
		
		# Generating background text By Drawing letter by letter
		foreach( $characters as $char )
		{
			# character rotation angle
			$rotation_angle = rand( 0 - $this->_rotation_angle, $this->_rotation_angle );

			# get color rgb values
			$rgb = $this->getRGBFromRange(
				$this->_background_text['color'][0],
				$this->_background_text['color'][1],
				$this->_background_text['color'][2],
				$this->_background_text['color']['range']
				);
			
			$character_color = imagecolorallocatealpha(
				$this->_image_resource,
				$rgb[0],
				$rgb[1],
				$rgb[2],
				$this->_background_text['color'][3]
				);

			# check to add the blocks seperation distance
			if( $char === ' ' )
				$this->_background_text['x'] += $this->_blocks_seperation;
			
			# Draw Character to the image
			imagettftext(
				$this->_image_resource,					# Image resource
				$this->_background_text['size'],		# Font Size
				$rotation_angle,						# Text Angle
				$this->_background_text['x'],			# X Position
				$this->_background_text['y'],			# Y Position
				$character_color,						# Color
				$this->_background_text['font'],		# Font
				$char 									# Text
				);
			
			# move x to the next position			
			// $this->_background_text['x'] += $this->getTextBoxDimensions(
			// 	$this->_background_text['size'],
			// 	$rotation_angle,
			// 	$this->_background_text['font'],
			// 	$char
			// 	)['width'];

			$box_dimension = $this->getTextBoxDimensions(
				$this->_background_text['size'],
				$rotation_angle,
				$this->_background_text['font'],
				$char
				);

			$this->_background_text['x'] += $box_dimension['width'];
			

			# Method End
		}
		
		
		# space between characters equal 1/4  average character width
		$space_between_chars = $this->_calculated_text_box['char_width'] / 4;

		# final character index
		$final_character_index = $this->_code_length - 1;
		
		
		# Front Text
		foreach( $characters as $index => $char )
		{
			
			# the same as background text
			
			$rotation_angle = rand( 0 - $this->_rotation_angle, $this->_rotation_angle );
			
			# get color rgb values
			$rgb = $this->getRGBFromRange(
				$this->_front_text['color'][0],
				$this->_front_text['color'][1],
				$this->_front_text['color'][2],
				$this->_front_text['color']['range']
				);

			$character_color = imagecolorallocatealpha(
				$this->_image_resource,
				$rgb[0],
				$rgb[1],
				$rgb[2],
				$this->_front_text['color'][3]
				);

			# Calculate Character Dimensions
			$character_box = $this->getTextBoxDimensions(
				$this->_front_text['size'],
				$rotation_angle,
				$this->_front_text['font'],
				$char
				);

			# # calculate y position
			// $this->_front_text['y'] = ( $character_box['height'] - abs( $character_box['points'][1] ) ) + ( ( $this->_image_info['height'] - $character_box['height'] ) / 2 );
			// Developing::preview( 'index' . $index . ': ' . ( $character_box['height'] - abs( $character_box['points'][1] ) ), 'index' . $index . ': ' . $character_box['points'][5] );
			// exit;
			
			$this->_front_text['y'] = abs( $character_box['height'] ) + ( ( $this->_image_info['height'] - $character_box['height'] ) / 2 ) ; 
			
			# check to add the blocks seperation distance
			if( $char === ' ' )
				$this->_front_text['x'] += $this->_blocks_seperation;
			
			
			# Draw Character To Image
			imagettftext(
						 $this->_image_resource,
						 $this->_front_text['size'],
						 $rotation_angle,
						 $this->_front_text['x'],
						 $this->_front_text['y'],
						 $character_color,
						 $this->_front_text['font'],
						 $char
						);
			
			$this->_front_text['x'] += $character_box['width'];
			
			$this->_front_text['x'] += ( $index !== $final_character_index ) ? $space_between_chars : null;
		
		}

		# Method End	
	}
606276
def draw(self):
        
        self.screen.printf(self.formatter.format(title=self.title, subtitle=self.subtitle, items=self.items,
                                                 prologue_text=self.prologue_text, epilogue_text=self.epilogue_text))
569544
def paintEvent(self, event):
        """"""
        painter = QPainter(self)

        color = QColor(self.color)
        color.setAlphaF(.5)
        painter.setPen(color)
        offset = self.editor.document().documentMargin() + \
            self.editor.contentOffset().x()

        for _, line_number, block in self.editor.visible_blocks:

            indentation = TextBlockHelper.get_fold_lvl(block)
            ref_lvl = indentation
            block = block.next()
            last_line = block.blockNumber()
            lvl = TextBlockHelper.get_fold_lvl(block)
            if ref_lvl == lvl:  # for zone set programmatically such as imports
                # in pyqode.python
                ref_lvl -= 1

            while (block.isValid() and
                   TextBlockHelper.get_fold_lvl(block) > ref_lvl):
                last_line = block.blockNumber()
                block = block.next()

            end_of_sub_fold = block
            if last_line:
                block = block.document().findBlockByNumber(last_line)
                while ((block.blockNumber()) and (block.text().strip() == ''
                       or block.text().strip().startswith('#'))):
                    block = block.previous()
                    last_line = block.blockNumber()

            block = self.editor.document().findBlockByNumber(line_number)
            top = int(self.editor.blockBoundingGeometry(block).translated(
                self.editor.contentOffset()).top())
            bottom = top + int(self.editor.blockBoundingRect(block).height())

            indentation = TextBlockHelper.get_fold_lvl(block)

            for i in range(1, indentation):
                if (line_number > last_line and
                        TextBlockHelper.get_fold_lvl(end_of_sub_fold) <= i):
                    continue
                else:
                    x = self.editor.fontMetrics().width(i * self.i_width *
                                                        '9') + offset
                    painter.drawLine(x, top, x, bottom)
793278
function drawCaptions(node) {
      ctx.save();
      var x = node.offset.x;
      var y = node.offset.y;
      ctx.translate(x, y);

      var tm = node.textMetrics;
      var caption = node.getCaption();
      var font = node.text.font;

      // ctx.strokeStyle = "#CCC";
      // ctx.strokeRect(0, 0, tm.width, tm.height);

      ctx.font = font.style + " " + font.weight + " " + font.size
          + "px sans-serif";

      var captionX = tm.width / 2;
      var captionY = 0;
      if (node.isRoot()) {
        // TODO remove magic numbers
        captionX = 0;
        captionY = 20;

        // root box
        ctx.lineWidth = 5.0;
        ctx.strokeStyle = "orange";
        ctx.fillStyle = "white";
        mindmaps.CanvasDrawingUtil.roundedRect(ctx,
            0 - tm.width / 2 - 4, 20 - 4, tm.width + 8,
            tm.height + 8, 10);
      }

      ctx.strokeStyle = font.color;
      ctx.fillStyle = font.color;

      // TODO underline manually. canvas doesnt support it
      // TODO strike through manually

      function checkLength(str) {
        var ctm = ctx.measureText(str);
        return ctm.width <= tm.width;
      }

      // write node caption.

      if (checkLength(caption)) {
        // easy part only one line
        ctx.fillText(caption, captionX, captionY);
      } else {
        /**
         * caption consists of multiple lines. needs special handling
         * that imitates the line breaking algorithm "word-wrap:
         * break-word;"
         * 
         * <pre>
         * 1. break up string into words
         * 2. cut words that are too long into smaller pieces so they fit on a line
         * 3. construct lines: fit as many words as possible on a line
         * 4. print lines
         * </pre>
         */

        /**
         * step 1
         */
        // check all words and break words that are too long for a one
        // line
        // TODO not perfect yet
        // find words in string (special treatment for hyphens)
        // a hyphen breaks like a white-space does
        // var regex = /(\w+-+)|(\w+)|(-+)/gi;
        // var regex = /[^- ]+[- ]*/gi;
        // var regex = /[^ -]+-* *|[- ]+/gi;
        // for now just match for words and the trailing space
        // hyphenating has probably be done in step 2
        var regex = /[^ ]+ */gi;
        var words1 = caption.match(regex);
        console.log("words1", words1);

        /**
         * step 2
         */
        var words2 = [];
        words1.forEach(function(word) {
          if (!checkLength(word)) {
            var part = "";
            for ( var i = 0; i < word.length; i++) {
              var c = word.charAt(i);
              if (checkLength(part + c)) {
                part += c;
                continue;
              } else {
                words2.push(part);
                part = c;
              }
            }
            words2.push(part);
          } else {
            words2.push(word);
          }
        });

        console.log("words2", words2);

        /**
         * step 3
         */
        var wordWidth = function(str) {
          return ctx.measureText(str).width;
        };

        var lines = [];
        var line = "";
        var lineWidth = tm.width;

        // construct invidual lines
        words2.forEach(function(word) {
          if (line === "") {
            line = word;
          } else {
            if (wordWidth(line + " " + word) > lineWidth) {
              lines.push(line);
              line = word;
            } else {
              line += " " + word;
            }
          }
        });
        lines.push(line);
        console.log("lines", lines);

        /**
         * step 4
         */
        // print lines
        for ( var j = 0; j < lines.length; j++) {
          var line = lines[j];
          ctx.fillText(line, captionX, captionY + j * font.size);
        }
      }

      node.forEachChild(function(child) {
        drawCaptions(child);
      });

      ctx.restore();
    }
9320
function drawHandles() {
            let handleFillColor = colorHelper.colorSchemasHuman.grey[1];

            // Styling
            handle = chartBrush
                        .selectAll('.handle.brush-rect')
                        .style('fill', handleFillColor);
        }
656024
function() {
    this.setColour(Blockly.Blocks.logic.HUE);
    this.appendDummyInput()
        .appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF);
    this.setPreviousStatement(true);
    this.setNextStatement(true);
    this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP);
    this.contextMenu = false;
  }
288390
def draw_rect(opts = {})
      x = opts[:top_left][0]
      y = opts[:top_left][1]
      width = opts[:width]
      height = opts[:height]
      color = opts[:color]

      `#{@canvas.context}.fillStyle = #{color}`
      `#{@canvas.context}.fillRect(#{x}, #{y}, #{width}, #{height})`
    end
1274034
function() {
    this.setColour(Blockly.Blocks.logic.HUE);
    this.appendDummyInput()
        .appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF);
    this.setNextStatement(true);
    this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP);
    this.contextMenu = false;
  }
431529
function() {
    this.jsonInit({
      "message0": Blockly.Msg.TEXT_ISEMPTY_TITLE,
      "args0": [
        {
          "type": "input_value",
          "name": "VALUE",
          "check": ['String', 'Array']
        }
      ],
      "output": 'Boolean',
      "colour": Blockly.Blocks.texts.HUE,
      "tooltip": Blockly.Msg.TEXT_ISEMPTY_TOOLTIP,
      "helpUrl": Blockly.Msg.TEXT_ISEMPTY_HELPURL
    });
  }
308107
function() {
        var c = this._canvas;
        c.width = Crafty.viewport.width;
        c.height = Crafty.viewport.height;

        var gl = this.context;
        gl.viewportWidth = c.width;
        gl.viewportHeight = c.height;
    }
163794
function () {
		var options = this.options,
			padding = this.padding,
			titleOptions = options.title,
			titleHeight = 0,
			bBox;
		
		if (titleOptions.text) {
			if (!this.title) {
				this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, null, null, 'legend-title')
					.attr({ zIndex: 1 })
					.css(titleOptions.style)
					.add(this.group);
			}
			bBox = this.title.getBBox();
			titleHeight = bBox.height;
			this.offsetWidth = bBox.width; // #1717
			this.contentGroup.attr({ translateY: titleHeight });
		}
		this.titleHeight = titleHeight;
	}
206779
def _draw_fold_region_background(self, block, painter):
        
        r = FoldScope(block)
        th = TextHelper(self.editor)
        start, end = r.get_range(ignore_blank_lines=True)
        if start > 0:
            top = th.line_pos_from_number(start)
        else:
            top = 0
        bottom = th.line_pos_from_number(end + 1)
        h = bottom - top
        if h == 0:
            h = self.sizeHint().height()
        w = self.sizeHint().width()
        self._draw_rect(QRectF(0, top, w, h), painter)
57899
def show(self, ax:plt.Axes, **kwargs):
        ""
        ax.set_title(str(self))