python类hls_to_rgb()的实例源码

visualization.py 文件源码 项目:krpcScripts 作者: jwvanderbeck 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def default_color_function(ctx, z):
    if ctx.isinf(z):
        return (1.0, 1.0, 1.0)
    if ctx.isnan(z):
        return (0.5, 0.5, 0.5)
    pi = 3.1415926535898
    a = (float(ctx.arg(z)) + ctx.pi) / (2*ctx.pi)
    a = (a + 0.5) % 1.0
    b = 1.0 - float(1/(1.0+abs(z)**0.3))
    return hls_to_rgb(a, b, 0.8)
slice_viewer.py 文件源码 项目:BrainModulyzer 作者: sugeerth 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def __init__(self, templateData, parcelationData, axis, correlationTable, colorTable, selectedColor):
        super(SliceViewer, self).__init__()

        self.template = templateData
        self.regionId = None
        self.parcelation = parcelationData
        self.axis = axis
        self.CommunityMode = False
        self.correlationTable = correlationTable
        self.colorTable= colorTable
        self.selectedColor = selectedColor
        self.displayedSlice = 0
        self.QImage = []
        scalefactor = 350
        self.scaleFactor = int(math.ceil(scalefactor / self.parcelation.shape[0]))

        numColors = self.parcelation.max()
        self.clut = np.zeros(numColors, dtype=np.uint32)

        for i in range(numColors):
            r, g, b = colorsys.hls_to_rgb(float(i) / float(numColors), 0.5, 1.0)
            self.clut[i] = (255 << 24 | int(255*r) << 16 | int(255*g) << 8 | int(255*b))

        slice_view_layout = QtGui.QHBoxLayout()
        self.setLayout(slice_view_layout)

        slider = QtGui.QSlider()
        slider.setRange(0, self.template.shape[self.axis]-1)
        slider.valueChanged.connect(self.setDisplayedSlice)
        slider.sliderReleased.connect(self.handleSliderRelease)
        slider.setValue(self.displayedSlice)
        slice_view_layout.addWidget(slider)

        self.label = QtGui.QLabel()
        self.updateSliceLabel()
        slice_view_layout.addWidget(self.label)
communityDetectionEngine.py 文件源码 项目:BrainModulyzer 作者: sugeerth 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def ColorForCommunities(self,counter):
        k=self.updateCommunityColors(counter)
        self.ColorVisit = []
        m = len(self.oneLengthCommunities)
        for i in range(counter):
            if i in self.oneLengthCommunities: 
                r,g,b = 0.5,0.5,0.5
                self.clut[i] = (255 << 24 | int(255*r) << 16 | int(255*g) << 8 | int(255*b))
                self.ColorVisit.append((r*255,g*255,b*255,255))
            else:
                r, g, b =  colorsys.hls_to_rgb(float(i) / float(counter-m), 0.8, 0.9)
                self.clut[i] = (255 << 24 | int(255*r) << 16 | int(255*g) << 8 | int(255*b))
                self.ColorVisit.append((r*255,g*255,b*255,255))
test_colorsys.py 文件源码 项目:oil 作者: oilshell 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_hls_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb))
                    )
test_colorsys.py 文件源码 项目:python2-tracer 作者: extremecoders-re 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_hls_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb))
                    )
test_colorsys.py 文件源码 项目:web_ctp 作者: molebot 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_hls_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb))
                    )
ted-editor.py 文件源码 项目:ted-editor 作者: tarnheld 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def rgb_lighten_saturate(rgb, dl,ds):
    hls = colorsys.rgb_to_hls(*rgb)
    hls = (hls[0], hls[1] + dl, hls[2] + ds)
    return colorsys.hls_to_rgb(*hls)
ted-editor.py 文件源码 项目:ted-editor 作者: tarnheld 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def hex_lighten_saturate(hexstr, dl, ds):
    hls = colorsys.rgb_to_hls(*hex2rgb(hexstr))
    hls = (hls[0], hls[1] + dl, hls[2] + ds)
    return rgb2hex(colorsys.hls_to_rgb(*hls))
arceditor4.py 文件源码 项目:ted-editor 作者: tarnheld 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def rgb_lighten_saturate(rgb, amount):
  hls = colorsys.rgb_to_hls(*rgb)
  hls = (hls[0], hls[1] + dl, hls[2] + ds)
  return colorsys.hls_to_rgb(*hls)
arceditor4.py 文件源码 项目:ted-editor 作者: tarnheld 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def hex_lighten_saturate(hexstr, dl,ds):
  hls = colorsys.rgb_to_hls(*hex2rgb(hexstr))
  hls = (hls[0], hls[1] + dl, hls[2] + ds)
  return rgb2hex(colorsys.hls_to_rgb(*hls))
color.py 文件源码 项目:ivport-v2 作者: ivmech 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def from_hls(cls, h, l, s):
        """
        Construct a :class:`Color` from `HLS`_ (hue, lightness, saturation)
        floats between 0.0 and 1.0.
        """
        return super(Color, cls).__new__(cls, *colorsys.hls_to_rgb(h, l, s))
icon_rnn.py 文件源码 项目:mandylion 作者: DOsinga 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def create_poster(net, icon_size, poster_path):
  icon_size_2 = (icon_size + 2)
  poster = Image.new('RGB', (icon_size_2 * 20, icon_size_2 * 15), color=(255, 255, 255))

  net.run_step(embed([icon_size + 1], icon_size + 2), True)

  for x in range(20):
    for y in range(15):
      icon_coos = generate_icon(net, icon_size)
      rgb = colorsys.hls_to_rgb(random.random(), 0.30, 0.9)
      rgb = tuple(int(v * 255) for v in rgb)
      for x1, y1 in icon_coos:
        poster.putpixel((icon_size_2 * x + x1, icon_size_2 * y + y1), rgb)
  poster.save(poster_path)
rgba.py 文件源码 项目:sublimeTextConfig 作者: luoye-fe 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def fromhls(self, h, l, s):
        """Convert to RGB from HSL."""

        r, g, b = hls_to_rgb(h, l, s)
        self.r = round_int(r * 255.0) & 0xFF
        self.g = round_int(g * 255.0) & 0xFF
        self.b = round_int(b * 255.0) & 0xFF
test_colorsys.py 文件源码 项目:pefile.pypy 作者: cloudtracer 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_hls_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb))
                    )
test_colorsys.py 文件源码 项目:ouroboros 作者: pybee 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def test_hls_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb))
                    )
test_colorsys.py 文件源码 项目:ndk-python 作者: gittor 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def test_hls_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb))
                    )
visualization.py 文件源码 项目:Python-iBeacon-Scan 作者: NikNitro 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def default_color_function(ctx, z):
    if ctx.isinf(z):
        return (1.0, 1.0, 1.0)
    if ctx.isnan(z):
        return (0.5, 0.5, 0.5)
    pi = 3.1415926535898
    a = (float(ctx.arg(z)) + ctx.pi) / (2*ctx.pi)
    a = (a + 0.5) % 1.0
    b = 1.0 - float(1/(1.0+abs(z)**0.3))
    return hls_to_rgb(a, b, 0.8)
chathelper.py 文件源码 项目:stepmania-server 作者: ningirsu 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def nick_color(nick):
    """
        Generate a color from a given string.

        :param str nick: Input string
        :return: A hex color
        :rtype: str

        >>> nick_color("A")
        '005ad0'

        >>> nick_color("Hello!")
        'f20c1a'
    """
    try:
        return STATIC_COLOR[nick.lower()]
    except KeyError:
        pass

    nick_int = sum(ord(n)*3 for n in nick)

    hue = (nick_int % 100) / 100

    color = hls_to_rgb(hue, 0.5, 0.9)

    return ''.join(["{:02x}".format(int(c*255)) for c in color])
test_colorsys.py 文件源码 项目:kbe_server 作者: xiaohaoppy 项目源码 文件源码 阅读 17 收藏 0 点赞 0 评论 0
def test_hls_roundtrip(self):
        for r in frange(0.0, 1.0, 0.2):
            for g in frange(0.0, 1.0, 0.2):
                for b in frange(0.0, 1.0, 0.2):
                    rgb = (r, g, b)
                    self.assertTripleEqual(
                        rgb,
                        colorsys.hls_to_rgb(*colorsys.rgb_to_hls(*rgb))
                    )
colors.py 文件源码 项目:rvmi-rekall 作者: fireeye 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def HSLToRGB(hue, saturation, luminosity):
    red, green, blue = colorsys.hls_to_rgb(hue, luminosity, saturation)
    return int(red * 0xff), int(green * 0xff), int(blue * 0xff)


问题


面经


文章

微信
公众号

扫码关注公众号