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


Python color.Color类代码示例

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


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

示例1: stop

  def stop(self):
    try:
      pf = file(self.pidfile, 'r')
      pid = int(pf.read().strip())
      pf.close()
    except IOError:
      pid = None

    if not pid:
      print Color.colorear(MSG_PID_NO_EXISTE % self.pidfile, color=Color.WARNING)
      return # no es error en 'restart'

    # Matar el demonio
    try:
      while 1:
        os.kill(pid, SIGTERM)
        time.sleep(0.1)
    except OSError, err:
      codigo_error, msg_error = err
      if codigo_error == CODIGO_NO_SUCH_PROCESS:
        if os.path.exists(self.pidfile):
          os.remove(self.pidfile)
      else:
        print Color.colorear(msg_error)
        sys.exit(1)
开发者ID:victorprospectot,项目名称:tracking,代码行数:25,代码来源:daemon.py

示例2: calcColor

 def calcColor(self,red,green,blue):
     hsl = Hsl()
     color = Color()
     pix = "OTHER"
     HSL = hsl.rgb2hsl(red, green, blue)
     HSL[1] = round(HSL[1],2)
     HSL[2] = round(HSL[2],2)
     grayLevel = self.calcGrayLevel(red,green,blue)
     colorLevel = self.calcColorLevel(red,green,blue)
     grayLumLevel = self.calcGrayLumLevel(red, green, blue)
     for i in range(0,len(Hsl.__hueThresh__)):
         try:
             if(HSL[0]>=Hsl.__hueThresh__[i][0] and HSL[0]<=Hsl.__hueThresh__[i][1]):
                 if(HSL[1]>=Hsl.__satThresh__[i][0] and HSL[1]<Hsl.__satThresh__[i][1]):
                     if(HSL[2]>=Hsl.__lumThresh__[i][0] and HSL[2]<Hsl.__lumThresh__[i][1]):
                         pix = Hsl.__hslColors__[i]
                         if(grayLevel==0):
                             pix = Hsl.__hslColors__[i] + str(int(colorLevel))
                     
                         else:
                             if(pix=="Black" or pix=="White"):
                                 pix += str(colorLevel)
                             elif(pix=="Grey"):
                                 pix += str(colorLevel)
                             else:
                                 pix = "Gray" + str(grayLumLevel) + Hsl.__hslColors__[i] + str(colorLevel)
         
                         if(color.countColors(Hsl.__hslColors__[i])>=2):
                             pix = color.reassignLevels(pix,red,green,blue)
                         return str(int(grayLevel)) + pix 
         except IndexError:
             print "rgb::calcColor2() out of range!\n"
             print "__hueThresh__.Size: {}".format(len(Hsl.__hueThresh__))
开发者ID:theunknowner,项目名称:Pyth,代码行数:33,代码来源:rgb.py

示例3: add_style

 def add_style(self, name="Default", fontname="Arial", fontsize=20,
               primarycolor="fff", secondarycolor="fff",
               bordcolor="000", shadowcolor="000",
               bold=False, italic=False, scalex=100, scaley=100,
               spacing=0, bord=2, shadow=0, alignment=2,
               marginl=10, marginr=20, marginv=10):
     if not isinstance(primarycolor, Color):
         primarycolor = Color.from_hex(primarycolor)
     if not isinstance(secondarycolor, Color):
         secondarycolor = Color.from_hex(secondarycolor)
     if not isinstance(bordcolor, Color):
         bordcolor = Color.from_hex(bordcolor)
     if not isinstance(shadowcolor, Color):
         shadowcolor = Color.from_hex(shadowcolor)
     style_item = {
         "name": name,
         "font": {"name": fontname, "size": fontsize},
         "color": {
             "primary": primarycolor.ass_long,
             "secondary": secondarycolor.ass_long,
             "bord": bordcolor.ass_long,
             "shadow": shadowcolor.ass_long},
         "bold": bold, "italic": italic, "scale": [scalex, scaley],
         "spacing": spacing, "bord": bord,
         "shadow": shadow, "alignment": alignment,
         "margin": {"l": marginl, "r": marginr, "v": marginv}}
     self._script_data["style"][name] = style_item
开发者ID:aristotll,项目名称:Eyecandy,代码行数:27,代码来源:effector.py

示例4: testDefinesClamping

 def testDefinesClamping(self):
     a, b, c = Color(0, 1, 0), Color(-0.4, 0.5, 8.2), Color(0.3, 3.9, -4.6)
     self.assEqual(a.clamped(), Color(0, 1, 0))
     self.assEqual(b.clamped(), Color(0, 0.5, 1))
     self.assEqual(c.clamped(), Color(0.3, 1, 0))
     self.assEqual(c, Color(0.3, 3.9, -4.6))
     c.clamp()
     self.assEqual(c, Color(0.3, 1, 0))
开发者ID:swantescholz,项目名称:coding,代码行数:8,代码来源:color_test.py

示例5: __init__

    def __init__(self, red=0.0, green=0.0, blue=0.0, alpha=1.0, position=0, string=None):
        Color.__init__(self, red, green, blue, alpha)
        self.position = position

        if string:
            array = string.split(':')
            #Color.set_color_as_hex(self, array[0])
            self.set_color_as_hex(array[0])
            self.position = array[1]
开发者ID:Happy-Ferret,项目名称:sanaviron,代码行数:9,代码来源:gradientcolor.py

示例6: __init__

 def __init__(self):
   self._theme = deepcopy(default)
   for scope in self._theme:
     for color_name in self._theme[scope]:
       # if color is hex rgb
       if re.search("#[0-90a-fA-F]{6}", self._theme[scope][color_name]):
         color = Color()
         color.fromRGBHex(default[scope][color_name])
         self._theme[scope][color_name] = color
开发者ID:ciembor,项目名称:bootstyle,代码行数:9,代码来源:theme.py

示例7: get_at

 def get_at(self, pos):
     """
     Return color of a surface pixel.
     The pos argument represents x,y position of pixel.
     """
     x,y = pos       #*tuple unpack error in jython applet
     try:
         color = Color(self.getRGB(x,y))
     except:     #ArrayOutOfBoundsException
         raise IndexError
     return color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()  #0.23
开发者ID:bowbahdoe,项目名称:Keys,代码行数:11,代码来源:surface.py

示例8: set_at

 def set_at(self, pos, color):
     """
     Set color of a surface pixel.
     The arguments represent position x,y and color of pixel.
     """
     color = Color(color)    #0.23
     try:
         self.setRGB(pos[0],pos[1],color.getRGB())  #0.23
     except:     #ArrayOutOfBoundsException
         raise IndexError
     return None
开发者ID:bowbahdoe,项目名称:Keys,代码行数:11,代码来源:surface.py

示例9: status

  def status(self):
    try:
      pf = file(self.pidfile, 'r')
      pid = int(pf.read().strip())
      pf.close()
    except IOError:
      pid = None
    print Color.colorear(MSJ_STATUS(self.__str__(), 
      pid and 'running' or 'stopped', 
      pid and ' with pid: {pid}.'.format(pid=pid) or '.'), color=pid and Color.OKGREEN or Color.WARNING)

    sys.exit()
开发者ID:victorprospectot,项目名称:tracking,代码行数:12,代码来源:daemon.py

示例10: gen_params

def gen_params(images):
    params = []
    c = Color()
    
    for i in range(0, images):
        el = {}
        el['color'] = c.rnd_color()
        el['contrast'] = c.contrast()
        el['id'] = gen_id()
        params.append(el)
    
    return params
开发者ID:sszachow,项目名称:vcf_gen-js,代码行数:12,代码来源:gen_photos.py

示例11: ColorTestCase

class ColorTestCase(unittest.TestCase):
    def setUp(self):
        self.red = Color(255, 0, 0)
        self.blue = Color(0, 0, 255)

    def test_get_red(self):
        self.assertEqual(self.red.get_red(), 255)

    def test_get_green(self):
        self.assertEqual(self.red.get_green(), 0)

    def test_get_blue(self):
        self.assertEqual(self.blue.get_blue(), 255)
开发者ID:xashes,项目名称:study,代码行数:13,代码来源:test_color.py

示例12: TestColor

class TestColor(unittest.TestCase):

    def setUp(self):
        self.color1 = Color(42, 42, 42)
        self.color2 = Color(210, 210, 210)
        self.color3 = Color(42, 21, 58)
        self.color4 = Color(240, 41, 25)

    def tearDown(self):
        pass

    def test_color(self):
        self.assertTrue(self.color1.enough_contrast(self.color2))
        self.assertFalse(self.color3.enough_contrast(self.color4))
开发者ID:pageask,项目名称:python-exercises,代码行数:14,代码来源:tc_color.py

示例13: replace_color

 def replace_color(self, color, new_color=None):
     """
     Replace color with with new_color or with alpha.
     """
     pixels = self.getRGB(0,0,self.width,self.height,None,0,self.width)
     color1 = Color(color)    #0.23
     if new_color:
         color2 = Color(new_color)
     else:
         color2 = Color(color1.r,color1.g,color1.b,0)
     for i, pixel in enumerate(pixels):
         if pixel == color1.getRGB():
             pixels[i] = color2.getRGB()
     self.setRGB(0,0,self.width,self.height,pixels,0,self.width)
     return None
开发者ID:bowbahdoe,项目名称:Keys,代码行数:15,代码来源:surface.py

示例14: start

  def start(self):
    try:
      pf = file(self.pidfile, 'r')
      pid = int(pf.read().strip())
      pf.close()
    except Exception as e:
      pid = None

    if pid:
      print Color.colorear(MSG_PID_EXISTE % self.pidfile)
      sys.exit(1)

    # start the daemon
    self.daemonize()
    self.run()
开发者ID:victorprospectot,项目名称:tracking,代码行数:15,代码来源:daemon.py

示例15: __init__

    def __init__(self):
        self.palette = None
        self.color = Color()
        self.h_ids = {}
        self.color.connect("changed", self.color_changed)

        self.init_config()
        self.build_gui()

        self.palette_dir = os.path.join(base.save_config_path(appinfo.pkgname), "palettes")
        Palette.PaletteDir = self.palette_dir

        self.palette_list = PaletteList()
        self.palette_list.load(self.palette_dir)
        self.palette_combo.set_model(self.palette_list)

        # no palettes, so create default
        if len(self.palette_list) == 0:
            palette = Palette()
            palette.name = "Default Palette"
            palette.filename = os.path.join(self.palette_dir, "default.gpl")
            self.palette_list.append(palette)

            self.palette_combo.select(0)

        self.colorpicker.set_color(self.color)

        self.load_config()
开发者ID:molok,项目名称:elicit-gtk,代码行数:28,代码来源:elicit.py


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