当前位置: 首页>>代码示例>>Python>>正文


Python Color.getCairoColor方法代码示例

本文整理汇总了Python中color.Color.getCairoColor方法的典型用法代码示例。如果您正苦于以下问题:Python Color.getCairoColor方法的具体用法?Python Color.getCairoColor怎么用?Python Color.getCairoColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在color.Color的用法示例。


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

示例1: getCustomIcon

# 需要导入模块: from color import Color [as 别名]
# 或者: from color.Color import getCairoColor [as 别名]
  def getCustomIcon(self,parameterList,w,h):
    """
    there are six positional parameters:
    fill color,fill opacity, outline color, outline opacity,
    outline width (default 8) and corner radius (default 22)
    to use default value, just don't fill in the positional parameter
    ( len(parameter) == 0 )
    USAGE:
    corner radius: default=22, 0 does right angle corners
    

    EXAMPLE: generic:green;1.0;blue;0.5;10;15
    """
    # check if the list has proper length
    if len(parameterList) != 6:
      return None
    semicolonSepList = parameterList
    # process the positional parameters
    if len(semicolonSepList[0]):
      fillColorString = semicolonSepList[0]
    else:
      fillColorString = None

    if len(semicolonSepList[1]):
      fillAlpha = float(semicolonSepList[1])
    else:
      fillAlpha = 1.0

    if len(semicolonSepList[2]):
      outlineColorString = semicolonSepList[2]
    else:
      outlineColorString = None

    if len(semicolonSepList[3]):
      outlineAlpha = float(semicolonSepList[3])
    else:
      outlineAlpha = 1.0

    if len(semicolonSepList[4]):
      outlineWidth = int(semicolonSepList[4])
    else:
      outlineWidth = 4

    if len(semicolonSepList[5]):
      cornerRadius = int(semicolonSepList[5])
    else:
      cornerRadius = 22

    # parse the colors (if defined)

    if fillColorString:
      fillColor = Color("fill", (fillColorString,fillAlpha))
      fillColorRGBATuple = fillColor.getCairoColor()
    else:
      fillColorRGBATuple = self.buttonFillColor


    if outlineColorString:
      outlineColor = Color("outline", (outlineColorString,outlineAlpha))
      outlineColorRGBATuple = outlineColor.getCairoColor()
    else:
      outlineColorRGBATuple = self.buttonOutlineColor

    # apply the alpha values
    try:
      (r,g,b,a) = fillColorRGBATuple
      fillColorRGBATuple = (r,g,b,fillAlpha)
    except Exception, e:
      print("** wrong fill color code or name: %s" % fillColorString)
      print("** exception: %s" % e)
      fillColorRGBATuple = self.buttonFillColor
开发者ID:Wikiwide,项目名称:modrana,代码行数:73,代码来源:mod_icons.py


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