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


Python color_objects.RGBColor类代码示例

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


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

示例1: extract_bsdf

def extract_bsdf(wd):
  color=RGBColor()
  color.set_from_rgb_hex(wd.color)
  lab=color.convert_to('lab')
  c=wd.contrast
  d=wd.d()
  return lab,(c,d)
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:7,代码来源:gist.py

示例2: closest_delta_e

    def closest_delta_e(self, hex):
        """
        Calculates the Delta E difference between a hex value and others in
        the specified palette and returns the closest match (CMC method)
        http://en.wikipedia.org/wiki/Color_difference#CMC_l:c_.281984.29
        """
        incumbent = RGBColor(*webcolors.hex_to_rgb(hex))

        shortest_dist = None
        nearest_colour = None
        for key, details in self.colours().items():

            candidate = RGBColor(*webcolors.hex_to_rgb(key))
            cdist = incumbent.delta_e(candidate, method="cmc")
            if nearest_colour is None:
                nearest_colour = (candidate, key, details)
                shortest_dist = cdist
            elif cdist < shortest_dist:
                shortest_dist = cdist
                nearest_colour = (candidate, key, details)

        details = nearest_colour[2]
        name = details['name']
        hex = self.hex(name)
        return hex, name
开发者ID:cooperhewitt,项目名称:py-cooperhewitt-swatchbook,代码行数:25,代码来源:palette.py

示例3: contrast_text

 def contrast_text(self):
     """Returns hex code of a color that contrasts with this one, for 
     overlaying text. Includes the #."""
             
     # get rgb and hsv values
     rgbcolor = RGBColor()
     rgbcolor.set_from_rgb_hex(self.color_hex)
     
     hsvcolor = rgbcolor.convert_to('hsv')
     
     new_v = hsvcolor.hsv_v;
     
     if new_v <= .55:
         new_v = 1.0;
     elif new_v > .55:
         new_v = 0.0;
     
     new_h = hsvcolor.hsv_h
     
     new_s = 0
     
     contrast = HSVColor(hsv_h = new_h, hsv_s = new_s, hsv_v = new_v)
     contrast_rgb = contrast.convert_to('rgb')
     
     return contrast_rgb.get_rgb_hex()
开发者ID:foxfirefey,项目名称:memewidth-styles,代码行数:25,代码来源:models.py

示例4: hex_me_up

    def hex_me_up(self):

        self.hex_value = webcolors.rgb_to_hex(self.rgb)
        snapped, colour_name = swatchbook.closest_delta_e('css3', self.hex_value)
        snapped_rgb = webcolors.hex_to_rgb(snapped)
        hsv = self.rgb_to_hsv(*snapped_rgb)
        target = RGBColor(*snapped_rgb)
        original = RGBColor(*self.rgb)
        cdist = target.delta_e(original, method="cmc")
        prom = Decimal(self.prominence).quantize(TWOPLACES)
        dist = Decimal(cdist).quantize(TWOPLACES)
        ELITE = False

        self.css = {
            'r': self.rgb[0],
            'g': self.rgb[1],
            'b': self.rgb[2],
            'hue': hsv[0],
            'hex': snapped,
            'name': colour_name,
            'distance': float(dist),
            'prominence': float(prom),
            'elite': ELITE,
        }

        return self.css
开发者ID:richbs,项目名称:colourlens,代码行数:26,代码来源:utils.py

示例5: get_lab

 def get_lab(self):
     """ returns the current point in L*a*b* """
     if not hasattr(self, '_lab'):
         c = RGBColor()
         c.set_from_rgb_hex(self.sRGB)
         self._lab = c.convert_to('lab').get_value_tuple()
     return self._lab
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:7,代码来源:models.py

示例6: fade_colors_rgb

	def fade_colors_rgb(self,rgbcolor1,rgbcolor2,speed=0.1):
		"""	
		Values for color conversion: Best result for me: 

		target_illuminant=d50
		target_rgb=sRGB

		target_illuminant= 
		'a'  'b' 'c' 'd50' 'd55' 'd65' 'd75' 'e' 'f2' 'f7' 'f11'

		target_rgb=
		'adobe_rgb' 'apple_rgb' 'best_rgb' 'bruce_rgb' 'cie_rgb' 'colormatch_rgb' 'don_rgb_4' 'eci_rgb' 'ekta_space_ps5' 'ntsc_rgb' 'pal_secam_rgb' 'prophoto_rgb' 'smpte_c_rgb' 'srgb' 'wide_gamut_rgb' 
		"""

		rgb1 = RGBColor(rgbcolor1[0],rgbcolor1[1],rgbcolor1[2])
		rgb2 = RGBColor(rgbcolor2[0],rgbcolor2[1],rgbcolor2[2])
		l1 = rgb1.convert_to('lab',target_illuminant='d50')
		l2 = rgb2.convert_to('lab',target_illuminant='d50')
		lab1 =[l1.lab_l,l1.lab_a,l1.lab_b]
		lab2 =[l2.lab_l,l2.lab_a,l2.lab_b]

		for i in range(0,self.fade_steps+1):
			l=self.transition3(i,self.fade_steps,lab1,lab2)
			lab=LabColor(l[0],l[1],l[2])
			r=lab.convert_to('rgb')
			rgb=[r.rgb_r,r.rgb_g,r.rgb_b]
			self.set_color_rgb(rgb)
			sleep(speed)
开发者ID:morgulbrut,项目名称:rgb_led,代码行数:28,代码来源:rgb_led.py

示例7: db_insert

def db_insert(filename, url, palette, rssid):
    if db[COLLECTION].find({'opedid':filename}).count() > 0:
        return
    doc = {}
    doc['opedid'] = filename
    doc['url'] = url
    # rgbs = []
    labs = []
    prominences = []
    for color in palette.colors:
        # rgbs.append(list(color.value))
        prominences.append(color.prominence)
        lab_color = RGBColor(*color.value).convert_to('lab')
        labs.append(list(lab_color.get_value_tuple()))
    # Rotate arrays
    # rgbs = zip(*rgbs)
    labs = zip(*labs)
    #doc['r'] = rgbs[0]
    #doc['g'] = rgbs[1]
    #doc['b'] = rgbs[2]
    doc['l'] = labs[0]
    doc['a'] = labs[1]
    doc['b'] = labs[2]
    doc['prominence'] = prominences
    doc['rssid'] = rssid
    db[COLLECTION].insert(doc, safe=True)
开发者ID:brishin,项目名称:nSquared,代码行数:26,代码来源:colorific.py

示例8: get_rgb

 def get_rgb(self):
     """ return the color as a list """
     if not hasattr(self, '_rgb'):
         c = RGBColor()
         c.set_from_rgb_hex(self.sRGB)
         self._rgb = (c.rgb_r / 255.0, c.rgb_g / 255.0, c.rgb_b / 255.0)
     return self._rgb
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:7,代码来源:models.py

示例9: color_distance

def color_distance(color_a, color_b):
    
    from colormath.color_objects import RGBColor
    
    colora = RGBColor(rgb_r = color_a.rR, rgb_g = color_a.rG, rgb_b = color_a.rB)
    colorb = RGBColor(rgb_r = color_b.rR, rgb_g = color_b.rG, rgb_b = color_b.rB)
    
    return colora.delta_e(colorb, mode='cmc', pl=1, pc=1)
开发者ID:foxfirefey,项目名称:memewidth-styles,代码行数:8,代码来源:models.py

示例10: find_related_pixel

    def find_related_pixel(self):
        self.is_parse = True

        try:
            fileimage = cStringIO.StringIO(urllib.urlopen(self.picture_url_high).read())
            img = Image.open(fileimage)
            imgResze = img.resize((1, 1), Image.ANTIALIAS)
            pixels = list(imgResze.getdata())
        except:
            print 'error color pixel'
            self.delete()
            return True
        
        color_insta = RGBColor(pixels[0][0],pixels[0][1],pixels[0][2])
        color_hex = color_insta.get_rgb_hex()
        color_hex = color_hex.replace("#", "")
                
        self.color = color_hex
        self.r_color = pixels[0][0]
        self.g_color = pixels[0][1]
        self.b_color = pixels[0][2]
        
        pixel_asso = None    
        for subscription in self.subscriptions.all():
            print 'Subscription => %s' %  subscription
            for mosaic in subscription.mosaics.all():
                print 'Mosaic : %s' % mosaic.name
                try:
                    img = img.resize((mosaic.pixel_size, mosaic.pixel_size), Image.ANTIALIAS)
                    filepath = settings.MEDIA_ROOT + '/pics/%s_%s.png' % (mosaic.pixel_size,self.id)
                    img.save(filepath, 'PNG')
                except:
                    print 'error save pixel min'
                    return True
                
                color_insta = RGBColor(pixels[0][0],pixels[0][1],pixels[0][2])
                color_hex = color_insta.get_rgb_hex()
                color_hex = color_hex.replace("#", "")
                delta_e = 100   
                 
                for pixel in mosaic.pixels.filter(pic__isnull=True):
                    pixel_color = RGBColor(pixel.r_color,pixel.g_color,pixel.b_color)
                    delta_e_new = color_insta.delta_e(pixel_color)
                    #print '#'+pixel.color 
                    #print color_insta.get_rgb_hex() 
                    #print delta_e_new 
                    if delta_e_new < delta_e:
                        delta_e = delta_e_new
                        pixel_asso = pixel
                print 'minimum delta_e %s' % delta_e
                
                if pixel_asso:
	                if delta_e < 25:
		                print 'set pixel %s with delta %s' % (pixel_asso.id,delta_e)
		                pixel_asso.pic = self
		                pixel_asso.save()
		                self.add_to_fake_mosaic(mosaic, pixel_asso)
        self.save()
开发者ID:alenoir,项目名称:instamoz_api,代码行数:58,代码来源:models.py

示例11: save

 def save(self, *args, **kwargs):
     if (self.color_L is None) or (self.color_a is None) or (self.color_b is None):
         c = RGBColor()
         c.set_from_rgb_hex(self.color)
         c = c.convert_to('lab')
         self.color_L = c.lab_l
         self.color_a = c.lab_a
         self.color_b = c.lab_b
     super(ShapeBsdfLabel_wd, self).save(*args, **kwargs)
开发者ID:CV-IP,项目名称:opensurfaces,代码行数:9,代码来源:models.py

示例12: find_color_opeds

def find_color_opeds(rgb_hex):
  'Returns matching opeds for a given color'
  color = RGBColor()
  color.set_from_rgb_hex('#' + rgb_hex)
  cursor = db_find(color)
  colors = mongo_to_colors(cursor)
  results = find_closest(color, colors)[:MAX_COLOR_RESULTS]
  opeds = [result[0] for result in results]
  return opeds
开发者ID:brishin,项目名称:nSquared,代码行数:9,代码来源:api.py

示例13: scaled_rgb

def scaled_rgb(hex_color, component=None, factor=1.0):
    rgb_color = RGBColor()
    rgb_color.set_from_rgb_hex(hex_color)
    values = list(map(lambda x: factor * (x / 255), rgb_color.get_value_tuple()))
    if component is None:
        return '{} {} {}'.format(*rgb_color.get_value_tuple())
    else:
        comp_idx = ('R', 'G', 'B').index(component)
        return '{}'.format(values[comp_idx])
开发者ID:Boltovnya,项目名称:dotfiles-1,代码行数:9,代码来源:trtpl_filters.py

示例14: fromRGBAHex

 def fromRGBAHex(self, rgba_hex, background_hex):
   self.fromRGBHex(rgba_hex[:7])
   
   if len(rgba_hex) > 7:
     opacity = int(100 * (int(rgba_hex[7:], 16) / 255))
     background = RGBColor()
     if len(background_hex) > 7:
       background_hex = "#ffffff"
     background.set_from_rgb_hex(background_hex)
     self.mix(background, opacity)
开发者ID:ciembor,项目名称:bootstyle,代码行数:10,代码来源:color.py

示例15: alter_lch

def alter_lch(hex_color, value, component='L', relative=True):
    rgb_color = RGBColor()
    rgb_color.set_from_rgb_hex(hex_color)
    lch_color = rgb_color.convert_to('lchab')
    lch_lst = list(lch_color.get_value_tuple())
    comp_idx = ('L', 'C', 'H').index(component)
    lch_lst[comp_idx] = lch_lst[comp_idx] + value if relative else value
    L, C, H = lch_lst
    lch_res = LCHabColor(L, C, H)
    return lch_to_hex(lch_res)
开发者ID:Boltovnya,项目名称:dotfiles-1,代码行数:10,代码来源:trtpl_filters.py


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