rgb2hex = function (rgb){
			rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
			return (rgb && rgb.length === 4) ? "#" +
			  ("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
			  ("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
			  ("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
		}
Function: text

Paints the given text. Possible values for format are empty string for
plain text and html for HTML markup. Background and border color as well
as clipping is not available in plain text labels for VML. HTML labels
are not available as part of shapes with no foreignObject support in SVG
(eg. IE9, IE10).

Parameters:

x - Number that represents the x-coordinate of the text.
y - Number that represents the y-coordinate of the text.
w - Number that represents the available width for the text or 0 for automatic width.
h - Number that represents the available height for the text or 0 for automatic height.
str - String that specifies the text to be painted.
align - String that represents the horizontal alignment.
valign - String that represents the vertical alignment.
wrap - Boolean that specifies if word-wrapping is enabled. Requires w > 0.
format - Empty string for plain text or 'html' for HTML markup.
overflow - Specifies the overflow behaviour of the label. Requires w > 0 and/or h > 0.
clip - Boolean that specifies if the label should be clipped. Requires w > 0 and/or h > 0.
rotation - Number that specifies the angle of the rotation around the anchor point of the text.
dir - Optional string that specifies the text direction. Possible values are rtl and lrt.