src/modules/context2d.js
function (style) {
        var rxRgb = /rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/;
        var rxRgba = /rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/;
        var rxTransparent = /transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/;

        var r, g, b, a;

        if (style.isCanvasGradient === true) {
            style = style.getColor();
        }

        if (!style) {
            return { r: 0, g: 0, b: 0, a: 0, style: style };
        }

        if (rxTransparent.test(style)) {
            r = 0;
            g = 0;
            b = 0;
            a = 0;
        } else {
            var matches = rxRgb.exec(style);
            if (matches !== null) {
                r = parseInt(matches[1]);
                g = parseInt(matches[2]);
                b = parseInt(matches[3]);
                a = 1;
            } else {
                matches = rxRgba.exec(style);
                if (matches !== null) {
                    r = parseInt(matches[1]);
                    g = parseInt(matches[2]);
                    b = parseInt(matches[3]);
                    a = parseFloat(matches[4]);
                } else {
                    a = 1;

                    if (typeof style === "string" && style.charAt(0) !== '#') {
                        var rgbColor = new RGBColor(style);
                        if (rgbColor.ok) {
                            style = rgbColor.toHex();
                        } else {
                            style = '#000000';
                        }
                    }

                    if (style.length === 4) {
                        r = style.substring(1, 2);
                        r += r;
                        g = style.substring(2, 3);
                        g += g;
                        b = style.substring(3, 4);
                        b += b;
                    } else {
                        r = style.substring(1, 3);
                        g = style.substring(3, 5);
                        b = style.substring(5, 7);
                    }
                    r = parseInt(r, 16);
                    g = parseInt(g, 16);
                    b = parseInt(b, 16);
                }
            }
        }
        return { r: r, g: g, b: b, a: a, style: style };
    }
function (style) {
        var rxRgb = /rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/;
        var rxRgba = /rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*([\d.]+)\s*\)/;
        var rxTransparent = /transparent|rgba\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*0+\s*\)/;

        var r, g, b, a;

        if (style.isCanvasGradient === true) {
            style = style.getColor();
        }

        if (!style) {
            return { r: 0, g: 0, b: 0, a: 0, style: style };
        }

        if (rxTransparent.test(style)) {
            r = 0;
            g = 0;
            b = 0;
            a = 0;
        } else {
            var matches = rxRgb.exec(style);
            if (matches !== null) {
                r = parseInt(matches[1]);
                g = parseInt(matches[2]);
                b = parseInt(matches[3]);
                a = 1;
            } else {
                matches = rxRgba.exec(style);
                if (matches !== null) {
                    r = parseInt(matches[1]);
                    g = parseInt(matches[2]);
                    b = parseInt(matches[3]);
                    a = parseFloat(matches[4]);
                } else {
                    a = 1;

                    if (typeof style === "string" && style.charAt(0) !== '#') {
                        var rgbColor = new RGBColor(style);
                        if (rgbColor.ok) {
                            style = rgbColor.toHex();
                        } else {
                            style = '#000000';
                        }
                    }

                    if (style.length === 4) {
                        r = style.substring(1, 2);
                        r += r;
                        g = style.substring(2, 3);
                        g += g;
                        b = style.substring(3, 4);
                        b += b;
                    } else {
                        r = style.substring(1, 3);
                        g = style.substring(3, 5);
                        b = style.substring(5, 7);
                    }
                    r = parseInt(r, 16);
                    g = parseInt(g, 16);
                    b = parseInt(b, 16);
                }
            }
        }
        return { r: r, g: g, b: b, a: a, style: style };
    }
helper functions 
Get the decimal values of r, g, b and a

@name getRGBA
@function
@private
@ignore