Code Duplication    Length = 28-29 lines in 2 locations

build/jsPDF.js 2 locations

@@ 1741-1769 (lines=29) @@
1738
        @methodOf jsPDF#
1739
        @name setFillColor
1740
         */
1741
        API.setFillColor = function (ch1, ch2, ch3, ch4) {
1742
            var color;
1743
1744
            if (ch2 === undefined || (ch4 === undefined && ch1 === ch2 === ch3)) {
1745
                // Gray color space.
1746
                if (typeof ch1 === 'string') {
1747
                    color = ch1 + ' g';
1748
                } else {
1749
                    color = f2(ch1 / 255) + ' g';
1750
                }
1751
            } else if (ch4 === undefined) {
1752
                // RGB
1753
                if (typeof ch1 === 'string') {
1754
                    color = [ch1, ch2, ch3, 'rg'].join(' ');
1755
                } else {
1756
                    color = [f2(ch1 / 255), f2(ch2 / 255), f2(ch3 / 255), 'rg'].join(' ');
1757
                }
1758
            } else {
1759
                // CMYK
1760
                if (typeof ch1 === 'string') {
1761
                    color = [ch1, ch2, ch3, ch4, 'k'].join(' ');
1762
                } else {
1763
                    color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), 'k'].join(' ');
1764
                }
1765
            }
1766
1767
            out(color);
1768
            return this;
1769
        };
1770
1771
        /**
1772
        Sets the text color for upcoming elements.
@@ 1675-1702 (lines=28) @@
1672
        @methodOf jsPDF#
1673
        @name setDrawColor
1674
         */
1675
        API.setDrawColor = function (ch1, ch2, ch3, ch4) {
1676
            var color;
1677
            if (ch2 === undefined || (ch4 === undefined && ch1 === ch2 === ch3)) {
1678
                // Gray color space.
1679
                if (typeof ch1 === 'string') {
1680
                    color = ch1 + ' G';
1681
                } else {
1682
                    color = f2(ch1 / 255) + ' G';
1683
                }
1684
            } else if (ch4 === undefined) {
1685
                // RGB
1686
                if (typeof ch1 === 'string') {
1687
                    color = [ch1, ch2, ch3, 'RG'].join(' ');
1688
                } else {
1689
                    color = [f2(ch1 / 255), f2(ch2 / 255), f2(ch3 / 255), 'RG'].join(' ');
1690
                }
1691
            } else {
1692
                // CMYK
1693
                if (typeof ch1 === 'string') {
1694
                    color = [ch1, ch2, ch3, ch4, 'K'].join(' ');
1695
                } else {
1696
                    color = [f2(ch1), f2(ch2), f2(ch3), f2(ch4), 'K'].join(' ');
1697
                }
1698
            }
1699
1700
            out(color);
1701
            return this;
1702
        };
1703
1704
        /**
1705
        Sets the fill color for upcoming elements.