• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python colors.getAllNamedColors函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中reportlab.lib.colors.getAllNamedColors函数的典型用法代码示例。如果您正苦于以下问题:Python getAllNamedColors函数的具体用法?Python getAllNamedColors怎么用?Python getAllNamedColors使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getAllNamedColors函数的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: printableColors

def printableColors():
	allColors = colors.getAllNamedColors()
	colorsForCategories = colors.getAllNamedColors().values()
	for k in allColors.keys():
		for unwantedName in ['white', 'yellow', 'CMYK', 'black', 'transparent']:
			if k.find(unwantedName) > -1: 
				print "removing %s" % k
				if allColors[k] in colorsForCategories:
					colorsForCategories.remove(allColors[k])
	return colorsForCategories
开发者ID:jawspeak,项目名称:google-docs-spreadsheet-namebadge-printer,代码行数:10,代码来源:csv_to_eng_mgr_game_cards.py


示例2: _render

    def _render(self, drawing):
        gap = 5

        legend = legends.Legend()
        legend.alignment = 'right'
        legend.x = gap
        legend.y = self.height - 3 * gap
        legend.deltay = 5
        legend.dxTextSpace = 5
        legend.fontSize = 14
        legend.columnMaximum = len(colors.getAllNamedColors().keys())
        legend.colorNamePairs = zip(colors.getAllNamedColors().values(),
                                    colors.getAllNamedColors().keys())

        drawing.add(legend, 'legend')
开发者ID:droodle,项目名称:eureka-opensource,代码行数:15,代码来源:comp.py


示例3: test1

    def test1(self):
        "Test colorDistance function."

        cols = colors.getAllNamedColors().values()
        for col in cols:
            d = colors.colorDistance(col, col)
            assert d == 0
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:7,代码来源:test_lib_colors.py


示例4: printColors

def printColors(canvas):  
    canvas.setFont("Helvetica",10)
    y = x = 0; dy=inch*1/2.0; dx=1*inch; w=h=dy/2  
    rdx=(dx-w)/2; rdy=h/5.0
    available_paper = 10*inch

    for name, color in colors.getAllNamedColors().iteritems():

    # for [namedcolor, name] in (  
        # 'darkseagreen', 'darkslateblue',
        #  [colors.darkblue, 'darkblue'],
        #  [colors.darkcyan, 'darkcyan'],
        #  [colors.darkolivegreen, 'darkolivegreen'],
        #  [colors.cornflower, 'cornflower'],
        #  [colors.orchid, 'orchid'],
        
        #  [colors.lavenderblush, "lavenderblush"],  
        #  [colors.lawngreen, "lawngreen"],  
        #  [colors.lemonchiffon, "lemonchiffon"],  
        #  [colors.lightblue, "lightblue"],  
        #  [colors.lightcoral, "lightcoral"]):  
        canvas.setFillColor(color)  
        canvas.rect(x+rdx, y+rdy, w, h, fill=1)
        canvas.setFillColor(colors.black)  
        canvas.drawString(x+dx/4 + 1*inch, y+rdy, name)  
        rdy += .2*inch
        available_paper -= (y+rdy)
        if available_paper < 1*inch:
            c.showPage()
            y = x = 0; dy=inch*1/2.0; dx=1*inch; w=h=dy/2  
            rdx=(dx-w)/2; rdy=h/5.0
            available_paper = 10*inch
开发者ID:jawspeak,项目名称:google-docs-spreadsheet-namebadge-printer,代码行数:32,代码来源:color_sample.py


示例5: test0

    def test0(self):
        "Test color2bw function on all named colors."

        cols = colors.getAllNamedColors().values()
        for col in cols:
            gray = colors.color2bw(col)
            r, g, b = gray.red, gray.green, gray.blue
            assert r == g == b
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:8,代码来源:test_lib_colors.py


示例6: draw

 def draw(self):
     """Actually draws the filled or outlined path on the canvas.
     """
     if self.fill_color:
         self.canvas.setFillColor(getAllNamedColors()[self.fill_color])
         self.canvas.drawPath(self.p, fill=True, stroke=False)
     else:
         self.canvas.drawPath(self.p, fill=False, stroke=True)
开发者ID:muescha,项目名称:juliabase,代码行数:8,代码来源:informal_stacks.py


示例7: get

    def get(col_str):
        allcols = colors.getAllNamedColors()

        regex_t = re.compile('\(([0-9\.]*),([0-9\.]*),([0-9\.]*)\)')
        regex_h = re.compile('#([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])')

        if col_str in allcols.keys():
                return allcols[col_str]
        res = regex_t.search(col_str, 0)
        if res:
                return (float(res.group(1)),float(res.group(2)),float(res.group(3)))
        res = regex_h.search(col_str, 0)
        if res:
                return tuple([ float(int(res.group(i),16))/255 for i in range(1,4)])
        return colors.red
开发者ID:dragotin,项目名称:kraft,代码行数:15,代码来源:erml2pdf.py


示例8: get_available_colors

    def get_available_colors(self):
        """Returns a list of available colors"""

        # Get reportlab available colors
        colors = getAllNamedColors()

        # Remove bad colors
        colors.pop('white', None)
        colors.pop('black', None)

        # Returns only the colors values (without their names)
        colors = colors.values()
        
        # Shuffle colors list
        random.shuffle(colors)

        return colors
开发者ID:7o9,项目名称:stdm-plugin,代码行数:17,代码来源:charts.py


示例9: test4

    def test4(self):
        "Construct CMYK instances and test round trip conversion"

        rgbCols = colors.getAllNamedColors().items()

        # Make a roundtrip test (RGB > CMYK > RGB).
        for name, rgbCol in rgbCols:
            r1, g1, b1 = rgbCol.red, rgbCol.green, rgbCol.blue
            c, m, y, k = colors.rgb2cmyk(r1, g1, b1)
            cmykCol = colors.CMYKColor(c,m,y,k)
            r2, g2, b2 = cmykCol.red, cmykCol.green, cmykCol.blue #colors.cmyk2rgb((c, m, y, k))
            rgbCol2 = colors.Color(r2, g2, b2)

            # Make sure the differences for each RGB component
            # isreally small (< power(10, -N)!
            N = 16 # max. value found to work on Python2.0 and Win2K.
            deltas = map(abs, (r1-r2, g1-g2, b1-b2))
            assert deltas < [math.pow(10, -N)] * 3
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:18,代码来源:test_lib_colors.py


示例10: test3

    def test3(self):
        "Test roundtrip RGB to CMYK conversion."

        # Take all colors as test subjects, except 'transparent'.
##        rgbCols = colors.getAllNamedColors()
##        del rgbCols['transparent']
        rgbCols = colors.getAllNamedColors().items()

        # Make a roundtrip test (RGB > CMYK > RGB).
        for name, rgbCol in rgbCols:
            r1, g1, b1 = rgbCol.red, rgbCol.green, rgbCol.blue
            c, m, y, k = colors.rgb2cmyk(r1, g1, b1)
            r2, g2, b2 = colors.cmyk2rgb((c, m, y, k))
            rgbCol2 = colors.Color(r2, g2, b2)

            # Make sure the differences for each RGB component
            # isreally small (< power(10, -N)!
            N = 16 # max. value found to work on Python2.0 and Win2K.
            deltas = map(abs, (r1-r2, g1-g2, b1-b2))
            assert deltas < [math.pow(10, -N)] * 3
开发者ID:sengupta,项目名称:scilab_cloud,代码行数:20,代码来源:test_lib_colors.py


示例11: dibujarPartes

def dibujarPartes():
    """Dibujar nodos y arcos."""

    for linea in ArrLineas:
        linea.strokeColor = Color(0,0.51,0.84)
        linea.strokeWidth = 2
        d.add(linea)

    for nodo in ArrNodos:
        # nodo.circulo.setFill('blue')
        # nodo.circulo.setOutline('cyan')
        nodo.circulo.fillColor = Color(0,0.51,0.84)
        nodo.circulo.strokeColor = Color(0,0.51,0.84)
        # nodo.circulo.strokeWidth = 5
        d.add(nodo.circulo)
        tex = String(nodo.centro.x,nodo.centro.y,str(nodo.numero))
        tex.textAnchor = 'middle'
        tex.fontSize = 18
        tex.fillColor = getAllNamedColors()['white']
        d.add(tex)
开发者ID:CicloviaTeam,项目名称:CicloviaProgram,代码行数:20,代码来源:grafo.py


示例12: get

def get(col_str):
    """
    parse a string and return a tuple
    """
    all_colors = colors.getAllNamedColors()

    if col_str in all_colors.keys():
        return all_colors[col_str]

    res = RGB_REGEX.search(col_str, 0)

    if res:
        return (float(res.group(1)),
                float(res.group(2)),
                float(res.group(3)))

    res = HEX_REGEX.search(col_str, 0)

    if res:
        return tuple([float(int(res.group(i), 16)) / 255 for i in range(1, 4)])
    return colors.red
开发者ID:eduardocereto,项目名称:trml2pdf,代码行数:21,代码来源:color.py


示例13: _toColor

def _toColor(arg, default=None):
    '''try to map an arbitrary arg to a color instance'''
    if isinstance(arg, Color): return arg
    tArg = type(arg)
    if tArg in (types.ListType, types.TupleType):
        assert 3 <= len(arg) <= 4, 'Can only convert 3 and 4 sequences to color'
        assert 0 <= min(arg) and max(arg) <= 1
        return len(arg) == 3 and Color(arg[0], arg[1], arg[2]) or CMYKColor(arg[0], arg[1], arg[2], arg[3])
    elif tArg == types.StringType:
        C = getAllNamedColors()
        s = arg.lower()
        if C.has_key(s): return C[s]
        try:
            return toColor(eval(arg))
        except:
            pass
    try:
        return HexColor(arg)
    except:
        if default is None:
            raise ValueError('Invalid color value %r' % arg)
        return default
开发者ID:ejucovy,项目名称:xhtml2pdf,代码行数:22,代码来源:util.py


示例14: or

#    License, or (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.     
#
##############################################################################

from reportlab.lib import colors
import re

allcols = colors.getAllNamedColors()

regex_t = re.compile('\(([0-9\.]*),([0-9\.]*),([0-9\.]*)\)')
regex_h = re.compile('#([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])([0-9a-zA-Z][0-9a-zA-Z])')

def get(col_str):
    if col_str is None:
        col_str = ''
    global allcols
    if col_str in allcols.keys():
        return allcols[col_str]
    res = regex_t.search(col_str, 0)
    if res:
        return float(res.group(1)), float(res.group(2)), float(res.group(3))
    res = regex_h.search(col_str, 0)
    if res:
开发者ID:ccdos,项目名称:OpenERP,代码行数:31,代码来源:color.py


示例15: generate_diagram

def generate_diagram(filepath, layers, title, subject):
    """Generates the stack diagram and writes it to a PDF file.

    :param filepath: the path to the PDF file that should be written
    :param layers: the layers of the stack in chronological order
    :param title: the title of the PDF file
    :param subject: the subject of the PDF file

    :type filepath: str
    :type layers: list of `Layer`
    :type title: unicode
    :type subject: unicode
    """
    scale = Scale(layers)
    stack_height = build_stack(layers, scale)
    labels, displaced_labels = place_labels(layers)
    total_margin = dimensions["margin"]
    full_label_width = dimensions["label_skip"] + dimensions["label_width"]
    width = dimensions["stack_width"] + 2 * total_margin + full_label_width
    if Label.needs_left_row:
        width += full_label_width
    legend, legend_height = build_legend(displaced_labels, width)
    height = scale.scale_height + stack_height + legend_height + 2 * total_margin + dimensions["scale_skip"]
    if legend:
        height += dimensions["legend_skip"]
    verified = all(layer.verified for layer in layers)
    if not verified:
        red_line_space = dimensions["red_line_skip"] + dimensions["red_line_width"]
        width += 2 * red_line_space
        height += 2 * red_line_space
        total_margin += red_line_space

    c = canvas.Canvas(filepath, pagesize=(width, height), pageCompression=True)
    c.setAuthor("JuliaBase samples database")
    c.setTitle(title)
    c.setSubject(subject)
    c.setLineJoin(1)
    c.setLineCap(1)

    if not verified:
        red_line_position = dimensions["red_line_width"] / 2 + dimensions["red_line_skip"]
        c.saveState()
        c.setStrokeColor(getAllNamedColors()["red"])
        c.setLineWidth(dimensions["red_line_width"])
        c.rect(red_line_position, red_line_position, width - 2 * red_line_position, height - 2 * red_line_position)
        c.restoreState()
    c.translate(total_margin, total_margin)
    yoffset = 0
    for item in reversed(legend):
        item.drawOn(c, 0, yoffset)
        yoffset += item.height + 0.3 * lineskip
    if legend:
        c.translate(0, legend_height + dimensions["legend_skip"])
    for label in labels:
        label.print_label(c)
    c.saveState()
    if Label.needs_left_row:
        c.translate(full_label_width, 0)
    layers = [layer for layer in reversed(layers) if layer.nm >= 0]
    for i, layer in enumerate(layers):
        layer.draw(c)
    c.restoreState()
    c.translate(full_label_width if Label.needs_left_row else 0, stack_height + dimensions["scale_skip"])
    scale.draw(c)
    c.showPage()
    c.save()
开发者ID:muescha,项目名称:juliabase,代码行数:66,代码来源:informal_stacks.py


示例16: _create_colors

 def _create_colors(self, color_names):
     colors_by_name = colors.getAllNamedColors()
     return [colors_by_name[name] for name in color_names]
开发者ID:droodle,项目名称:eureka-opensource,代码行数:3,代码来源:comp.py



注:本文中的reportlab.lib.colors.getAllNamedColors函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python colors.linearlyInterpolatedColor函数代码示例发布时间:2022-05-26
下一篇:
Python abag.ABag类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap